コード例 #1
0
 public void InitAnimBool(SerializedProperty property)
 {
     if (visible == null)
     {
         visible       = new AnimBool();
         visible.speed = BlazeDrawerUtil.AnimSpeed;
         visible.valueChanged.AddListener(() => { BlazeDrawerUtil.RepaintInspector(property.serializedObject); });
     }
 }
コード例 #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            InitAnimBool(property);

            // EditorGUI.indentLevel--;
            // Debug.Log(position);

            // position = EditorGUI.IndentedRect(position);

            // Debug.Log(position);

            position.x     += 4;
            position.width -= 8;

            position.height = EditorGUIUtility.singleLineHeight;
            var temp = new GUIContent(label);

            SerializedProperty persistentCalls = property.FindPropertyRelative("m_PersistentCalls.m_Calls");

            if (persistentCalls != null)
            {
                temp.text += " (" + persistentCalls.arraySize + ")";
            }

            // visible.target = EditorGUI.Foldout(position, visible.value, temp, true);

#if UNITY_2019_1_OR_NEWER
            var hum = EditorGUIUtility.hierarchyMode;
            EditorGUIUtility.hierarchyMode = false;
            visible.target = EditorGUI.BeginFoldoutHeaderGroup(position, visible.target, temp);
            EditorGUIUtility.hierarchyMode = hum;
#else
            visible.target = EditorGUI.Foldout(position, visible.target, temp, true);
#endif
            if (BlazeDrawerUtil.BeginFade(visible))
            {
                label.text      = null;
                position.height = base.GetPropertyHeight(property, label);
                position.y     += EditorGUIUtility.singleLineHeight;
                base.OnGUI(position, property, label);
            }
            BlazeDrawerUtil.EndFade();
#if UNITY_2019_1_OR_NEWER
            EditorGUI.EndFoldoutHeaderGroup();
#endif
            // EditorGUI.indentLevel++;
        }
コード例 #3
0
        public void Refresh(SerializedProperty property)
        {
            var isNew      = false;
            var currentTab = GetCurrentTab(property);

            isNew = currentTab.Count == 0;

            if (isNew)
            {
                InitTab(property, currentTab);
                foreach (var tab in currentTab)
                {
                    tab.visible       = new AnimBool();
                    tab.visible.speed = BlazeDrawerUtil.AnimSpeed;
                    tab.visible.valueChanged.AddListener(() => { BlazeDrawerUtil.RepaintInspector(property.serializedObject); });
                }
            }
        }
コード例 #4
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Init(property);
            var currentState = GetCurrentState(property);

            var allTabs = GetCurrentTab(property);

            var valueProperty = property.FindPropertyRelative("value");

            var tempName = label.text;

            EditorGUI.BeginProperty(position, label, property);
            label.text = tempName;

            // position.y += verticalSpace * 2;

            var groupRect = new Rect(position.x, position.y + verticalSpace * 2, position.width, position.height - verticalSpace * 2);

            GUI.BeginGroup(groupRect, GUI.skin.box);

            var localX = 6;
            var localY = 4;
            var localW = position.width - 6 * 2;
            // var propertyTitleRect = new Rect(localX, localY  + EditorGUIUtility.singleLineHeight + verticalSpace + verticalSpace, localW - tabBtnWidth * allTabs.Count, EditorGUIUtility.singleLineHeight);
            // EditorGUI.LabelField(propertyTitleRect, label);

            var tabX = 0f;

            var toolBarRect = new Rect(localX + tabX, localY + EditorGUI.GetPropertyHeight(valueProperty) + verticalSpace + verticalSpace, localW, EditorGUIUtility.singleLineHeight);

            EditorGUI.BeginChangeCheck();
            // var tempSkin = GUI.skin;
            // GUI.skin = smallToolBarSkin;
            var tempI = currentState.editItem;
            var style = new GUIStyle("MiniPopup");

            //GUI.Toolbar(toolBarRect, currentState.editItem, allTabs.ConvertAll(x => x.icon.text).ToArray());
            toolBarRect.width = 50;
            toolBarRect.x    += localW;
            //+= localW - (toolBarRect.width + groupHorizontalSpace) * allTabs.Count + groupHorizontalSpace;
            for (int i = allTabs.Count - 1; i >= 0; i--)
            {
                toolBarRect.width = style.CalcSize(allTabs[i].icon).x;
                toolBarRect.x    -= toolBarRect.width;
                if (GUI.Button(toolBarRect, allTabs[i].icon, "MiniPopup"))
                {
                    tempI = i;
                }
                toolBarRect.x -= groupHorizontalSpace;
            }
            // GUI.skin = tempSkin;

            if (EditorGUI.EndChangeCheck())
            {
                if (currentState.editItem == tempI)
                {
                    currentState.editItem = -1;
                    CloseAllTab(property);
                }
                else
                {
                    currentState.trackedEditItem = tempI;
                    currentState.editItem        = tempI;
                    CloseAllTab(property);
                    allTabs[tempI].visible.target = true;
                }
            }

            // for (int i = 0; i < allTabs.Count; i++)
            // {
            //     var tab = allTabs[i];
            //     //localW - (allTabs.Count - i) * tabBtnWidth
            //     var tabWidth = GUI.skin.button.CalcSize(tab.icon).x;
            //     var btnRect = new Rect(localX + tabX, localY + EditorGUIUtility.singleLineHeight + verticalSpace + verticalSpace, tabWidth, EditorGUIUtility.singleLineHeight);
            //     tabX += tabWidth;
            //     if (GUI.Button(btnRect, tab.icon))
            //     {
            //         if (GetCurrentState(property).editItem == i)
            //         {
            //             GetCurrentState(property).editItem = -1;
            //             CloseAllTab(property);
            //         }
            //         else
            //         {
            //             GetCurrentState(property).trackedEditItem = i;
            //             GetCurrentState(property).editItem = i;
            //             CloseAllTab(property);
            //             tab.visible.target = true;
            //         }
            //     }
            // }

            // - tabBtnWidth * allTabs.Count
            var propertyRect = new Rect(localX, localY, localW, EditorGUI.GetPropertyHeight(valueProperty));

            // if (!allTabs.Any(x => x.visible.value))
            label.text = tempName;
            // Debug.Log(label.text);
            EditorGUI.PropertyField(propertyRect, valueProperty, label);

            GUI.EndGroup();

            subTitleVerticalSpace = EditorStyles.miniBoldLabel.CalcHeight(GUIContent.none, position.width);

            var extraRectGroup = new Rect(position.x + verticalSpace * 2, position.y + EditorGUIUtility.singleLineHeight + EditorGUI.GetPropertyHeight(valueProperty) + verticalSpace * 4 + 8, position.width - verticalSpace * 4, EditorGUIUtility.singleLineHeight);
            // extraRectGroup = EditorGUI.IndentedRect(extraRectGroup);

            var displayTab = allTabs[currentState.trackedEditItem];

            if (BlazeDrawerUtil.BeginFade(displayTab.visible))
            {
                extraRectGroup.height = GetItemsHeight(displayTab.contents) + verticalSpace;

                var indent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;

                GUI.BeginGroup(extraRectGroup);

                DrawItemContents(displayTab.contents, extraRectGroup.width);

                GUI.EndGroup();

                EditorGUI.indentLevel = indent;
            }
            BlazeDrawerUtil.EndFade();

            EditorGUI.EndProperty();
        }