コード例 #1
0
        public float GetHeight(SerializedProperty property, GUIContent label, bool includeChildren)
        {
            if (label == null)
            {
                label = EditorHelper.TempContent(property.displayName);
            }

            if (!includeChildren || !property.hasVisibleChildren)
            {
                return(ScriptAttributeUtility.SharedNullInternalPropertyHandler.GetHeight(property, label, includeChildren));
                //return EditorGUI.GetPropertyHeight(property, label, includeChildren);
            }

            float h = EditorGUIUtility.singleLineHeight;

            if (property.isExpanded)
            {
                var iterator = property.Copy();
                var end      = property.GetEndProperty();
                for (bool enterChildren = true; iterator.Next(enterChildren); enterChildren = false)
                {
                    if (SerializedProperty.EqualContents(iterator, end))
                    {
                        break;
                    }

                    h += SPEditorGUI.GetPropertyHeight(iterator, EditorHelper.TempContent(iterator.displayName), iterator.hasVisibleChildren);
                }
            }

            return(h);
        }
コード例 #2
0
        private void BeginProperty(SerializedProperty property, GUIContent label)
        {
            var valuesProp = property.FindPropertyRelative(PROP_VALUES);

            _label = label;

            _lst               = CachedReorderableList.GetListDrawer(valuesProp, _lst_DrawHeader, _lst_DrawElement);
            _lst.displayAdd    = false;
            _lst.displayRemove = false;
            _lst.draggable     = false;

            if (valuesProp.arraySize > 0)
            {
                var el = valuesProp.GetArrayElementAtIndex(0);
                if (OverridePropertyDrawer != null)
                {
                    _lst.elementHeight = OverridePropertyDrawer.GetPropertyHeight(el, GUIContent.none);
                }
                else
                {
                    _lst.elementHeight = SPEditorGUI.GetPropertyHeight(el);
                }
            }
            else
            {
                _lst.elementHeight = EditorGUIUtility.singleLineHeight;
            }
        }
コード例 #3
0
        public bool OnGUI(Rect position, SerializedProperty property, GUIContent label, bool includeChildren)
        {
            if (label == null)
            {
                label = EditorHelper.TempContent(property.displayName);
            }

            if (!includeChildren || !property.hasVisibleChildren)
            {
                return(ScriptAttributeUtility.SharedNullInternalPropertyHandler.OnGUI(position, property, label, includeChildren));
                //return EditorGUI.PropertyField(position, property, label, includeChildren);
            }

            float h;
            Rect  r;

            EditorGUI.BeginChangeCheck();

            //draw header
            h                   = EditorGUIUtility.singleLineHeight;
            r                   = new Rect(position.xMin, position.yMin, position.width, h);
            position            = new Rect(r.xMin, r.yMax, r.width, position.height - h);
            property.isExpanded = EditorGUI.Foldout(r, property.isExpanded, label);

            //draw children
            if (property.isExpanded)
            {
                var iterator = property.Copy();
                var end      = property.GetEndProperty();
                for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
                {
                    if (SerializedProperty.EqualContents(iterator, end))
                    {
                        break;
                    }

                    h        = SPEditorGUI.GetPropertyHeight(iterator);
                    r        = new Rect(position.xMin, position.yMin, position.width, h);
                    position = new Rect(r.xMin, r.yMax, r.width, position.height - h);

                    SPEditorGUI.PropertyField(r, iterator, EditorHelper.TempContent(iterator.displayName), iterator.hasVisibleChildren);
                }
            }

            return(EditorGUI.EndChangeCheck());
        }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float h = EditorGUIUtility.singleLineHeight * 3f;

            var settingsProp = property.FindPropertyRelative(PROP_SETTINGS);

            if (settingsProp.isExpanded)
            {
                h += SPEditorGUI.GetPropertyHeight(settingsProp, EditorHelper.TempContent(settingsProp.displayName));
            }
            else
            {
                h += EditorGUIUtility.singleLineHeight;
            }

            return(h);
        }
