OnInspectorGUI() публичный Метод

Implement this function to make a custom inspector.

public OnInspectorGUI ( ) : void
Результат void
Пример #1
0
            public override void OnGUI(Rect rect)
            {
                rect.height = EditorGUIUtility.singleLineHeight;
                rect.y     += rect.height * 2;
                EditorGUI.BeginChangeCheck();

                switch (assignmentType.enumValueIndex)
                {
                case 0:                         // constant (we're not actually showing this right now)
                    _editor.OnInspectorGUI();
                    break;

                case 1:                         // global
                    EditorGUIUtility.labelWidth = 100;
                    _editor.OnInspectorGUI();

                    EditorGUIUtility.labelWidth = 0;
                    break;

                case 2:                         // instanced
                    if (_noReference)
                    {
                        GUILayout.Label("Not Intitialized / Lists not supported yet");
                    }
                    else
                    {
                        EditorGUIUtility.labelWidth = 100;
                        _editor.OnInspectorGUI();
                        EditorGUIUtility.labelWidth = 0;
                    }
                    break;
                }
            }
Пример #2
0
        public override void OnInspectorGUI()
        {
            // Note: Show Reset PSR buttons.
            EditorGUILayout.LabelField("Reset Local PSR", EditorStyles.boldLabel);
            if (GUILayout.Button("Reset All"))
            {
                ZeroAllLocal();
            }

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Reset Position"))
            {
                ZeroLocalPosition();
            }

            if (GUILayout.Button("Reset Rotation"))
            {
                ZeroLocalRotation();
            }

            if (GUILayout.Button("Reset Scale"))
            {
                ZeroLocalScale();
            }
            EditorGUILayout.EndHorizontal();

            // Note: Show default inspector.
            EditorGUILayout.LabelField("Local Space", EditorStyles.boldLabel);
            defaultEditor.OnInspectorGUI();

            // Note: Show World Space Transform information.
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("World Space", EditorStyles.boldLabel);

            GUI.enabled = false;
            Vector3 localPosition = transform.localPosition;

            transform.localPosition = transform.position;

            Quaternion localRotation = transform.localRotation;

            transform.localRotation = transform.rotation;

            Vector3 localScale = transform.localScale;

            transform.localScale = transform.lossyScale;

            defaultEditor.OnInspectorGUI();
            transform.localPosition = localPosition;
            transform.localRotation = localRotation;
            transform.localScale    = localScale;
            GUI.enabled             = true;
        }
        private void DrawEditor(SerializedProperty serializedProperty)
        {
            if (serializedProperty.objectReferenceValue != null)
            {
                if (m_editor == null || m_editor.target != serializedProperty.objectReferenceValue)
                {
                    m_editor = CreateEditor(serializedProperty.objectReferenceValue);
                }
            }
            else if (m_editor != null)
            {
                DestroyImmediate(m_editor);
            }

            if (m_editor != null)
            {
                serializedProperty.isExpanded = EditorGUILayout.InspectorTitlebar(serializedProperty.isExpanded, m_editor);

                if (serializedProperty.isExpanded)
                {
                    m_editor.OnInspectorGUI();
                }
            }
            else
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("Select config asset to display.", MessageType.Info);
            }
        }
        public void DrawFields(ExperienceProfile profile, string name)
        {
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label(name, GUILayout.Width(Screen.width * 0.2F));
            }
            EditorGUILayout.EndHorizontal();

            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);

            var tmpEditor = UnityEditor.Editor.CreateEditor(profile);

            if (_currentConfigEditor != null)
            {
                Object.DestroyImmediate(_currentConfigEditor);
            }

            _currentConfigEditor = tmpEditor;

            if (_currentConfigEditor != null && _limappConfig != null)
            {
                _currentConfigEditor.OnInspectorGUI();
            }

            EditorGUILayout.EndScrollView();
        }
        private void OnGUI()
        {
            bigScroll = EditorGUILayout.BeginScrollView(bigScroll);
            if (!editor)
            {
                editor = UnityEditor.Editor.CreateEditor(this);
            }
            else
            {
                editor.OnInspectorGUI();
            }

            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("By pressing the button, we will try to migrate" +
                                    " Access -> Clearance from the list of occupations", MessageType.Info);

            if (GUILayout.Button("Migrate!"))
            {
                MigrateOccupationsInFolder();
            }

            EditorGUILayout.Space();
            EditorGUILayout.TextArea(log);
            EditorGUILayout.Space();
            EditorGUILayout.EndScrollView();
        }
        public override void OnInspectorGUI()
        {
            m_Transform = target as Transform;
            if (m_Transform == null)
            {
                return;
            }
            m_Editor.OnInspectorGUI();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("顺时针"))
            {
                Undo.RecordObject(m_Transform, "f**k");
                m_Transform.Rotate2D(-90);
            }
            if (GUILayout.Button("逆时针"))
            {
                Undo.RecordObject(m_Transform, "f**k");
                m_Transform.Rotate2D(90);
            }

            if (GUILayout.Button("清空子"))
            {
                GameObject[] tmp = new GameObject[m_Transform.childCount];
                for (int i = 0; i < m_Transform.childCount; i++)
                {
                    tmp[i] = m_Transform.GetChild(i).gameObject;
                }

                foreach (var gameObject in tmp)
                {
                    Undo.DestroyObjectImmediate(gameObject);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        /// <summary>
        /// Renders a non-editable object field and an editable dropdown of a profile.
        /// </summary>
        /// <param name="property"></param>
        /// <returns></returns>
        public static void RenderReadOnlyProfile(SerializedProperty property)
        {
            EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ObjectField(property.objectReferenceValue != null ? "" : property.displayName, property.objectReferenceValue, typeof(BaseMixedRealityProfile), false, GUILayout.ExpandWidth(true));
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndHorizontal();

            if (property.objectReferenceValue != null)
            {
                UnityEditor.Editor subProfileEditor = UnityEditor.Editor.CreateEditor(property.objectReferenceValue);

                // If this is a default MRTK configuration profile, ask it to render as a sub-profile
                if (typeof(BaseMixedRealityToolkitConfigurationProfileInspector).IsAssignableFrom(subProfileEditor.GetType()))
                {
                    BaseMixedRealityToolkitConfigurationProfileInspector configProfile = (BaseMixedRealityToolkitConfigurationProfileInspector)subProfileEditor;
                    configProfile.RenderAsSubProfile = true;
                }

                EditorGUILayout.BeginHorizontal();
                EditorGUI.indentLevel++;
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                subProfileEditor.OnInspectorGUI();
                EditorGUILayout.Space();
                EditorGUILayout.EndVertical();
                EditorGUI.indentLevel--;
                EditorGUILayout.EndHorizontal();
            }
        }
Пример #8
0
 public override void OnInspectorGUI()
 {
     if (_baseEditor)
     {
         _baseEditor.OnInspectorGUI();
     }
 }
Пример #9
0
    public override void OnInspectorGUI()
    {
        using (new EditorGUILayout.HorizontalScope())
        {
            using (new EditorGUI.IndentLevelScope(1))
            {
                using (new EditorGUILayout.VerticalScope())
                {
                    m_InspectorInstance?.OnInspectorGUI();

                    var indentPerLevel   = 15F;
                    var lastRect         = GUILayoutUtility.GetLastRect();
                    var singleLineHeight = EditorGUIUtility.singleLineHeight;

                    lastRect = DrawButton(lastRect, EditorGUI.indentLevel * indentPerLevel, 0, singleLineHeight, "S", x => x.localScale = Vector3.one);
                    lastRect = DrawButton(lastRect, EditorGUI.indentLevel * indentPerLevel, singleLineHeight + 2, singleLineHeight, "R", x => x.localEulerAngles = Vector3.zero);
                    lastRect = DrawButton(lastRect, EditorGUI.indentLevel * indentPerLevel, singleLineHeight + 10, singleLineHeight, "P", x => x.pivot = Vector3.one * 0.5F);

                    var showLayoutOptions = (bool)(s_ShowLayoutOptionsField?.GetValue(m_InspectorInstance) ?? false);
                    if (showLayoutOptions)
                    {
                        lastRect = DrawButton(lastRect, (EditorGUI.indentLevel + 1) * indentPerLevel, singleLineHeight + 4, singleLineHeight, "a", x => x.anchorMax = Vector3.one * 0.5F);
                        lastRect = DrawButton(lastRect, (EditorGUI.indentLevel + 1) * indentPerLevel, singleLineHeight + 2, singleLineHeight, "i", x => x.anchorMin = Vector3.one * 0.5F);
                    }

                    lastRect = DrawButton(lastRect, EditorGUIUtility.labelWidth, singleLineHeight + 20, singleLineHeight, "S", x => x.sizeDelta = new Vector2(100, 100));
                    lastRect = DrawButton(lastRect, EditorGUIUtility.labelWidth, singleLineHeight + 18, singleLineHeight, "P", x => x.anchoredPosition3D = Vector3.zero);
                }
            }
        }
    }
Пример #10
0
        private void OnScriptableObjectEditorGUI(SerializedProperty property)
        {
            UnityEditor.Editor editor = GetEditor(property.objectReferenceValue);

            if (m_Path == null)
            {
                m_Path     = AssetDatabase.GetAssetPath(property.objectReferenceValue);
                m_FileName = Path.GetFileNameWithoutExtension(m_Path);
            }

            Asset assetFile;
            bool  canEdit = CanEdit(m_Path, out assetFile);

            GUILayout.BeginHorizontal(Toolbar);

            GUI.enabled = canEdit;
            GUILayout.Label(m_FileName + " Inspector", ToolbarLabel, GUILayout.ExpandWidth(true));
            GUI.enabled = true;

            if (Provider.enabled && !canEdit && GUILayout.Button("Check Out", BoldToolbarButton, GUILayout.ExpandWidth(false)))
            {
                Provider.Checkout(assetFile, CheckoutMode.Both);
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginVertical(SubEditorBox);
            using (new EditorGUI.DisabledGroupScope(Provider.enabled && !canEdit)) {
                editor.OnInspectorGUI();
            }

            GUILayout.EndVertical();
        }
        public static SettingsProvider CreateMyCustomSettingsProvider()
        {
            var settingsScriptable = SplineMeshConfiguration.Instance;

            if (cachedEditor == null)
            {
                UnityEditor.Editor.CreateCachedEditor(settingsScriptable, null, ref cachedEditor);
            }

            var provider = new SettingsProvider(SettingsPath, SettingsScope.Project)
            {
                label      = SettingsLabel,
                guiHandler = (searchContext) =>
                {
                    var prevLabelWidth = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 250;
                    EditorGUI.indentLevel++;
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    EditorGUILayout.Space(10);
                    cachedEditor.OnInspectorGUI();
                    EditorGUILayout.Space(10);
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.Space(20);
                    EditorGUI.indentLevel--;
                    EditorGUIUtility.labelWidth = prevLabelWidth;
                },

                // Populate the search keywords to enable smart search filtering and label highlighting:
                keywords = new HashSet <string>(new[] { "Spline", "Editor", "Bezier", "Curve", "Mesh", "Generator" })
            };

            return(provider);
        }
Пример #12
0
        protected override void DrawDetail(Quest item, int index)
        {
            EditorGUIUtility.labelWidth = Devdog.General.Editors.EditorStyles.labelWidth;

            Devdog.General.Editors.EditorUtility.ErrorIfEmpty(EditorPrefs.GetString(SettingsEditor.PrefabSaveKey) == string.Empty, QuestSystemPro.ProductName + " prefab folder is not set, items cannot be saved! Please go to settings and define the " + QuestSystemPro.ProductName + " prefab folder.");
            if (EditorPrefs.GetString(SettingsEditor.PrefabSaveKey) == string.Empty)
            {
                canCreateItems = false;
                return;
            }
            canCreateItems = true;

            if (_editor != null)
            {
                _editor.OnInspectorGUI();
            }

            if (_previouslySelectedGUIItemName == "Quest_Name" && GUI.GetNameOfFocusedControl() != _previouslySelectedGUIItemName)
            {
                UpdateAssetName(item);
            }

            _previouslySelectedGUIItemName = GUI.GetNameOfFocusedControl();
            EditorGUIUtility.labelWidth    = 0;
        }
        public override void OnInspectorGUI()
        {
            if (isRootCanvas && canvas != null)
            {
                ShowMRTKButton();

                List <Graphic> graphics = GetGraphicsWhichRequireScaleMeshEffect(targets);

                if (graphics.Count != 0)
                {
                    EditorGUILayout.HelpBox($"Canvas contains {graphics.Count} {typeof(Graphic).Name}(s) which require a {typeof(ScaleMeshEffect).Name} to work with the {StandardShaderUtility.MrtkStandardShaderName} shader.", MessageType.Warning);
                    if (GUILayout.Button($"Add {typeof(ScaleMeshEffect).Name}(s)"))
                    {
                        foreach (var graphic in graphics)
                        {
                            Undo.AddComponent <ScaleMeshEffect>(graphic.gameObject);
                        }
                    }
                }

                EditorGUILayout.Space();
            }

            if (internalEditor != null)
            {
                internalEditor.OnInspectorGUI();
            }
        }
Пример #14
0
        // padding

        private void OnGUI()
        {
            // Try to create the editor object if it hasn't been initialized.
            if (editor == null)
            {
                editor = UnityEditor.Editor.CreateEditor(EM_Settings.Instance);
            }

            // If it's still null.
            if (editor == null)
            {
                EditorGUILayout.HelpBox("Coundn't create the settings resources editor.", MessageType.Error);
                return;
            }

            EM_SettingsEditor.callFromEditorWindow = true;
            EM_SettingsEditor.width  = position.width;
            EM_SettingsEditor.height = position.height;

            editor.DrawHeader();

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            EditorGUILayout.BeginVertical(new GUIStyle()
            {
                padding = new RectOffset(left, right, top, bottom)
            });

            editor.OnInspectorGUI();

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();

            EM_SettingsEditor.callFromEditorWindow = false;
        }
Пример #15
0
        void DrawBacktraceConfigSections()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(BacktraceIntegrationWindowLabels.LABEL_INTEGRATION_CONFIGSECTION_HEADER, BTEditorUtility.HeaderTextStyle);
            GUILayout.FlexibleSpace();

            backtraceConfiguration = (BacktraceConfiguration)EditorGUILayout
                                     .ObjectField(backtraceConfiguration, typeof(BacktraceConfiguration), false, new GUILayoutOption[]
            {
                GUILayout.MinWidth(position.width / 3)
            });

            EditorGUILayout.EndHorizontal();
            BTEditorUtility.DrawHorizontalUILine(Color.grey, 2, 1);
            if (backtraceConfiguration != null)
            {
                BTEditorUtility.DrawSubHeading("Settings for: " + backtraceConfiguration.name);

                if (backtraceConfigurationEditor == null)
                {
                    backtraceConfigurationEditor = UnityEditor.Editor.CreateEditor(backtraceConfiguration);
                }
                backtraceConfigurationEditor.OnInspectorGUI();
                backtraceConfigurationEditor.Repaint();
            }
            else
            {
                DrawConfigCreatorSection();
            }
        }
        public override void OnInspectorGUI()
        {
            //WTF...
            if (target == null)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();
            DrawDefaultInspector();

            if (m_condifEditor != null)
            {
                m_condifEditor.OnInspectorGUI();
            }
            else
            {
                EditorGUILayout.HelpBox("No test configuration assigned", MessageType.Warning);
            }


            if (EditorGUI.EndChangeCheck())
            {
                UpdateConfigEditor();
            }
        }
        /// <summary>
        /// Renders a non-editable object field and an editable dropdown of a profile.
        /// </summary>
        public static void RenderReadOnlyProfile(SerializedProperty property)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ObjectField(property.objectReferenceValue != null ? "" : property.displayName, property.objectReferenceValue, typeof(BaseMixedRealityProfile), false, GUILayout.ExpandWidth(true));
                EditorGUI.EndDisabledGroup();
            }

            if (property.objectReferenceValue != null)
            {
                bool showReadOnlyProfile = SessionState.GetBool(property.name + ".ReadOnlyProfile", false);

                using (new EditorGUI.IndentLevelScope())
                {
                    RenderFoldout(ref showReadOnlyProfile, property.displayName, () =>
                    {
                        using (new EditorGUI.IndentLevelScope())
                        {
                            UnityEditor.Editor subProfileEditor = CreateEditor(property.objectReferenceValue);
                            // If this is a default MRTK configuration profile, ask it to render as a sub-profile
                            if (typeof(BaseMixedRealityToolkitConfigurationProfileInspector).IsAssignableFrom(subProfileEditor.GetType()))
                            {
                                BaseMixedRealityToolkitConfigurationProfileInspector configProfile = (BaseMixedRealityToolkitConfigurationProfileInspector)subProfileEditor;
                                configProfile.RenderAsSubProfile = true;
                            }
                            subProfileEditor.OnInspectorGUI();
                        }
                    });
                }

                SessionState.SetBool(property.name + ".ReadOnlyProfile", showReadOnlyProfile);
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            int newIndex = EditorGUILayout.Popup("Setting", index, subTypeDisplayedOptions);

            if (newIndex != index)
            {
                index = newIndex;
                Undo.DestroyObjectImmediate(setting.objectReferenceValue);
                setting.objectReferenceValue = CreateInstance(subTypes[index]);
                settingEditor = CreateEditor(setting.objectReferenceValue);

                //var undoGroup = Undo.GetCurrentGroupName();
                //UnityEngine.Debug.Log(Undo.GetCurrentGroupName());

                //Undo.RecordObject(settingEditor, undoGroup);
                //setting.objectReferenceValue = CreateInstance(subTypes[index]);

                //Undo.IncrementCurrentGroup();
                //settingEditor = CreateEditor(setting.objectReferenceValue);
                //Undo.RevertAllInCurrentGroup();

                //Undo.ClearUndo(settingEditor);
                //Undo.RegisterCreatedObjectUndo(settingEditor, undoGroup);
            }

            settingEditor.OnInspectorGUI();

            serializedObject.ApplyModifiedProperties();
        }
Пример #19
0
        void OnGUI()
        {
            GUI.enabled = !EditorApplication.isCompiling && !ModExporter.isExporting && !Application.isPlaying;

            exportSettingsEditor.OnInspectorGUI();

            GUILayout.FlexibleSpace();

            if (ExportSettings.WorkshopId != 0)
            {
                GUILayout.Space(5);
                GUILayout.Label("This item is on the Workshop!  To add screenshots and videos, visit the Workshop page and click the 'Add/Edit images & videos' button.", EditorStyles.helpBox);
                GUILayout.Space(5);
                if (GUILayout.Button("Visit Workshop", GUILayout.Height(30)) &&
                    EditorUtility.DisplayDialog("Open Browser", "This will open your browser to visit the Workshop page.  Are you sure?", "Yes", "Cancel"))
                {
                    Application.OpenURL(ExportSettings.WorkshopUrl);
                }
            }

            if (GUILayout.Button("Export Mod", GUILayout.Height(30)) &&
                EditorUtility.DisplayDialog("Export Mod", "This will start the mod export process.  Are you sure?", "Yes", "Cancel"))
            {
                ModExporter.ExportMod();
            }
        }
Пример #20
0
        public static void AbstractPropertyDrawer(this SerializedProperty property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("Null Property");
            }

            if (property.propertyType == SerializedPropertyType.ObjectReference)
            {
                if (property.objectReferenceValue == null)
                {
                    EditorGUILayout.PropertyField(property);
                    return;
                }

                System.Type        concreteType = property.objectReferenceValue.GetType();
                UnityEngine.Object castedObject = (UnityEngine.Object)System.Convert.ChangeType(property.objectReferenceValue, concreteType);

                UnityEditor.Editor editor = UnityEditor.Editor.CreateEditor(castedObject);

                editor.OnInspectorGUI();
            }
            else
            {
                EditorGUILayout.PropertyField(property);
            }
        }
        public override void OnInspectorGUI()
        {
            MixedRealityToolkit instance = (MixedRealityToolkit)target;

            if (MixedRealityToolkit.Instance == null && instance.isActiveAndEnabled)
            {   // See if an active instance exists at all. If it doesn't register this instance preemptively.
                MixedRealityToolkit.SetActiveInstance(instance);
            }

            if (!instance.IsActiveInstance)
            {
                EditorGUILayout.HelpBox("This instance of the toolkit is inactive. There can only be one active instance loaded at any time.", MessageType.Warning);
                using (new EditorGUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Select Active Instance"))
                    {
                        Selection.activeGameObject = MixedRealityToolkit.Instance.gameObject;
                    }

                    if (GUILayout.Button("Make this the Active Instance"))
                    {
                        MixedRealityToolkit.SetActiveInstance(instance);
                    }
                }
                return;
            }

            serializedObject.Update();

            // If no profile is assigned, then warn user
            if (activeProfile.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("MixedRealityToolkit cannot initialize unless an Active Profile is assigned!", MessageType.Error);
            }

            bool changed = MixedRealityInspectorUtility.DrawProfileDropDownList(activeProfile, null, activeProfile.objectReferenceValue, typeof(MixedRealityToolkitConfigurationProfile), false, false) ||
                           cachedProfile != activeProfile.objectReferenceValue;

            serializedObject.ApplyModifiedProperties();

            if (changed)
            {
                MixedRealityToolkit.Instance.ResetConfiguration((MixedRealityToolkitConfigurationProfile)activeProfile.objectReferenceValue);
                activeProfileEditor = null;
                cachedProfile       = activeProfile.objectReferenceValue;
            }

            if (activeProfile.objectReferenceValue != null && activeProfileEditor == null)
            {
                // For the configuration profile, show the default inspector GUI
                activeProfileEditor = CreateEditor(activeProfile.objectReferenceValue);
            }

            if (activeProfileEditor != null)
            {
                activeProfileEditor.OnInspectorGUI();
            }
        }
