• 大小: 28.84M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-03
  • 语言: 其他
  • 标签: 其他  

资源简介

GeneralBook.zip

资源截图

代码片段和文件信息

using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
using UnityEditorInternal;
using System;

[CustomEditor(typeof(BookPro))]
public class BookProEditor : Editor
{
    ReorderableList list;
    Texture tex;
    private void OnEnable()
    {
        tex = AssetDatabase.LoadAssetAtPath(“Assets\\Book-Page Curl\\Editor\\replace.png“ typeof(Texture)) as Texture;
        if (tex == null)
        {
            tex = Texture2D.blackTexture;
        }
        list = new ReorderableList(serializedobject
                serializedobject.FindProperty(“papers“)
                true true true true);
        list.elementHeight = 75;
        list.drawElementCallback = DrawElement;
        list.drawHeaderCallback = drawHeader;
        list.onAddCallback = addElement;

        list.onCanRemoveCallback = canremove;

        list.onRemoveCallback = (ReorderableList l) =>
        {
            if (EditorUtility.DisplayDialog(“Warning!“
                “Are you sure you want to delete this Paper?\r\nThe paper pages (front and back) will be deleted from the scene“ “Yes“ “No“))
            {
                BookPro book = target as BookPro;
                if (book.EndFlippingPaper == book.papers.Length - 1)
                    book.EndFlippingPaper--;
                OnInspectorGUI();
                Paper paper = book.papers[l.index];

                book.LeftPageShadow.gameobject.SetActive(false);
                book.LeftPageShadow.transform.SetParent(book.transform);

                book.RightPageShadow.gameobject.SetActive(false);
                book.RightPageShadow.transform.SetParent(book.transform);

                Undo.DestroyobjectImmediate(paper.Back);
                Undo.DestroyobjectImmediate(paper.Front);
                ReorderableList.defaultBehaviours.DoRemoveButton(l);
                EditorUtility.SetDirty(book);
            }
        };
    }

    private bool canremove(ReorderableList list)
    {
        if (list.count == 1)
            return false;
        return true;
    }

    private void addElement(ReorderableList list)
    {
        BookPro book = target as BookPro;

        if (book.EndFlippingPaper == book.papers.Length - 1)
        {
            book.EndFlippingPaper = book.papers.Length;
            OnInspectorGUI();
        }

        list.serializedProperty.arraySize++;
        var lastElement = list.serializedProperty.GetArrayElementAtIndex(list.count - 1);


        Gameobject rightPage = Instantiate(book.RightPageTransform.gameobject) as Gameobject;
        rightPage.transform.SetParent(book.transform true);
        rightPage.GetComponent().sizeDelta = book.RightPageTransform.GetComponent().sizeDelta;
        rightPage.GetComponent().pivot = book.RightPageTransform.GetComponent().pivot;
        rightPage.GetComponent().anchoredPosition = book.RightPageTransfo

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-08-28 17:19  GeneralBook\
     目录           0  2017-11-14 14:14  GeneralBook\.git\
     文件          59  2017-08-21 17:13  GeneralBook\.gitignore
     文件           8  2017-09-30 09:24  GeneralBook\.git\COMMIT_EDITMSG
     文件         336  2017-09-30 09:24  GeneralBook\.git\config
     文件          73  2017-09-30 09:22  GeneralBook\.git\description
     文件          23  2017-09-30 09:22  GeneralBook\.git\HEAD
     目录           0  2017-11-14 14:14  GeneralBook\.git\hooks\
     文件         478  2017-09-30 09:22  GeneralBook\.git\hooks\applypatch-msg.sample
     文件         896  2017-09-30 09:22  GeneralBook\.git\hooks\commit-msg.sample
     文件         189  2017-09-30 09:22  GeneralBook\.git\hooks\post-update.sample
     文件         424  2017-09-30 09:22  GeneralBook\.git\hooks\pre-applypatch.sample
     文件        1642  2017-09-30 09:22  GeneralBook\.git\hooks\pre-commit.sample
     文件        1348  2017-09-30 09:22  GeneralBook\.git\hooks\pre-push.sample
     文件        4951  2017-09-30 09:22  GeneralBook\.git\hooks\pre-rebase.sample
     文件        1239  2017-09-30 09:22  GeneralBook\.git\hooks\prepare-commit-msg.sample
     文件        3610  2017-09-30 09:22  GeneralBook\.git\hooks\update.sample
     文件       15717  2017-09-30 09:24  GeneralBook\.git\index
     目录           0  2017-11-14 14:14  GeneralBook\.git\info\
     文件         240  2017-09-30 09:22  GeneralBook\.git\info\exclude
     目录           0  2017-11-14 14:14  GeneralBook\.git\logs\
     文件         156  2017-09-30 09:24  GeneralBook\.git\logs\HEAD
     目录           0  2017-11-14 14:14  GeneralBook\.git\logs\refs\
     目录           0  2017-11-14 14:14  GeneralBook\.git\logs\refs\heads\
     文件         156  2017-09-30 09:24  GeneralBook\.git\logs\refs\heads\master
     目录           0  2017-11-14 14:14  GeneralBook\.git\logs\refs\remotes\
     目录           0  2017-11-14 14:14  GeneralBook\.git\logs\refs\remotes\origin\
     文件         145  2017-09-30 09:24  GeneralBook\.git\logs\refs\remotes\origin\master
     目录           0  2017-11-14 14:14  GeneralBook\.git\objects\
     目录           0  2017-11-14 14:14  GeneralBook\.git\objects\04\
     文件         164  2017-09-30 09:23  GeneralBook\.git\objects\04\d5e463d6c136bb52f1d27c14a34556c2a99ff5
............此处省略1653个文件信息

评论

共有 条评论