public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     if (!_initialized)
     {
         Initialize(property);
     }
     _listHeight = _reorderableList?.GetHeight() ?? _listHeight;
     return(base.GetPropertyHeight(property, label) + _listHeight + _spaceAboveControl);
 }
Пример #2
0
        public void OnGUI()
        {
            // Use for debugging
            // EditorGUILayout.LabelField(m_Property.stringValue);

            var listRect = GUILayoutUtility.GetRect(200, m_ListView.GetHeight());

            listRect = EditorGUI.IndentedRect(listRect);
            m_ListView.DoList(listRect);

            if (m_ListView.index >= 0)
            {
                for (var i = 0; i < m_SelectedParameterList.Length; i++)
                {
                    var parameterValue = m_SelectedParameterList[i];
                    EditorGUI.BeginChangeCheck();

                    ////TODO: need to detect when value is at default

                    string result = null;
                    if (parameterValue.type == InputControlLayout.ParameterType.Integer)
                    {
                        var intValue = int.Parse(parameterValue.GetValueAsString());
                        result = EditorGUILayout.IntField(ObjectNames.NicifyVariableName(parameterValue.name), intValue).ToString();
                    }
                    else if (parameterValue.type == InputControlLayout.ParameterType.Float)
                    {
                        var floatValue = float.Parse(parameterValue.GetValueAsString());
                        result = EditorGUILayout.FloatField(ObjectNames.NicifyVariableName(parameterValue.name), floatValue).ToString();
                    }
                    else if (parameterValue.type == InputControlLayout.ParameterType.Boolean)
                    {
                        var boolValue = bool.Parse(parameterValue.GetValueAsString());
                        result = EditorGUILayout.Toggle(ObjectNames.NicifyVariableName(parameterValue.name), boolValue).ToString();
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        m_SelectedParameterList[i].SetValue(result);
                        m_Apply();
                    }
                }
            }
        }
Пример #3
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float h;

            if (EditorHelper.AssertMultiObjectEditingNotSupportedHeight(property, label, out h))
            {
                return(h);
            }

            if (property.isArray)
            {
                this.StartOnGUI(property, label);
                if (_disallowFoldout || property.isExpanded)
                {
                    h = _lst.GetHeight();
                    if (_drawElementAtBottom && _lst.index >= 0 && _lst.index < property.arraySize)
                    {
                        var pchild = property.GetArrayElementAtIndex(_lst.index);
                        if (_internalDrawer != null)
                        {
                            h += _internalDrawer.GetPropertyHeight(pchild, label) + BOTTOM_PAD + TOP_PAD;
                        }
                        else if (pchild.hasChildren && pchild.objectReferenceValue is MonoBehaviour)
                        {
                            //we don't draw this way if it's a built-in type from Unity
                            h += SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + BOTTOM_PAD + TOP_PAD - EditorGUIUtility.singleLineHeight;
                        }
                        else
                        {
                            h += SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + BOTTOM_PAD + TOP_PAD;
                        }
                    }
                }
                else
                {
                    h = EditorGUIUtility.singleLineHeight;
                }
            }
            else
            {
                h = EditorGUIUtility.singleLineHeight;
            }
            return(h);
        }
Пример #4
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);
        property.serializedObject.Update();

        myClassObject = fieldInfo.GetValue(property.serializedObject.targetObject) as MyClass1;

        myInt        = property.FindPropertyRelative("myInt");
        myClass2List = property.FindPropertyRelative("MyClass2List");

        height = 0;
        yPos   = position.y;

        position.height     = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
        height             += position.height + EditorGUIUtility.standardVerticalSpacing;;
        yPos               += position.height + EditorGUIUtility.standardVerticalSpacing;;
        property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, new GUIContent("Element"));

        if (property.isExpanded)
        {
            subPropsRect        = new Rect(position);
            subPropsRect.x     += indent;
            subPropsRect.width -= indent;

            intRect        = new Rect(subPropsRect);
            intRect.y      = yPos;
            intRect.height = EditorGUI.GetPropertyHeight(myInt);
            height        += intRect.height + EditorGUIUtility.standardVerticalSpacing * 2;
            yPos          += intRect.height + EditorGUIUtility.standardVerticalSpacing * 2;
            EditorGUI.PropertyField(intRect, myInt);

            list            = GetNestedReorderableList(myClass2List);
            listRect        = new Rect(subPropsRect);
            listRect.y      = yPos;
            listRect.height = list.GetHeight();
            height         += listRect.height + EditorGUIUtility.standardVerticalSpacing;
            list.DoList(listRect);
        }

        property.FindPropertyRelative("elementHeight").floatValue = height + EditorGUIUtility.standardVerticalSpacing;

        property.serializedObject.ApplyModifiedProperties();
        EditorGUI.EndProperty();
    }
