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

Call this function to draw the header of the editor.

public DrawHeader ( ) : void
Результат void
Пример #1
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;
        }
Пример #2
0
 public void OnGUI()
 {
     if (editor != null)
     {
         editor.DrawHeader();
         editor.OnInspectorGUI();
         // editor.serializedObject.ApplyModifiedProperties();
     }
 }
            float DrawEditor(Rect rect, Editor editor, bool disabled, EditorGUIUtility.ComparisonViewMode comparisonViewMode)
            {
                rect.xMin += 1;
                EditorGUIUtility.ResetGUIState();

                EditorGUIUtility.wideMode           = true;
                EditorGUIUtility.labelWidth         = 120;
                EditorGUIUtility.comparisonViewMode = comparisonViewMode;
                EditorGUIUtility.leftMarginCoord    = rect.x;

                GUILayout.BeginArea(rect);
                Rect editorRect = EditorGUILayout.BeginVertical();

                {
                    using (new EditorGUI.DisabledScope(disabled))
                    {
                        if (editor == null)
                        {
                            GUI.enabled = true;
                            GUILayout.Label("None - this should not happen.", Styles.centeredLabelStyle);
                        }
                        else
                        {
                            EditorGUI.BeginChangeCheck();
                            if (editor.target is GameObject)
                            {
                                editor.DrawHeader();
                            }
                            else
                            {
                                EditorGUIUtility.hierarchyMode = true;
                                EditorGUILayout.InspectorTitlebar(true, editor);
                                EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);
                                editor.OnInspectorGUI();
                                EditorGUILayout.Space();
                                EditorGUILayout.EndVertical();
                            }

                            if (EditorGUI.EndChangeCheck())
                            {
                                m_OwnerNeedsRefresh = true;
                            }
                        }
                    }
                }

                EditorGUILayout.EndVertical();
                GUILayout.EndArea();

                // Overdraw border by one pixel in all directions.
                GUI.Label(new Rect(rect.x - 1, -1, rect.width + 2, m_PreviewSize.y + 2), GUIContent.none, Styles.borderStyle);

                return(editorRect.height);
            }
Пример #4
0
        public override void OnInspectorGUI()
        {
            if (this.m_SubstanceStyles == null)
            {
                this.m_SubstanceStyles = new SubstanceImporterInspector.SubstanceStyles();
            }
            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(new GUILayoutOption[0]);
            this.MaterialListing();
            this.MaterialManagement();
            EditorGUILayout.EndVertical();
            Editor selectedMaterialInspector = this.GetSelectedMaterialInspector();

            if (selectedMaterialInspector)
            {
                selectedMaterialInspector.DrawHeader();
                selectedMaterialInspector.OnInspectorGUI();
            }
        }