コード例 #5
0
            public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
            {
                if (label == null)
                {
                    label = EditorHelper.TempContent(property.displayName);
                }

                if (!property.isArray)
                {
                    if (_drawer != null)
                    {
                        return(_drawer.GetPropertyHeight(property, label));
                    }
                    else
                    {
                        return(SPEditorGUI.GetDefaultPropertyHeight(property));
                    }
                }
                else
                {
                    float h = SPEditorGUI.GetSinglePropertyHeight(property, label);
                    if (!property.isExpanded)
                    {
                        return(h);
                    }

                    h += EditorGUIUtility.singleLineHeight + 2f;

                    for (int i = 0; i < property.arraySize; i++)
                    {
                        var pchild = property.GetArrayElementAtIndex(i);
                        if (_drawer != null)
                        {
                            h += _drawer.GetPropertyHeight(pchild, EditorHelper.TempContent(pchild.displayName)) + 2f;
                        }
                        else
                        {
                            h += SPEditorGUI.GetPropertyHeight(pchild, EditorHelper.TempContent(pchild.displayName)) + 2f;
                        }
                    }
                    return(h);
                }
            }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            if (property.serializedObject.targetObject is i_PlayRandomAnimation)
            {
                this.DrawFlat = true;

                var controller = property.serializedObject.FindProperty(i_PlayRandomAnimationInspector.PROP_TARGETANIMATOR).FindPropertyRelative(TriggerableTargetObjectPropertyDrawer.PROP_TARGET).objectReferenceValue;
                if (controller is Animation || controller is SPLegacyAnimController)
                {
                    float h = EditorGUIUtility.singleLineHeight * 6f;
                    var   propApplySetting = property.FindPropertyRelative(PROP_APPPLYSETTINGS);
                    if (propApplySetting.boolValue)
                    {
                        var propSettings = property.FindPropertyRelative(PROP_SETTINGS);
                        propSettings.isExpanded = true;
                        h += SPEditorGUI.GetPropertyHeight(propSettings, EditorHelper.TempContent(propSettings.displayName), true);
                    }
                    else
                    {
                        h += EditorGUIUtility.singleLineHeight;
                    }

                    return(h);
                }
                else if (controller is ISPAnimator)
                {
                    return(EditorGUIUtility.singleLineHeight * 2f);
                }
                else if (controller is ISPAnimationSource)
                {
                    float h = EditorGUIUtility.singleLineHeight * 5f;
                    if (!this.DrawFlat)
                    {
                        h += EditorGUIUtility.singleLineHeight;
                    }

                    var propApplySetting = property.FindPropertyRelative(PROP_APPPLYSETTINGS);
                    if (propApplySetting.boolValue)
                    {
                        var propSettings = property.FindPropertyRelative(PROP_SETTINGS);
                        propSettings.isExpanded = true;
                        h += SPEditorGUI.GetPropertyHeight(propSettings, EditorHelper.TempContent(propSettings.displayName), true);
                    }
                    else
                    {
                        h += EditorGUIUtility.singleLineHeight;
                    }

                    return(h);
                }
                else
                {
                    return(EditorGUIUtility.singleLineHeight);
                }
            }
            else
            {
                if (!this.DrawFlat && !property.isExpanded)
                {
                    return(EditorGUIUtility.singleLineHeight);
                }

                float h = EditorGUIUtility.singleLineHeight * 6f;
                if (!this.DrawFlat)
                {
                    h += EditorGUIUtility.singleLineHeight;
                }

                var propApplySetting = property.FindPropertyRelative(PROP_APPPLYSETTINGS);
                if (propApplySetting.boolValue)
                {
                    var propSettings = property.FindPropertyRelative(PROP_SETTINGS);
                    propSettings.isExpanded = true;
                    h += SPEditorGUI.GetPropertyHeight(propSettings, EditorHelper.TempContent(propSettings.displayName), true);
                }
                else
                {
                    h += EditorGUIUtility.singleLineHeight;
                }

                return(h);
            }
        }
コード例 #7
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            var signalSourceProp = property.FindPropertyRelative("_signalSource");

            return(SPEditorGUI.GetPropertyHeight(signalSourceProp, label, false));
        }