Пример #5
0
            ////TODO: close with escape

            public override void OnGUI(Rect rect)
            {
                m_ScrollPosition = GUI.BeginScrollView(rect, m_ScrollPosition, rect);

                // Modifiers section.
                var modifierListRect = rect;

                modifierListRect.x     += kPaddingLeftRight;
                modifierListRect.y     += kPaddingTop;
                modifierListRect.width -= kPaddingLeftRight * 2;
                modifierListRect.height = m_ModifierListView.GetHeight();
                m_ModifierListView.DoList(modifierListRect);

                ////TODO: draw box around following section

                // Chaining toggle.
                var chainingToggleRect = modifierListRect;

                chainingToggleRect.y     += modifierListRect.height + 5;
                chainingToggleRect.height = kCombineToggleHeight;

                ////TODO: disable toggle if property is first in list (bit tricky to find out from the SerializedProperty)

                var currentCombineSetting = (m_Flags & InputBinding.Flags.ThisAndPreviousCombine) ==
                                            InputBinding.Flags.ThisAndPreviousCombine;
                var newCombineSetting = EditorGUI.ToggleLeft(chainingToggleRect, Contents.chain, currentCombineSetting);

                if (currentCombineSetting != newCombineSetting)
                {
                    if (newCombineSetting)
                    {
                        m_Flags |= InputBinding.Flags.ThisAndPreviousCombine;
                    }
                    else
                    {
                        m_Flags &= ~InputBinding.Flags.ThisAndPreviousCombine;
                    }

                    m_FlagsProperty.intValue = (int)m_Flags;
                    m_FlagsProperty.serializedObject.ApplyModifiedProperties();
                }

                GUI.EndScrollView();
            }
Пример #6
0
        public override void OnGUILayout(SerializedProperty property, GUIContent label)
        {
            if (property.isExpanded)
            {
                LayoutContainer(() => reorderableList.DoList(position), reorderableList.GetHeight());
                if (IsGUI)
                {
                    var newDataSP  = property.FindPropertyRelative("newData");
                    var newKeySP   = newDataSP.FindPropertyRelative("key");
                    var newValueSP = newDataSP.FindPropertyRelative("value");
                    var rect       = position;
                    rect.width = rect.width - 70F;
                    rect.yMin  = rect.yMax - 18F;
                    const float arrowWidth  = 20;
                    const float prefixWidth = 65F;

                    var keyWidth   = (rect.width - arrowWidth - prefixWidth) * 0.3F;
                    var valueWidth = rect.width - keyWidth - arrowWidth - prefixWidth;
                    EditorGUI.LabelField(
                        new Rect(rect.xMin, rect.yMin, prefixWidth, rect.height),
                        new GUIContent("New Data")
                        );
                    rect.xMin += prefixWidth;
                    EditorGUI.PropertyField(
                        new Rect(rect.xMin, rect.yMin, keyWidth, rect.height),
                        newKeySP, GUIContent.none
                        );
                    rect.xMin += keyWidth;
                    EditorGUI.PrefixLabel(
                        new Rect(rect.xMin, rect.yMin, arrowWidth, rect.height),
                        new GUIContent(ArrowText)
                        );
                    rect.xMin += arrowWidth;
                    EditorGUI.PropertyField(
                        new Rect(rect.xMin, rect.yMin, valueWidth, rect.height),
                        newValueSP, GUIContent.none
                        );
                }
            }
            else
            {
                BetterGUILayout.PropertyField(property, displayLabel);
            }
        }
 public override void OnGUILayout(SerializedProperty property, GUIContent label)
 {
     if (property.isExpanded)
     {
         LayoutContainer(() => reorderableList.DoList(position), reorderableList.GetHeight());
         if (IsGUI)
         {
             var newDataSP = property.FindPropertyRelative("newData");
             var rect      = position;
             rect.width -= 70F;
             rect.yMin   = rect.yMax - 18F;
             EditorGUI.PropertyField(rect, newDataSP);
         }
     }
     else
     {
         BetterGUILayout.PropertyField(property, displayLabel);
     }
 }