Пример #22
0
 public void OnGUI()
 {
     if (editor != null)
     {
         editor.DrawHeader();
         editor.OnInspectorGUI();
         // editor.serializedObject.ApplyModifiedProperties();
     }
 }
Пример #23
0
        private void SettingsGUI()
        {
            if (!_settingsEditor)
            {
                UnityEditor.Editor.CreateCachedEditor(_settings, typeof(MPUIKitSettingsEditor), ref _settingsEditor);
            }

            _settingsEditor.OnInspectorGUI();
        }
Пример #24
0
        protected void DrawEditor(UnityEditor.Editor editor, string header, int headerSize = 12)
        {
            EditorGUILayout.Space();
            EditorGUILayout.InspectorTitlebar(false, editor.target, false);

            EditorGUI.indentLevel = 1;
            editor.OnInspectorGUI();
            EditorGUI.indentLevel = 0;
        }
Пример #25
0
        void OnGUI()
        {
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            modToolSettingsEditor.OnInspectorGUI();
            codeSettingsEditor.OnInspectorGUI();

            EditorGUILayout.EndScrollView();
        }
Пример #26
0
 // ReSharper disable once InconsistentNaming
 public void OnInspectorGUI()
 {
     if (_editor == null)
     {
         return;
     }
     GUILayout.Box(String.Empty, GUILayout.ExpandWidth(true), GUILayout.Height(1));
     _editor.OnInspectorGUI();
 }
