Exemple #1
0
 public override float GetHeight()
 {
     return(EditorStyles.helpBox.CalcSize(EditorHelper.TempContent(_message)).y);
 }
Exemple #2
0
 public static object DefaultPropertyField(string label, object value, System.Type valueType)
 {
     return(SPEditorGUI.DefaultPropertyField(EditorGUILayout.GetControlRect(true), EditorHelper.TempContent(label), value, valueType));
 }
Exemple #3
0
 public static bool PropertyField(SerializedObject obj, string prop, string label, bool includeChildren)
 {
     return(SPEditorGUILayout.PropertyField(obj, prop, EditorHelper.TempContent(label), includeChildren));
 }
Exemple #4
0
        public static Component SelectComponentField(string label, Component[] components, Component selectedComp)
        {
            var position = EditorGUILayout.GetControlRect(true);

            return(SPEditorGUI.SelectComponentField(position, EditorHelper.TempContent(label), components, selectedComp));
        }
Exemple #5
0
        public static Component SelectComponentFromSourceField(string label, GameObject source, Component selectedComp, System.Predicate <Component> filter = null)
        {
            var position = EditorGUILayout.GetControlRect(true);

            return(SPEditorGUI.SelectComponentFromSourceField(position, EditorHelper.TempContent(label), source, selectedComp, filter));
        }
Exemple #6
0
 public static System.Enum EnumPopupExcluding(string label, System.Enum enumValue, params System.Enum[] ignoredValues)
 {
     return(SPEditorGUI.EnumPopupExcluding(EditorGUILayout.GetControlRect(true), EditorHelper.TempContent(label), enumValue, ignoredValues));
 }
Exemple #7
0
        public sealed override void OnInspectorGUI()
        {
            if (!(this.target is SPComponent) && !SpacepuppySettings.UseSPEditorAsDefaultEditor)
            {
                base.OnInspectorGUI();
                return;
            }

            this.OnBeforeSPInspectorGUI();

            EditorGUI.BeginChangeCheck();

            //draw header infobox if needed
            this.DrawDefaultInspectorHeader();
            this.OnSPInspectorGUI();
            this.DrawDefaultInspectorFooters();

            if (EditorGUI.EndChangeCheck())
            {
                //do call onValidate
                PropertyHandlerValidationUtility.OnInspectorGUIComplete(this.serializedObject, true);
                this.OnValidate();

                if (SpacepuppySettings.SignalValidateReceiver)
                {
                    foreach (var obj in this.serializedObject.targetObjects)
                    {
                        var iterator = serializedObject.GetIterator();
                        while (iterator.Next(true))
                        {
                            if (iterator.propertyType == SerializedPropertyType.ObjectReference)
                            {
                                continue;
                            }

                            var validated = EditorHelper.GetTargetObjectOfProperty(iterator, obj) as IValidateReceiver;
                            validated?.OnValidate();
                        }
                    }
                }
            }
            else
            {
                PropertyHandlerValidationUtility.OnInspectorGUIComplete(this.serializedObject, false);
            }

            if (_shownFields != null && UnityEngine.Application.isPlaying)
            {
                GUILayout.Label("Runtime Values", EditorStyles.boldLabel);

                foreach (var info in _shownFields)
                {
                    var cache = SPGUI.DisableIf(info.Attrib.Readonly);

                    var value = DynamicUtil.GetValue(this.target, info.MemberInfo);
                    EditorGUI.BeginChangeCheck();
                    value = SPEditorGUILayout.DefaultPropertyField(info.Label, value, DynamicUtil.GetReturnType(info.MemberInfo));
                    if (EditorGUI.EndChangeCheck())
                    {
                        DynamicUtil.SetValue(this.target, info.MemberInfo, value);
                    }

                    cache.Reset();
                }
            }
        }
 public static System.Enum EnumPopup(string label, System.Enum enumValue)
 {
     return(SPEditorGUI.EnumPopup(EditorGUILayout.GetControlRect(true), EditorHelper.TempContent(label), enumValue));
 }