Пример #8
0
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        RestoreState(property);

        float height = 0f;

        if (m_ReorderableList != null)
        {
            if (!m_ReorderableList.serializedProperty.isExpanded)
            {
                return(EditorGUIUtility.singleLineHeight + VerticalSpacing + VerticalSpacing);
            }

            height  = m_ReorderableList.GetHeight();
            height += EditorGUIUtility.singleLineHeight;
        }

        return(height + VerticalSpacing);
    }
Пример #9
0
        /// <inheritdoc />
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float eventLineHeight = 0f;

            if (_displayValueChangedEvent && _isConstant)
            {
                int persistentArgumentsCount = 0;

                SerializedProperty persistentCalls =
                    property.FindPropertyRelative("OnConstantValueChanged._PersistentCalls");

                for (int i = 0, condition = persistentCalls.arraySize; i < condition; i++)
                {
                    SerializedProperty persistentCall = persistentCalls.GetArrayElementAtIndex(i);

                    SerializedProperty persistentArguments =
                        persistentCall.FindPropertyRelative("_PersistentArguments");

                    persistentArgumentsCount += persistentArguments.arraySize;
                }

                ReorderableList eventDrawer = new ReorderableList(property.serializedObject, persistentCalls)
                {
                    elementHeight =
                        EditorGUIUtility.singleLineHeight * 1.45f,
                    headerHeight = 0f
                };

                SerializedProperty events = property.FindPropertyRelative("OnConstantValueChanged");

                eventLineHeight = eventDrawer.GetHeight() -
                                  (events.isExpanded
                                       ? 0f
                                       : EditorGUIUtility.singleLineHeight * Mathf.Max(1, eventDrawer.count) *
                                   1.45f
                                  ) +
                                  (events.isExpanded
                                       ? EditorGUIUtility.singleLineHeight * 1.125f * persistentArgumentsCount
                                       : 0f);
            }

            return(base.GetPropertyHeight(property, label) + _lineHeight + eventLineHeight);
        }
Пример #10
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(3);
        if (repeatNames.Count > 0)
        {
            var oldFontStyle = EditorStyles.helpBox.fontStyle;
            EditorStyles.helpBox.fontStyle = FontStyle.Bold;
            EditorGUILayout.HelpBox(StringUtil.Contact("There are duplicate field names :\n", string.Join("\n", repeatNames)), MessageType.Error);
            EditorStyles.helpBox.fontStyle = oldFontStyle;
        }
        serializedObject.Update();
        var height = Mathf.Min(800, reorderableList.GetHeight());

        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(height));
        reorderableList.DoLayoutList();
        EditorGUILayout.EndScrollView();
        serializedObject.ApplyModifiedProperties();

        if (GUI.changed)
        {
            fieldNames.Clear();
            repeatNames.Clear();
            for (int i = 0; i < luaComponentsProperty.arraySize; i++)
            {
                var element      = reorderableList.serializedProperty.GetArrayElementAtIndex(i);
                var nameProperty = element.FindPropertyRelative("name");
                if (!string.IsNullOrEmpty(nameProperty.stringValue))
                {
                    if (fieldNames.Contains(nameProperty.stringValue))
                    {
                        if (!repeatNames.Contains(nameProperty.stringValue))
                        {
                            repeatNames.Add(nameProperty.stringValue);
                        }
                    }
                    else
                    {
                        fieldNames.Add(nameProperty.stringValue);
                    }
                }
            }
        }
    }
        protected override float GetHeight(GUIContent label)
        {
            if (Event.current.type == EventType.Layout)
            {
                ClearCache();
            }

            float height = 0f;

            if (_ConditionsList != null)
            {
                var oldIndentLevel = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;
                height = _ConditionsList.GetHeight();
                EditorGUI.indentLevel = oldIndentLevel;
            }

            return(height);
        }
