コード例 #1
0
        public static void Draw(Rect position, SerializedObject serializedObject, bool indent, List <float> propertyHeights = null)
        {
            if (Event.current.type == EventType.Layout)
            {
                return;
            }

            var rect        = new Rect(position);
            int indentLevel = EditorGUI.indentLevel;

            int index = 0;

            serializedObject.Update();
            var  iterator = serializedObject.GetIterator();
            bool enter    = true;

            InGroupAttribute.Push();
            while (iterator.NextVisible(enter))
            {
                enter = false;
                if (iterator.propertyPath.Equals("m_Script"))
                {
                    continue;
                }
                EditorGUI.indentLevel = indentLevel + (indent ? 1 : 0);
                if (propertyHeights != null)
                {
                    rect.height = propertyHeights[index];
                }
                else
                {
                    rect.height = EditorGUI.GetPropertyHeight(iterator, null, true);
                }
                if (rect.height > 0)
                {
                    EditorGUI.PropertyField(rect, iterator, null, true);
                    rect = rect.MoveDown(2);
                }
                index++;
            }
            InGroupAttribute.Pop();
            serializedObject.ApplyModifiedProperties();

            EditorGUI.indentLevel = indentLevel;
        }
コード例 #2
0
        public static float GetHeight(SerializedObject serializedObject, List <float> propertyHeights = null)
        {
            float result = 0;

            if (propertyHeights != null)
            {
                propertyHeights.Clear();
            }
            serializedObject.Update();
            var  iterator = serializedObject.GetIterator();
            bool enter    = true;

            InGroupAttribute.Push();
            while (iterator.NextVisible(enter))
            {
                enter = false;
                if (iterator.propertyPath.Equals("m_Script"))
                {
                    continue;
                }
                var h = EditorGUI.GetPropertyHeight(iterator, null, true);
                if (h < 0)
                {
                    h = 0;
                }
                if (propertyHeights != null)
                {
                    propertyHeights.Add(h);
                }
                if (result > 0 && h > 0)
                {
                    result += 2;
                }
                result += h;
            }
            InGroupAttribute.Pop();
            return(Mathf.Max(0, result));
        }
コード例 #3
0
        public static void Draw(SerializedObject serializedObject, bool indent)
        {
            int indentLevel = EditorGUI.indentLevel;

            serializedObject.Update();
            var  iterator = serializedObject.GetIterator();
            bool enter    = true;

            InGroupAttribute.Push();
            while (iterator.NextVisible(enter))
            {
                enter = false;
                if (iterator.propertyPath.Equals("m_Script"))
                {
                    continue;
                }
                iterator.GetFieldInfos(s_FieldInfos);
                if (s_FieldInfos[s_FieldInfos.Count - 1].GetCustomAttributes(typeof(InGroupAttribute), false).Any())
                {
                    continue;
                }
                EditorGUI.indentLevel = indentLevel + (indent ? 1 : 0);
                var h = EditorGUI.GetPropertyHeight(iterator, null, true);
                if (h > 0)
                {
                    var rect = EditorGUILayout.GetControlRect(true, h);
                    if (Event.current.type != EventType.Layout)
                    {
                        EditorGUI.PropertyField(rect, iterator, null, true);
                    }
                }
            }
            InGroupAttribute.Pop();
            serializedObject.ApplyModifiedProperties();

            EditorGUI.indentLevel = indentLevel;
        }