Пример #27
0
        private void OnGUI()
        {
            if (_brushEditor == null)
            {
                return;
            }

            _brushEditor.OnInspectorGUI();
        }
Пример #28
0
        public override void OnInspectorGUI()
        {
            if (IsRootCanvas && j_Canvas != null)
            {
                ShowMRTKButton();

                List <Graphic> graphics = GetGraphicsWhichRequireScaleMeshEffect(targets);

                if (graphics.Count != 0)
                {
                    EditorGUILayout.HelpBox($"Canvas contains {graphics.Count} {typeof(Graphic).Name}(s) which require a {typeof(JMRScaleMeshEffect).Name} to work with the {JMRStandardShaderUtility.StandardShaderName} shader.", MessageType.Warning);
                    if (GUILayout.Button($"Add {typeof(JMRScaleMeshEffect).Name}(s)"))
                    {
                        foreach (var graphic in graphics)
                        {
                            Undo.AddComponent <JMRScaleMeshEffect>(graphic.gameObject);
                        }
                    }
                }

                EditorGUILayout.Space();

                if (!IsCanvasHasScene)
                {
                    return;
                }

                if (IsJMRToolkitConfigured)
                {
                    if (j_Canvas.worldCamera == null)
                    {
                        SetRaycastCameraToCanvas();
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox($"Input Manager not present in scene. Event camera needed in scene to work canvas properly", MessageType.Error);
                    if (j_Timer >= 0.5f)
                    {
                        if (!j_IPManager)
                        {
                            j_IPManager = FindObjectOfType <JMRInputManager>();
                        }

                        IsJMRToolkitConfigured = (j_IPManager != null) ? true : false;
                        j_Timer = 0;
                    }
                    j_Timer += Time.deltaTime;
                }
            }

            if (j_InternalEditor != null)
            {
                j_InternalEditor.OnInspectorGUI();
            }
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            InspectorUIUtility.DrawTitle("Profiles");

            if (profilesProperty.arraySize == 0)
            {
                AddProfile();
            }

            for (int i = 0; i < profilesProperty.arraySize; i++)
            {
                using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    SerializedProperty profile = profilesProperty.GetArrayElementAtIndex(i);

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        SerializedProperty targetGameObject = profile.FindPropertyRelative("Target");
                        EditorGUILayout.PropertyField(targetGameObject, new GUIContent("Target", "Target gameObject for this theme properties to manipulate"));

                        if (InspectorUIUtility.SmallButton(RemoveProfileContent))
                        {
                            profilesProperty.DeleteArrayElementAtIndex(i);
                            serializedObject.ApplyModifiedProperties();
                            continue;
                        }
                    }

                    SerializedProperty theme = profile.FindPropertyRelative("Theme");
                    EditorGUILayout.PropertyField(theme, new GUIContent("Theme", "Theme properties for interaction feedback"));

                    // Render Theme Settings
                    if (theme.objectReferenceValue != null)
                    {
                        InspectorUIUtility.ListSettings settings = listSettings[i];
                        settings.Show = InspectorUIUtility.DrawSectionFoldout("Theme Settings (Click to edit)", listSettings[i].Show);
                        if (settings.Show)
                        {
                            UnityEditor.Editor themeEditor = UnityEditor.Editor.CreateEditor(theme.objectReferenceValue);
                            themeEditor.OnInspectorGUI();
                        }

                        listSettings[i] = settings;
                    }
                }
            }// profile for loop

            if (InspectorUIUtility.RenderIndentedButton(AddProfileContent, EditorStyles.miniButton))
            {
                AddProfile();
            }

            serializedObject.ApplyModifiedProperties();
        }