Пример #12
0
 /// <summary>
 /// Draws the properties for the inventory subclass.
 /// </summary>
 protected override void DrawInventoryProperties()
 {
     if (Foldout("Default Loadout"))
     {
         EditorGUI.indentLevel++;
         if (m_DefaultLoadoutReordableList == null)
         {
             var itemListProperty = PropertyFromName("m_DefaultLoadout");
             m_DefaultLoadoutReordableList = new ReorderableList(serializedObject, itemListProperty, true, true, true, true);
             m_DefaultLoadoutReordableList.drawHeaderCallback  = OnDefaultLoadoutHeaderDraw;
             m_DefaultLoadoutReordableList.drawElementCallback = OnDefaultLoadoutElementDraw;
         }
         var listRect = GUILayoutUtility.GetRect(0, m_DefaultLoadoutReordableList.GetHeight());
         listRect.x    += EditorGUI.indentLevel * Shared.Editor.Inspectors.Utility.InspectorUtility.IndentWidth;
         listRect.xMax -= EditorGUI.indentLevel * Shared.Editor.Inspectors.Utility.InspectorUtility.IndentWidth;
         m_DefaultLoadoutReordableList.DoList(listRect);
         EditorGUI.indentLevel--;
     }
 }
Пример #13
0
    public override void Draw()
    {
        inPoint.Draw();
        outPoint.Draw();
        GUI.Box(rect, "", style);
        EditorGUI.LabelField(new Rect(rect.position + new Vector2(25, 15), new Vector2(size - 50, 20)), "Line Node");
        title = GUI.TextField(new Rect(rect.position + new Vector2(25, 35), new Vector2(size - 50, 20)), title);
        GUI.Label(new Rect(rect.position + new Vector2(25, 65), new Vector2(size - 50, 20)), "ID: " + ID);
        //NumOfLines = EditorGUI.DelayedIntField(new Rect(rect.position + new Vector2(25, 85), new Vector2(150, 20)), NumOfLines);
        CallNextNodeImmediately = EditorGUI.ToggleLeft(new Rect(rect.position + new Vector2(25, 85), new Vector2(size - 50, 20)), "Call Next Node Immediately", CallNextNodeImmediately);
        DenyPlayerInput         = EditorGUI.ToggleLeft(new Rect(rect.position + new Vector2(25, 110), new Vector2(size - 50, 20)), "Deny Player Input", DenyPlayerInput);
        //EditorGUI.PropertyField(new Rect(rect.position + new Vector2(25, 115), new Vector2(150, 20)), (SerializedProperty)Lines, true);
        size = EditorGUI.Slider(new Rect(rect.position + new Vector2(25, 125), new Vector2(300, 20)), size, 350, 1000);

        List.DoList(new Rect(rect.position + new Vector2(25, 150), new Vector2(size - 50, 20)));

        NumOfLines = Lines.Count;
        rect.size  = new Vector2(size, 165 + List.GetHeight());
    }
        /************************************************************************************************************************/

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            if (!property.isExpanded)
            {
                return(EditorGUIUtility.singleLineHeight);
            }
            else
            {
                if (!DrawerState.Current.TryBeginEvent(property))
                {
                    return(EditorGUIUtility.singleLineHeight);
                }

                CachePersistentCallList(property);
                DrawerState.Current.EndEvent();

                return(_CurrentCallList.GetHeight() - 1);
            }
        }
Пример #15
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float h;

            if (EditorHelper.AssertMultiObjectEditingNotSupportedHeight(property, label, out h))
            {
                return(h);
            }

            if (property.isArray)
            {
                this.StartOnGUI(property, label);
                if (_disallowFoldout || property.isExpanded)
                {
                    h = _lst.GetHeight();
                    if (_drawElementAtBottom && _lst.index >= 0 && _lst.index < property.arraySize)
                    {
                        var  pchild = property.GetArrayElementAtIndex(_lst.index);
                        bool cache  = pchild.isExpanded;
                        pchild.isExpanded = true;
                        if (_internalDrawer != null)
                        {
                            h += _internalDrawer.GetPropertyHeight(pchild, label) + BOTTOM_PAD;
                        }
                        else
                        {
                            h += SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + BOTTOM_PAD;
                        }
                        pchild.isExpanded = cache;
                    }
                }
                else
                {
                    h = EditorGUIUtility.singleLineHeight;
                }
            }
            else
            {
                h = EditorGUIUtility.singleLineHeight;
            }
            return(h);
        }