Пример #5
0
        private void OnGUI()
        {
            if (referenceObject == null)
            {
                DestroyEditor();
                return;
            }


            if (editor == null)
            {
                CreateEdtiorForRefObject();
            }

            scrollVec = EditorGUILayout.BeginScrollView(scrollVec);
            editor.DrawHeader();
            editor.OnInspectorGUI();
            EditorGUILayout.EndScrollView();
            EditorGUILayout.Space();
        }
        public override void OnInspectorGUI()
        {
            if (this.m_SubstanceStyles == null)
            {
                this.m_SubstanceStyles = new SubstanceImporterInspector.SubstanceStyles();
            }
            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical();
            this.MaterialListing();
            this.MaterialManagement();
            EditorGUILayout.EndVertical();
            Editor materialInspector = this.GetSelectedMaterialInspector();

            if (!(bool)((UnityEngine.Object)materialInspector))
            {
                return;
            }
            materialInspector.DrawHeader();
            materialInspector.OnInspectorGUI();
        }
            float DrawEditor(Rect rect, Editor editor, bool disabled)
            {
                GUILayout.BeginArea(rect);
                Rect editorRect = EditorGUILayout.BeginVertical();

                {
                    using (new EditorGUI.DisabledScope(disabled))
                    {
                        if (editor == null)
                        {
                            GUI.enabled = true;
                            GUILayout.Label("None - this should not happen.", Styles.centeredLabelStyle);
                        }
                        else
                        {
                            if (editor.target is GameObject)
                            {
                                editor.DrawHeader();
                            }
                            else
                            {
                                EditorGUIUtility.hierarchyMode = true;
                                EditorGUILayout.InspectorTitlebar(true, editor.target);
                                EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);
                                editor.OnInspectorGUI();
                                EditorGUILayout.Space();
                                EditorGUILayout.EndVertical();
                            }
                        }
                    }
                }

                EditorGUILayout.EndVertical();
                GUILayout.EndArea();

                // Overdraw border by one pixel to the right and down, so adjacent borders overlap.
                GUI.Label(new Rect(rect.x, 0, rect.width + 1, m_PreviewSize.y + 1), GUIContent.none, Styles.borderStyle);

                return(editorRect.height);
            }
        public override void OnInspectorGUI()
        {
//			DrawDefaultInspector ();
//			EditorGUILayout.Space ();

            serObj.Update();
            EditorGUILayout.PropertyField(mat, new GUIContent("Cloud Material", "Put Cloud material here."));
//			NightBrightness.floatValue = EditorGUILayout.Slider("Night Brightness",NightBrightness.floatValue,0f,1f);
            serObj.ApplyModifiedProperties();

            m_DC = (DistanceCloud)target;
            Material m_Mat = m_DC.CloudMaterial;

            EditorGUI.BeginChangeCheck();

            // draw a Titlebar
//			if (m_Mat != null)
//				showMat = EditorGUILayout.InspectorTitlebar (showMat, m_Mat);

            InitEditor(m_Mat);

            currentMaterialEditor = m_tmpEditor;
//						if (GUI.changed) {
            if (EditorGUI.EndChangeCheck())
            {
                InitEditor(m_Mat);
            }

            // draw material setting
//			if (tmpEditor != null && m_Mat != null && showMat) {		// for Titlebar
            if (currentMaterialEditor != null && m_Mat != null)                         // for DrawHeader
            {
                currentMaterialEditor.DrawHeader();
                currentMaterialEditor.OnInspectorGUI();
            }
        }
        public override void OnInspectorGUI()
        {
            TargetMeshRenderer.gameObject.SetActive(false);
            try
            {
                foreach (PortalController p in targets)
                {
                    Undo.RecordObject(p, "Portal Controller Editor Changes");
                }

                EditorGUI.BeginChangeCheck();
                PortalController.TargetController = (PortalController)EditorGUILayout.ObjectField(
                    new GUIContent("Target Controller", "The targetTransform of this Portal."),
                    PortalController.TargetController, typeof(PortalController), true, null);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (PortalController p in targets)
                    {
                        p.TargetController = PortalController.TargetController;
                    }
                }

                //if (!PortalController.PortalScript.PortalCamera ||
                //    !PortalController.TargetController.PortalScript.PortalCamera) return;

                EditorGUI.BeginChangeCheck();
                PortalController.Portal =
                    (GameObject)EditorGUILayout.ObjectField(
                        new GUIContent("Portal Prefab", "The Prefab to use for when the Portal is spawned"),
                        PortalController.Portal, typeof(GameObject), false, null);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (PortalController p in targets)
                    {
                        p.Portal = PortalController.Portal;
                    }
                }


                if (SKSGlobalRenderSettings.ShouldOverrideMask)
                {
                    EditorGUILayout.HelpBox("Your Global Portal Settings are currently overriding the mask",
                                            MessageType.Warning);
                }

                EditorGUI.BeginChangeCheck();
                PortalController.Mask = (Texture2D)EditorGUILayout.ObjectField(new GUIContent("Portal Mask", "The transparency mask to use on the Portal"), PortalController.Mask, typeof(Texture2D), false, GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight));

                if (EditorGUI.EndChangeCheck())
                {
                    foreach (PortalController p in targets)
                    {
                        p.Mask = PortalController.Mask;
                    }
                }

                EditorGUI.BeginChangeCheck();
                Material material =
                    (Material)EditorGUILayout.ObjectField(
                        new GUIContent("Portal Material", "The material to use for the Portal"),
                        PortalController.PortalMaterial, typeof(Material), false, null);
                if (EditorGUI.EndChangeCheck())
                {
                    PortalMaterial = material;
                    foreach (PortalController p in targets)
                    {
                        p.PortalMaterial = PortalController.PortalMaterial;
                    }
                }


                EditorGUI.BeginChangeCheck();
                PortalController.Enterable =
                    EditorGUILayout.Toggle(
                        new GUIContent("Enterable", "Is the Portal Enterable by Teleportable Objects?"),
                        PortalController.Enterable);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (PortalController p in targets)
                    {
                        p.Enterable = PortalController.Enterable;
                    }
                }

                EditorGUI.BeginChangeCheck();
                PortalController.Is3D =
                    EditorGUILayout.Toggle(
                        new GUIContent("Portal is 3D Object", "Is the Portal a 3d object, such as a Crystal ball?"),
                        PortalController.Is3D);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (PortalController p in targets)
                    {
                        p.Is3D = PortalController.Is3D;
                    }
                }

                EditorGUI.BeginChangeCheck();
                PortalController.DetectionScale = EditorGUILayout.Slider(
                    new GUIContent("Detection zone Scale", "The scale of the portal detection zone."),
                    PortalController.DetectionScale, 1f, 10f);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (PortalController p in targets)
                    {
                        p.DetectionScale = PortalController.DetectionScale;
                    }
                }
                //Show the Portal Material Inspector
                if (Application.isPlaying)
                {
                    return;
                }

                EditorGUILayout.LabelField("Portal Material Preview:");

                if (PortalController.PortalMaterial)
                {
                    if (_matEditor == null)
                    {
                        _matEditor = UnityEditor.Editor.CreateEditor(PortalController.PortalMaterial);
                    }
                }

                _matEditor.DrawHeader();
                _matEditor.OnInspectorGUI();
            }
            catch
            {
                //Just for cleanliness
            }
            finally
            {
                if (!SKSGlobalRenderSettings.Preview)
                {
                    //CleanupTemp();
                }
            }

            //Cache state of random
            UnityEngine.Random.State seed = UnityEngine.Random.state;
            //Make color deterministic based on ID
            UnityEngine.Random.InitState(PortalController.GetInstanceID());
            PortalController.color = UnityEngine.Random.ColorHSV(0, 1, 0.48f, 0.48f, 0.81f, 0.81f);
            //Reset the random
            UnityEngine.Random.state = seed;
        }
Пример #10
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);
		}
 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);
   }
 }