Пример #30
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            EditorGUILayout.LabelField("Singletons", boldLabel);

            for (var i = 0; i < BaseSingleton.allSingletons.Count; ++i)
            {
                if (!m_Editors.ContainsKey(i))
                {
                    m_Editors.Add(i, null);
                }

                if (!m_Foldouts.ContainsKey(i))
                {
                    m_Foldouts.Add(i, true);
                }

                BaseSingleton singleton = BaseSingleton.allSingletons[i];

                m_Foldouts[i] = EditorGUILayout.InspectorTitlebar(m_Foldouts[i], singleton);

                if (!m_Foldouts[i])
                {
                    continue;
                }

                UnityEditor.Editor editor = m_Editors[i];
                CreateCachedEditor(singleton, null, ref editor);

                m_Editors[i] = editor;

                EditorGUI.indentLevel += 1;
                editor.OnInspectorGUI();

                EditorGUILayout.Space();

                if (AssetDatabase.Contains(singleton))
                {
                    EditorGUILayout.ObjectField(
                        "Reference",
                        singleton,
                        singleton.GetType(),
                        false
                        );
                }
                else
                {
                    EditorGUILayout.HelpBox("Runtime generated", MessageType.Info);
                }

                EditorGUI.indentLevel -= 1;
            }
        }
 private void DrawEditor(Editor editor, int editorIndex, bool rebuildOptimizedGUIBlock, ref bool showImportedObjectBarNext, ref Rect importedObjectBarRect)
 {
   if ((UnityEngine.Object) editor == (UnityEngine.Object) null)
     return;
   UnityEngine.Object target = editor.target;
   GUIUtility.GetControlID(target.GetInstanceID(), FocusType.Passive);
   EditorGUIUtility.ResetGUIState();
   GUILayoutGroup topLevel = GUILayoutUtility.current.topLevel;
   int visible = this.m_Tracker.GetVisible(editorIndex);
   bool flag1;
   if (visible == -1)
   {
     flag1 = InternalEditorUtility.GetIsInspectorExpanded(target);
     this.m_Tracker.SetVisible(editorIndex, !flag1 ? 0 : 1);
   }
   else
     flag1 = visible == 1;
   rebuildOptimizedGUIBlock |= editor.isInspectorDirty;
   if (Event.current.type == EventType.Repaint)
     editor.isInspectorDirty = false;
   ScriptAttributeUtility.propertyHandlerCache = editor.propertyHandlerCache;
   bool flag2 = AssetDatabase.IsMainAsset(target) || AssetDatabase.IsSubAsset(target) || editorIndex == 0 || target is Material;
   if (flag2)
   {
     string message = string.Empty;
     bool flag3 = editor.IsOpenForEdit(out message);
     if (showImportedObjectBarNext)
     {
       showImportedObjectBarNext = false;
       GUILayout.Space(15f);
       importedObjectBarRect = GUILayoutUtility.GetRect(16f, 16f);
       importedObjectBarRect.height = 17f;
     }
     flag1 = true;
     EditorGUI.BeginDisabledGroup(!flag3);
     editor.DrawHeader();
     EditorGUI.EndDisabledGroup();
   }
   if (editor.target is AssetImporter)
     showImportedObjectBarNext = true;
   bool flag4 = false;
   if (editor is GenericInspector && CustomEditorAttributes.FindCustomEditorType(target, false) != null && this.m_InspectorMode != InspectorMode.DebugInternal)
   {
     if (this.m_InspectorMode == InspectorMode.Normal)
       flag4 = true;
     else if (target is AssetImporter)
       flag4 = true;
   }
   if (!flag2)
   {
     EditorGUI.BeginDisabledGroup(!editor.IsEnabled());
     bool isExpanded = EditorGUILayout.InspectorTitlebar(flag1, editor.targets, editor.CanBeExpandedViaAFoldout());
     if (flag1 != isExpanded)
     {
       this.m_Tracker.SetVisible(editorIndex, !isExpanded ? 0 : 1);
       InternalEditorUtility.SetIsInspectorExpanded(target, isExpanded);
       if (isExpanded)
         this.m_LastInteractedEditor = editor;
       else if ((UnityEngine.Object) this.m_LastInteractedEditor == (UnityEngine.Object) editor)
         this.m_LastInteractedEditor = (Editor) null;
     }
     EditorGUI.EndDisabledGroup();
   }
   if (flag4 && flag1)
   {
     GUILayout.Label("Multi-object editing not supported.", EditorStyles.helpBox, new GUILayoutOption[0]);
   }
   else
   {
     EditorGUIUtility.ResetGUIState();
     EditorGUI.BeginDisabledGroup(!editor.IsEnabled());
     GenericInspector genericInspector = editor as GenericInspector;
     if ((bool) ((UnityEngine.Object) genericInspector))
       genericInspector.m_InspectorMode = this.m_InspectorMode;
     EditorGUIUtility.hierarchyMode = true;
     EditorGUIUtility.wideMode = (double) this.position.width > 330.0;
     ScriptAttributeUtility.propertyHandlerCache = editor.propertyHandlerCache;
     Rect rect = new Rect();
     OptimizedGUIBlock block;
     float height;
     if (editor.GetOptimizedGUIBlock(rebuildOptimizedGUIBlock, flag1, out block, out height))
     {
       rect = GUILayoutUtility.GetRect(0.0f, !flag1 ? 0.0f : height);
       this.HandleLastInteractedEditor(rect, editor);
       if (Event.current.type == EventType.Layout)
         return;
       if (block.Begin(rebuildOptimizedGUIBlock, rect) && flag1)
       {
         GUI.changed = false;
         editor.OnOptimizedInspectorGUI(rect);
       }
       block.End();
     }
     else
     {
       if (flag1)
       {
         rect = EditorGUILayout.BeginVertical(!editor.UseDefaultMargins() ? GUIStyle.none : EditorStyles.inspectorDefaultMargins, new GUILayoutOption[0]);
         this.HandleLastInteractedEditor(rect, editor);
         GUI.changed = false;
         try
         {
           editor.OnInspectorGUI();
         }
         catch (Exception ex)
         {
           if (ex is ExitGUIException)
             throw;
           else
             Debug.LogException(ex);
         }
         EditorGUILayout.EndVertical();
       }
       if (Event.current.type == EventType.Used)
         return;
     }
     EditorGUI.EndDisabledGroup();
     if (GUILayoutUtility.current.topLevel != topLevel)
     {
       if (!GUILayoutUtility.current.layoutGroups.Contains((object) topLevel))
       {
         Debug.LogError((object) "Expected top level layout group missing! Too many GUILayout.EndScrollView/EndVertical/EndHorizontal?");
         GUIUtility.ExitGUI();
       }
       else
       {
         Debug.LogWarning((object) "Unexpected top level layout group! Missing GUILayout.EndScrollView/EndVertical/EndHorizontal?");
         while (GUILayoutUtility.current.topLevel != topLevel)
           GUILayoutUtility.EndLayoutGroup();
       }
     }
     this.HandleComponentScreenshot(rect, editor);
   }
 }