Пример #16
0
 /// <summary>
 /// Draws the inspector for the ItemIdentifier list.
 /// </summary>
 protected override void DrawItemIdentifierInspector()
 {
     if (Foldout("Item Definition Amounts"))
     {
         EditorGUI.indentLevel++;
         if (m_ReordableItemAmount == null)
         {
             var itemListProperty = PropertyFromName("m_ItemDefinitionAmounts");
             m_ReordableItemAmount = new ReorderableList(serializedObject, itemListProperty, true, true, true, true);
             m_ReordableItemAmount.drawHeaderCallback  = OnItemIdentifierAmountHeaderDraw;
             m_ReordableItemAmount.drawElementCallback = OnItemIdentifierAmountElementDraw;
             m_ReordableItemAmount.elementHeight       = c_SlotRowHeight;
         }
         var listRect = GUILayoutUtility.GetRect(0, m_ReordableItemAmount.GetHeight());
         listRect.x    += EditorGUI.indentLevel * InspectorUtility.IndentWidth;
         listRect.xMax -= EditorGUI.indentLevel * InspectorUtility.IndentWidth;
         m_ReordableItemAmount.DoList(listRect);
         EditorGUI.indentLevel--;
     }
 }
Пример #17
0
        public static void DrawList(ReorderableList list, EditorUtils editorUtils)
        {
            Rect maskRect;

            //if (listExpanded)
            //{
            maskRect = EditorGUILayout.GetControlRect(true, list.GetHeight());
            list.DoList(maskRect);
            //}
            //else
            //{
            //    int oldIndent = EditorGUI.indentLevel;
            //    EditorGUI.indentLevel = 1;
            //    listExpanded = EditorGUILayout.Foldout(listExpanded, PropertyCount("SpawnerAdded", (List<SpawnerPresetListEntry>)list.list, editorUtils), true);
            //    maskRect = GUILayoutUtility.GetLastRect();
            //    EditorGUI.indentLevel = oldIndent;
            //}

            //editorUtils.Panel("MaskBaking", DrawMaskBaking, false);
        }
Пример #18
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float h;

            if (EditorHelper.AssertMultiObjectEditingNotSupportedHeight(property, label, out h))
            {
                return(h);
            }

            if (property.isExpanded)
            {
                this.BeginProperty(property, label);
                h = _lst.GetHeight();
                this.EndProperty();
                return(h);
            }
            else
            {
                return(EditorGUIUtility.singleLineHeight);
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(skillNameProp);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                _skillInfoAsset.name = _skillInfoAsset.skillName.StringValue;
                var path = AssetDatabase.GetAssetPath(_skillInfoAsset);
                AssetDatabase.RenameAsset(path,
                                          _skillInfoAsset.skillName.StringValue);
                AssetDatabase.Refresh();
            }

            if (GUILayout.Button("清空触发器列表"))
            {
                triggerListProp.arraySize = 0;
            }
            var minHeight = Mathf.Min(triggerList.GetHeight(), 400);

            this.scrolPos = GUILayout.BeginScrollView(this.scrolPos, false, false, GUILayout.ExpandHeight(true), GUILayout.MaxHeight(minHeight));

            triggerList.DoLayoutList();
            GUILayout.EndScrollView();
            if (selectIndex != -1 && selectIndex < triggerList.serializedProperty.arraySize)
            {
                var prop   = triggerListProp.GetArrayElementAtIndex(selectIndex);
                var height = EditorGUI.GetPropertyHeight(prop);
                this.detailPos = GUILayout.BeginScrollView(this.detailPos, false, false, GUILayout.ExpandHeight(true), GUILayout.MaxHeight(height));

                var rect = GUILayoutUtility.GetRect(100, height,
                                                    GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                _skillInfoAsset.triggers[selectIndex].OnDrawMoreInfo(prop, rect);
                GUILayout.EndScrollView();
            }

            serializedObject.ApplyModifiedProperties();
        }
        protected virtual Rect DrawCollection(Rect position, SerializedProperty property, SerializedProperty collection, GUIContent label)
        {
            EditorGUI.BeginProperty(position, new GUIContent(collection.displayName), collection);
            {
                Rect foldoutPos = position;
                foldoutPos.height     = EditorGUIUtility.singleLineHeight;
                collection.isExpanded = EditorGUI.Foldout(foldoutPos, collection.isExpanded, label, true);

                position.y += EditorGUIUtility.singleLineHeight;

                DisplayState listState = ReorderableCollection.ListStates[GetFullPath(collection)];
                listState.Collection = collection;
                ReorderableList valuePairList = listState.List.List;
                valuePairList.serializedProperty = collection;
                if (collection.isExpanded && collection.isArray)
                {
                    valuePairList.DoList(position);
                    position.y += valuePairList.GetHeight();
                }
            }
            EditorGUI.EndProperty();
            return(position);
        }
