示例#1
0
    public CUResizableContainerStyle()
    {
        resizerVertical               = new GUIStyle();
        resizerVertical.fixedHeight   = 6;
        resizerVertical.fixedWidth    = 42;
        resizerVertical.margin        = new RectOffset(0, 0, 1, 0);
        resizerVertical.imagePosition = ImagePosition.ImageOnly;
        if (EditorGUIUtility.isProSkin)
        {
            resizerVertical.normal.background = LoadRes.FindTextureOrGUISkin <Texture2D>("CUResizeDarkVertical.png");
        }
        else
        {
            resizerVertical.normal.background = LoadRes.FindTextureOrGUISkin <Texture2D>("CUResizeLightVertical.png");
        }

        resizerHorizontal               = new GUIStyle();
        resizerHorizontal.fixedHeight   = 42;
        resizerHorizontal.fixedWidth    = 6;
        resizerHorizontal.margin        = new RectOffset(1, 0, 0, 0);
        resizerHorizontal.imagePosition = ImagePosition.ImageOnly;
        if (EditorGUIUtility.isProSkin)
        {
            resizerHorizontal.normal.background = LoadRes.FindTextureOrGUISkin <Texture2D>("CUResizeDarkHorizontal.png");
        }
        else
        {
            resizerHorizontal.normal.background =
                LoadRes.FindTextureOrGUISkin <Texture2D>("CUResizeLightHorizontal.png");
        }
    }
示例#2
0
    public CUListStyle()
    {
        GUISkin skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);

        evenBackground = new GUIStyle(skin.FindStyle("OL EntryBackEven"));
        oddBackground  = new GUIStyle(skin.FindStyle("OL EntryBackOdd"));
        // default style doesn't handle focus. therefore we have to swap the textures
        evenBackground.onFocused.background = evenBackground.onNormal.background;
        oddBackground.onFocused.background  = oddBackground.onNormal.background;
        Texture2D texture;

        if (EditorGUIUtility.isProSkin)
        {
            texture = LoadRes.FindTextureOrGUISkin <Texture2D>("CUNotFocusedSelectionDark.png");
        }
        else
        {
            texture = LoadRes.FindTextureOrGUISkin <Texture2D>("CUNotFocusedSelectionLight.png");
        }
        evenBackground.onNormal.background = texture;
        oddBackground.onNormal.background  = texture;

        item             = new GUIStyle(skin.FindStyle("PlayerSettingsPlatform"));
        item.alignment   = TextAnchor.MiddleLeft;
        item.fixedHeight = 0;
        item.padding     = new RectOffset(5, 0, 0, 0);
        item.margin      = new RectOffset();

        dropIntoHighlight = new GUIStyle();
        dropIntoHighlight.normal.background = LoadRes.FindTextureOrGUISkin <Texture2D>("CUDragIntoHighlight.png");
        dropIntoHighlight.border            = new RectOffset(3, 3, 3, 3);
        dropIntoHighlight.stretchWidth      = true;
        dropIntoHighlight.stretchHeight     = true;
        dropIntoHighlight.imagePosition     = ImagePosition.ImageOnly;

        dropBeforeHighlight = new GUIStyle();
        dropBeforeHighlight.normal.background = LoadRes.FindTextureOrGUISkin <Texture2D>("CUDragBeforeHighlight.png");
        dropBeforeHighlight.border            = new RectOffset(0, 0, 3, 0);
        dropBeforeHighlight.stretchWidth      = true;
        dropBeforeHighlight.stretchHeight     = true;
        dropBeforeHighlight.overflow          = new RectOffset(0, 0, 1, 0);
        dropBeforeHighlight.imagePosition     = ImagePosition.ImageOnly;

        dropAfterHighlight = new GUIStyle();
        dropAfterHighlight.normal.background = LoadRes.FindTextureOrGUISkin <Texture2D>("BottomLine_Blue.png");
        dropAfterHighlight.border            = new RectOffset(0, 0, 0, 3);
        dropAfterHighlight.stretchWidth      = true;
        dropAfterHighlight.stretchHeight     = true;
        dropAfterHighlight.overflow          = new RectOffset(0, 0, 0, 1);
        dropAfterHighlight.imagePosition     = ImagePosition.ImageOnly;
    }
示例#3
0
    void OnEnable()
    {
        tex = LoadRes.FindTextureOrGUISkin <Texture>("replace.png");

        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);
            }
        };
    }