Пример #32
0
		private void DrawEditor(Editor editor, int editorIndex, bool forceDirty, ref bool showImportedObjectBarNext, ref Rect importedObjectBarRect, bool eyeDropperDirty)
		{
			if (editor == null)
			{
				return;
			}
			UnityEngine.Object target = editor.target;
			GUIUtility.GetControlID(target.GetInstanceID(), FocusType.Passive);
			EditorGUIUtility.ResetGUIState();
			GUILayoutGroup topLevel = GUILayoutUtility.current.topLevel;
			int visible = this.m_Tracker.GetVisible(editorIndex);
			bool flag;
			if (visible == -1)
			{
				flag = InternalEditorUtility.GetIsInspectorExpanded(target);
				this.m_Tracker.SetVisible(editorIndex, (!flag) ? 0 : 1);
			}
			else
			{
				flag = (visible == 1);
			}
			bool flag2 = forceDirty || editor.isInspectorDirty || eyeDropperDirty || InspectorWindow.s_FlushOptimizedGUI;
			if (Event.current.type == EventType.Repaint)
			{
				editor.isInspectorDirty = false;
			}
			ScriptAttributeUtility.propertyHandlerCache = editor.propertyHandlerCache;
			bool flag3 = AssetDatabase.IsMainAsset(target) || AssetDatabase.IsSubAsset(target) || editorIndex == 0 || target is Material;
			if (flag3)
			{
				string empty = string.Empty;
				bool flag4 = editor.IsOpenForEdit(out empty);
				if (showImportedObjectBarNext)
				{
					showImportedObjectBarNext = false;
					GUILayout.Space(15f);
					importedObjectBarRect = GUILayoutUtility.GetRect(16f, 16f);
					importedObjectBarRect.height = 17f;
				}
				flag = true;
				EditorGUI.BeginDisabledGroup(!flag4);
				editor.DrawHeader();
				EditorGUI.EndDisabledGroup();
			}
			if (editor.target is AssetImporter)
			{
				showImportedObjectBarNext = true;
			}
			bool flag5 = false;
			if (editor is GenericInspector && CustomEditorAttributes.FindCustomEditorType(target, false) != null)
			{
				if (this.m_InspectorMode != InspectorMode.DebugInternal)
				{
					if (this.m_InspectorMode == InspectorMode.Normal)
					{
						flag5 = true;
					}
					else
					{
						if (target is AssetImporter)
						{
							flag5 = true;
						}
					}
				}
			}
			if (!flag3)
			{
				EditorGUI.BeginDisabledGroup(!editor.IsEnabled());
				bool flag6 = EditorGUILayout.InspectorTitlebar(flag, editor.targets);
				if (flag != flag6)
				{
					this.m_Tracker.SetVisible(editorIndex, (!flag6) ? 0 : 1);
					InternalEditorUtility.SetIsInspectorExpanded(target, flag6);
					if (flag6)
					{
						this.m_LastInteractedEditor = editor;
					}
					else
					{
						if (this.m_LastInteractedEditor == editor)
						{
							this.m_LastInteractedEditor = null;
						}
					}
				}
				EditorGUI.EndDisabledGroup();
			}
			if (flag5 && flag)
			{
				GUILayout.Label("Multi-object editing not supported.", EditorStyles.helpBox, new GUILayoutOption[0]);
				return;
			}
			EditorGUIUtility.ResetGUIState();
			EditorGUI.BeginDisabledGroup(!editor.IsEnabled());
			GenericInspector genericInspector = editor as GenericInspector;
			if (genericInspector)
			{
				genericInspector.m_InspectorMode = this.m_InspectorMode;
			}
			EditorGUIUtility.hierarchyMode = true;
			EditorGUIUtility.wideMode = (base.position.width > 330f);
			ScriptAttributeUtility.propertyHandlerCache = editor.propertyHandlerCache;
			Rect rect = default(Rect);
			OptimizedGUIBlock optimizedGUIBlock;
			float num;
			if (editor.GetOptimizedGUIBlock(flag2, flag, out optimizedGUIBlock, out num))
			{
				rect = GUILayoutUtility.GetRect(0f, (!flag) ? 0f : num);
				this.HandleLastInteractedEditor(rect, editor);
				if (Event.current.type == EventType.Layout)
				{
					return;
				}
				if (optimizedGUIBlock.Begin(flag2, rect) && flag)
				{
					GUI.changed = false;
					editor.OnOptimizedInspectorGUI(rect);
				}
				optimizedGUIBlock.End();
			}
			else
			{
				if (flag)
				{
					GUIStyle style = (!editor.UseDefaultMargins()) ? GUIStyle.none : EditorStyles.inspectorDefaultMargins;
					rect = EditorGUILayout.BeginVertical(style, new GUILayoutOption[0]);
					this.HandleLastInteractedEditor(rect, editor);
					GUI.changed = false;
					try
					{
						editor.OnInspectorGUI();
					}
					catch (Exception ex)
					{
						if (ex is ExitGUIException)
						{
							throw;
						}
						Debug.LogException(ex);
					}
					EditorGUILayout.EndVertical();
				}
				if (Event.current.type == EventType.Used)
				{
					return;
				}
			}
			EditorGUI.EndDisabledGroup();
			if (GUILayoutUtility.current.topLevel != topLevel)
			{
				if (!GUILayoutUtility.current.layoutGroups.Contains(topLevel))
				{
					Debug.LogError("Expected top level layout group missing! Too many GUILayout.EndScrollView/EndVertical/EndHorizontal?");
					GUIUtility.ExitGUI();
				}
				else
				{
					Debug.LogWarning("Unexpected top level layout group! Missing GUILayout.EndScrollView/EndVertical/EndHorizontal?");
					while (GUILayoutUtility.current.topLevel != topLevel)
					{
						GUILayoutUtility.EndLayoutGroup();
					}
				}
			}
			this.HandleComponentScreenshot(rect, editor);
		}