Пример #21
0
        void DrawDeviceList()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.label);
            var requirementsLabelSize = EditorStyles.label.CalcSize(m_RequirementGUI);
            var deviceListRect        = GUILayoutUtility.GetRect(GetWindowSize().x - requirementsLabelSize.x - 20, m_DevicesReorderableList.GetHeight());

            m_DevicesReorderableList.DoList(deviceListRect);
            var requirementsHeight = DrawRequirementsCheckboxes();
            var listHeight         = m_DevicesReorderableList.GetHeight() + EditorGUIUtility.singleLineHeight * 3;

            if (Event.current.type == EventType.Repaint)
            {
                if (listHeight < requirementsHeight)
                {
                    m_ButtonsAndLabelsHeights += requirementsHeight;
                }
                else
                {
                    m_ButtonsAndLabelsHeights += listHeight;
                }
            }

            EditorGUILayout.EndHorizontal();
        }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            SerializedProperty onUPSerialized   = property.FindPropertyRelative("onUP");
            SerializedProperty onDOWNSerialized = property.FindPropertyRelative("onDOWN");
            SerializedProperty onHOLDSerialized = property.FindPropertyRelative("onHOLD");



            SerializedProperty elements;
            ReorderableList    list;

            elements = onUPSerialized.FindPropertyRelative("m_PersistentCalls.m_Calls");
            list     = new ReorderableList(onUPSerialized.serializedObject, elements, false, true, true, true);

            list.elementHeight           = 43f;                          //MAGIC NUMBER (see UnityEventDrawer onGUI and GetState)
            onUPSerializedPropertyHeight = list.GetHeight();



            elements           = onDOWNSerialized.FindPropertyRelative("m_PersistentCalls.m_Calls");
            list               = new ReorderableList(onDOWNSerialized.serializedObject, elements, false, true, true, true);
            list.elementHeight = 43f;

            onDOWNSerializedPropertyHeight = list.GetHeight();


            elements = onHOLDSerialized.FindPropertyRelative("m_PersistentCalls.m_Calls");
            list     = new ReorderableList(onHOLDSerialized.serializedObject, elements, false, true, true, true);

            list.elementHeight             = 43f;
            onHOLDSerializedPropertyHeight = list.GetHeight();


            return(onUPSerializedPropertyHeight + onDOWNSerializedPropertyHeight + onHOLDSerializedPropertyHeight
                   + 5 * 2f + 16f);                                            //offset + EnumPopup
        }
Пример #23
0
            /// <inheritdoc/>
            public override void OnGUI(Rect area, SerializedProperty property, GUIContent label)
            {
                _RootProperty = null;

                base.OnGUI(area, property, label);

                if (_RootProperty == null ||
                    !_RootProperty.isExpanded)
                {
                    return;
                }

                using (DrawerContext.Get(_RootProperty))
                {
                    if (Context.Transition == null)
                    {
                        return;
                    }

                    _CurrentChildList = GatherDetails(_RootProperty);

                    var indentLevel = EditorGUI.indentLevel;

                    area.yMin = area.yMax - _CurrentChildList.GetHeight();

                    EditorGUI.indentLevel++;
                    area = EditorGUI.IndentedRect(area);

                    EditorGUI.indentLevel = 0;
                    _CurrentChildList.DoList(area);

                    EditorGUI.indentLevel = indentLevel;

                    TryCollapseArrays();
                }
            }
