public static CreateCachedEditor ( Object targetObject, |
||
targetObject | Object | |
editorType | ||
previousEditor | ||
return | void |
public override void OnPreviewGUI(Rect position, GUIStyle style) { if (!this.ValidPreviewSetup()) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.5f); GUILayout.Label("Reflection Probe not baked yet", new GUILayoutOption[0]); GUI.color = color; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { ReflectionProbe reflectionProbe = base.target as ReflectionProbe; if (reflectionProbe != null && reflectionProbe.texture != null && base.targets.Length == 1) { Editor cubemapEditor = this.m_CubemapEditor; Editor.CreateCachedEditor(reflectionProbe.texture, null, ref cubemapEditor); this.m_CubemapEditor = (cubemapEditor as TextureInspector); } if (this.m_CubemapEditor != null) { this.m_CubemapEditor.SetCubemapIntensity(this.GetProbeIntensity((ReflectionProbe)base.target)); this.m_CubemapEditor.OnPreviewGUI(position, style); } } }
public override void OnPreviewGUI(Rect position, GUIStyle style) { if (!this.ValidPreviewSetup()) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.5f); GUILayout.Label("Reflection Probe not baked yet"); GUI.color = color; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { ReflectionProbe target = this.target as ReflectionProbe; if ((UnityEngine.Object)target != (UnityEngine.Object)null && (UnityEngine.Object)target.texture != (UnityEngine.Object)null && this.targets.Length == 1) { Editor cubemapEditor = (Editor)this.m_CubemapEditor; Editor.CreateCachedEditor((UnityEngine.Object)target.texture, (System.Type)null, ref cubemapEditor); this.m_CubemapEditor = cubemapEditor as TextureInspector; } if (!((UnityEngine.Object) this.m_CubemapEditor != (UnityEngine.Object)null)) { return; } this.m_CubemapEditor.SetCubemapIntensity(this.GetProbeIntensity((ReflectionProbe)this.target)); this.m_CubemapEditor.OnPreviewGUI(position, style); } }
public override void OnPreviewGUI(Rect position, GUIStyle style) { // Fix for case 939947 where we didn't get the Layout event if the texture was null when changing color if (!ValidPreviewSetup() && Event.current.type != EventType.ExecuteCommand) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Color prevColor = GUI.color; GUI.color = new Color(1, 1, 1, 0.5f); GUILayout.Label("Reflection Probe not baked/ready yet"); GUI.color = prevColor; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return; } ReflectionProbe p = target as ReflectionProbe; if (p != null && p.texture != null && targets.Length == 1) { Editor editor = m_CubemapEditor; Editor.CreateCachedEditor(p.texture, null, ref editor); m_CubemapEditor = editor as TextureInspector; } if (m_CubemapEditor != null) { m_CubemapEditor.SetCubemapIntensity(GetProbeIntensity((ReflectionProbe)target)); m_CubemapEditor.OnPreviewGUI(position, style); } }
public override void OnFooterGUI(FuzzyOptionNode node, Rect position) { if (editorTarget != prefab) { editorTarget = prefab; UEditor.CreateCachedEditor(editorTarget, null, ref editor); } if (editor != null) { editor.DrawPreview(position); } }
public override bool HasPreviewGUI() { if (base.targets.Length > 1) { return(false); } if (this.ValidPreviewSetup()) { Editor cubemapEditor = this.m_CubemapEditor; Editor.CreateCachedEditor(((ReflectionProbe)this.target).texture, null, ref cubemapEditor); this.m_CubemapEditor = (cubemapEditor as TextureInspector); } return(true); }
public override bool HasPreviewGUI() { if (this.targets.Length > 1) { return(false); } if (this.ValidPreviewSetup()) { Editor cubemapEditor = (Editor)this.m_CubemapEditor; Editor.CreateCachedEditor((UnityEngine.Object)((ReflectionProbe)this.target).texture, (System.Type)null, ref cubemapEditor); this.m_CubemapEditor = cubemapEditor as TextureInspector; } return(true); }
public override bool HasPreviewGUI() { if (targets.Length > 1) { return(false); // We only handle one preview for reflection probes } // Ensure valid cube map editor (if possible) if (ValidPreviewSetup()) { Editor editor = m_CubemapEditor; Editor.CreateCachedEditor(((ReflectionProbe)target).texture, null, ref editor); m_CubemapEditor = editor as TextureInspector; } // If having one probe selected we always want preview (to prevent preview window from popping) return(true); }
void CreateTextureInspector(Texture texture, ref Editor previousEditor) { switch (texture) { case Cubemap _: Editor.CreateCachedEditor(texture, typeof(CubemapInspector), ref previousEditor); break; case CustomRenderTexture _: Editor.CreateCachedEditor(texture, typeof(CustomRenderTextureEditor), ref previousEditor); break; case RenderTexture _: Editor.CreateCachedEditor(texture, typeof(RenderTextureEditor), ref previousEditor); break; default: Editor.CreateCachedEditor(texture, typeof(TextureInspector), ref previousEditor); break; } }
private Editor GetLightmapParametersEditor(UnityEngine.Object[] lights) { Editor.CreateCachedEditor(lights, typeof(LightmapParametersEditor), ref this.m_LightmapParametersEditor); return(this.m_LightmapParametersEditor); }
private Editor GetLightEditor(Light[] lights) { Editor.CreateCachedEditor(lights, typeof(LightEditor), ref this.m_LightEditor); return(this.m_LightEditor); }
protected override void OnGUI() { base.OnGUI(); // Reloaded from serialization if (treeView == null) { Close(); GUIUtility.ExitGUI(); } // Close on Escape if (e.type == EventType.KeyDown && e.modifiers == EventModifiers.None && e.keyCode == KeyCode.Escape) { Close(); GUIUtility.ExitGUI(); } var innerPosition = new Rect(0, 0, position.width, position.height); // Draw Background EditorGUI.DrawRect(innerPosition, ColorPalette.unityBackgroundMid); GUILayout.BeginVertical(); // Draw Search GUILayout.BeginHorizontal(LudiqStyles.searchFieldBackground, GUILayout.Height(LudiqStyles.searchFieldOuterHeight), GUILayout.ExpandWidth(true)); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName(searchFieldName); // Special keyboard controls while search field is selected if (GUI.GetNameOfFocusedControl() == searchFieldName && e.type == EventType.KeyDown) { // Pass arrow events to tree view if (e.keyCode == KeyCode.DownArrow || e.keyCode == KeyCode.UpArrow || !treeView.hasSearch && (e.keyCode == KeyCode.LeftArrow || e.keyCode == KeyCode.RightArrow)) { var selection = treeView.GetSelection(); treeView.SetFocus(); treeView.SetSelection(selection); } // Confirm search with enter else if (e.keyCode == KeyCode.Return) { if (treeView.SelectActive()) { Close(); GUIUtility.ExitGUI(); } else { e.Use(); } } // Close if pressing space again without search else if (e.keyCode == KeyCode.Space && !treeView.hasSearch) { Close(); GUIUtility.ExitGUI(); } } treeView.searchString = EditorGUILayout.TextField(treeView.searchString, LudiqStyles.searchField); // Focus on Search if (focusSearch && e.type == EventType.Repaint) { GUI.FocusControl(searchFieldName); focusSearch = false; } // Reload Tree View on Search if (EditorGUI.EndChangeCheck()) { treeView.Reload(); } // Search Cancel Button if (GUILayout.Button(GUIContent.none, treeView.hasSearch ? LudiqStyles.searchFieldCancelButton : LudiqStyles.searchFieldCancelButtonEmpty) && treeView.hasSearch) { treeView.searchString = string.Empty; treeView.Reload(); GUIUtility.keyboardControl = 0; } GUILayout.EndHorizontal(); // Horizontal Separator GUILayout.Box(GUIContent.none, LudiqStyles.horizontalSeparator); // Handle special keyboard strokes in tree view if (treeView.HasFocus() && e.type == EventType.KeyDown) { // Select current item if (e.keyCode == KeyCode.Space) { if (treeView.SelectActive()) { Close(); GUIUtility.ExitGUI(); } else { e.Use(); } } // Move back up to search field else if (e.keyCode == KeyCode.UpArrow) { if (treeView.GetSelection().FirstOrDefault() == treeView.GetRows().FirstOrDefault()?.id) { focusSearch = true; e.Use(); } } // Delete character from search else if (e.keyCode == KeyCode.Backspace) { treeView.searchString = treeView.searchString.Substring(0, Mathf.Max(0, treeView.searchString.Length - 1)); e.Use(); } // Append characters to search else if (e.modifiers == EventModifiers.None && !char.IsWhiteSpace(e.character) && !char.IsControl(e.character)) { treeView.searchString += e.character; e.Use(); } // Focus search else if (e.keyCode == KeyCode.F && e.CtrlOrCmd()) { focusSearch = true; e.Use(); } } // Draw Tree View var treeViewPosition = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); treeView.OnGUI(treeViewPosition); // Draw Preview previewEditorTargets.Clear(); previewEditorTargets.AddRange(treeView.GetActiveGameObjects()); if ((previewEditor == null && previewEditorTargets.Count > 0) || (previewEditor != null && !previewEditorTargets.SequenceEqual(previewEditor.targets))) { UEditor.CreateCachedEditor(previewEditorTargets.ToArray(), null, ref previewEditor); } if (previewEditor != null && (previewEditor.HasPreviewGUI() || previewEditorTargets.Any(PreviewUtility.HasPreview))) { GUILayout.Box(GUIContent.none, LudiqStyles.horizontalSeparator); var previewPosition = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(Styles.previewHeight), GUILayout.ExpandWidth(true)); previewEditor.DrawPreview(previewPosition); } GUILayout.EndVertical(); // Draw Border if (e.type == EventType.Repaint) { LudiqGUI.DrawEmptyRect(new Rect(Vector2.zero, position.size), ColorPalette.unityBackgroundVeryDark); } // Repaint on hover if (innerPosition.Contains(e.mousePosition)) { Repaint(); } }
private Editor GetLightEditor(Light[] lights) { Editor.CreateCachedEditor((UnityEngine.Object[])lights, typeof(LightEditor), ref this.m_LightEditor); return(this.m_LightEditor); }