Beispiel #1
0
        public sealed override void OnInspectorGUI()
        {
            if (!(this.target is SPComponent) && !EditorProjectPrefs.Local.GetBool(BaseSettings.SETTING_SPEDITOR_ISDEFAULT_ACTIVE, true))
            {
                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();
            }
            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 = info.FieldInfo.GetValue(this.target);
                    EditorGUI.BeginChangeCheck();
                    value = SPEditorGUILayout.DefaultPropertyField(info.Label, value, info.FieldInfo.FieldType);
                    if (EditorGUI.EndChangeCheck())
                    {
                        info.FieldInfo.SetValue(this.target, value);
                    }

                    cache.Reset();
                }
            }
        }
        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();
            }
            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();
                }
            }
        }