Пример #24
0
        void DrawCustomPassReorderableList()
        {
            // Sanitize list:
            for (int i = 0; i < m_SerializedPassVolume.customPasses.arraySize; i++)
            {
                if (m_SerializedPassVolume.customPasses.GetArrayElementAtIndex(i) == null)
                {
                    m_SerializedPassVolume.customPasses.DeleteArrayElementAtIndex(i);
                    serializedObject.ApplyModifiedProperties();
                    i++;
                }
            }

            float customPassListHeight = m_CustomPassList.GetHeight();
            var   customPassRect       = EditorGUILayout.GetControlRect(false, customPassListHeight);

            EditorGUI.BeginProperty(customPassRect, GUIContent.none, m_SerializedPassVolume.customPasses);
            {
                EditorGUILayout.BeginVertical();
                m_CustomPassList.DoList(customPassRect);
                EditorGUILayout.EndVertical();
            }
            EditorGUI.EndProperty();
        }
Пример #25
0
        // ReSharper disable Unity.PerformanceAnalysis
        internal bool Display(ref Rect position)
        {
            var rect             = position;
            var listHeight       = reorderableList.GetHeight();
            var singleLineHeight = EditorGUIUtility.singleLineHeight;

            // Reserve space
            {
                rect.height = singleLineHeight + 10 + listHeight;
                GetRect(rect.width, rect.height);
                position.y += rect.height + 5;
            }

            // Background
            {
                rect.x      += 5;
                rect.width  -= 10;
                rect.height -= listHeight;
                DrawRect(rect, DarkGray);
            }

            // Transition Header
            {
                rect.x += 3;
                LabelField(rect, "To");
                rect.x += 20;
                LabelField(rect, SerializedTransition.ToState?.objectReferenceValue.name, boldLabel);
            }

            // Buttons
            {
                bool Button(Rect pos, string icon)
                {
                    return(GUI.Button(pos, IconContent(icon)));
                }

                var buttonRect = new Rect(rect.width - 25, rect.y + 5, 30, 18);
                //int i, l;
                {
                    /*var transitions = editor.GetTransitions(SerializedTransition.FromState.objectReferenceValue);
                     * l = transitions.Count - 1;
                     * i = transitions.FindIndex(t => t.Index == SerializedTransition.Index);*/
                }

                // Remove transition
                if (Button(buttonRect, "Toolbar Minus"))
                {
                    //editor.RemoveTransition(SerializedTransition);
                    return(true);
                }

                buttonRect.x -= 35;

                // Move transition down

                /*if (i < l)
                 * {
                 *  if (Button(buttonRect, "scrolldown"))
                 *  {
                 *      editor.ReorderTransition(SerializedTransition, false);
                 *      return true;
                 *  }
                 *
                 *  buttonRect.x -= 35;
                 * }*/

                // Move transition up

                /*if (i > 0)
                 * {
                 *  if (Button(buttonRect, "scrollup"))
                 *  {
                 *      editor.ReorderTransition(SerializedTransition, true);
                 *      return true;
                 *  }
                 *
                 *  buttonRect.x -= 35;
                 * }
                 *
                 * // State editor
                 * if (Button(buttonRect, "SceneViewTools"))
                 * {
                 *  editor.DisplayStateEditor(SerializedTransition.ToState.objectReferenceValue);
                 *  return true;
                 * }*/
            }
            rect.x      = position.x + 5;
            rect.y     += rect.height;
            rect.width  = position.width - 10;
            rect.height = listHeight;

            // Display conditions
            reorderableList.DoList(rect);
            return(false);
        }
Пример #26
0
        public override void OnGUI(string searchContext)
        {
            if (m_SettingsManager == null)
            {
                Initialize();
            }

            // This has to be called to sync all the changes between m_SettingsManager and m_SettingsManagerObject.
            if (m_SettingsManagerObject.targetObject != null)
            {
                m_SettingsManagerObject.Update();
            }

            var noHeightRect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.label, GUILayout.ExpandWidth(true), GUILayout.Height(0));
            var width        = noHeightRect.width;

            var totalRect = new Rect(k_Padding, 0f, width - k_Padding, Screen.height);

            // Draw the toolbar for Android/iOS.
            var toolBarRect  = new Rect(totalRect.x, totalRect.y, totalRect.width, k_ToolbarHeight);
            var toolbarIndex = GUI.Toolbar(toolBarRect, m_SettingsManager.ToolbarIndex, k_ToolbarStrings);

            if (toolbarIndex != m_SettingsManager.ToolbarIndex)
            {
                m_SettingsManager.ToolbarIndex = toolbarIndex;
                m_SettingsManager.SaveSettings();
            }

            var notificationSettingsRect = new Rect(totalRect.x, k_ToolbarHeight + 2, totalRect.width, totalRect.height - k_ToolbarHeight - k_Padding);

            // Draw the notification settings.
            int drawnSettingsCount = DrawNotificationSettings(notificationSettingsRect, m_SettingsManager.ToolbarIndex);

            if (drawnSettingsCount <= 0)
            {
                return;
            }

            float heightPlaceHolder = k_SlotSize;

            // Draw drawable resources list for Android.
            if (m_SettingsManager.ToolbarIndex == 0)
            {
                var iconListlabelRect = new Rect(notificationSettingsRect.x, notificationSettingsRect.y + 85, 180, k_LabelLineHeight);
                GUI.Label(iconListlabelRect, "Notification Icons", EditorStyles.label);

                // Draw the help message for setting the icons.
                float labelHeight;
                if (notificationSettingsRect.width > 510)
                {
                    labelHeight = k_LabelLineHeight * 4;
                }
                else if (notificationSettingsRect.width > 500)
                {
                    labelHeight = k_LabelLineHeight * 5;
                }
                else
                {
                    labelHeight = k_LabelLineHeight * 6;
                }
                var iconListMsgRect = new Rect(iconListlabelRect.x, iconListlabelRect.y + iconListlabelRect.height + k_VerticalSeparator, notificationSettingsRect.width, labelHeight);
                EditorGUI.SelectableLabel(iconListMsgRect, k_InfoStringAndroid, NotificationStyles.k_IconHelpMessageStyle);

                // Draw the reorderable list for the icon list.
                var iconListRect = new Rect(iconListMsgRect.x, iconListMsgRect.y + iconListMsgRect.height + k_VerticalSeparator, iconListMsgRect.width, notificationSettingsRect.height - 55f);
                m_ReorderableList.DoList(iconListRect);

                heightPlaceHolder += iconListMsgRect.height + m_ReorderableList.GetHeight();
            }

            // We have to do this to occupy the space that ScrollView can set the scrollbars correctly.
            EditorGUILayout.GetControlRect(true, heightPlaceHolder, GUILayout.MinWidth(width));
        }
Пример #27
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            ReorderableList list = GetList(property, attribute as ReorderableAttribute, ARRAY_PROPERTY_NAME);

            return(list != null?list.GetHeight() : EditorGUIUtility.singleLineHeight);
        }
Пример #28
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            Init(property);

            return(m_ReorderableList.GetHeight());
        }
        public void OnSceneGUI()
        {
            serializedObject.Update();

            Handles.BeginGUI();
            // clamp index to valid value
            m_selectedIndexProp.intValue  = Mathf.Clamp(m_selectedIndexProp.intValue, -1, m_target.Tilemaps.Count - 1);
            m_sceneViewTilemapRList.index = m_selectedIndexProp.intValue;
            GUI.color = new Color(.75f, .75f, 0.8f, 0.85f);
            float hOff = m_displayTilemapRList.boolValue? 40f : 20f;

            m_sceneViewTilemapRList.DoList(new Rect(Screen.width - 300f - 10f, Screen.height - m_sceneViewTilemapRList.GetHeight() - hOff, 300f, 1f));
            GUI.color = Color.white;
            Handles.EndGUI();

            TilemapEditor tilemapEditor = GetTilemapEditor();

            if (tilemapEditor)
            {
                (tilemapEditor as TilemapEditor).OnSceneGUI();
            }

            DoKeyboardChecks();
            serializedObject.ApplyModifiedProperties();
        }
Пример #30
0
 /// <summary>
 /// Overrides the rendered height of the property drawer
 /// </summary>
 /// <param name="property">Reference to SerializedProperty in question</param>
 /// <param name="label">Reference to GUIContent</param>
 /// <returns>Rendered height of the property drawer</returns>
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     return(m_ReorderableList == null?base.GetPropertyHeight(property, label) : m_ReorderableList.GetHeight());
 }