internal static bool Show(Vector2 position, IProvider provider) { // If the window is already open, close it instead. var wins = Resources.FindObjectsOfTypeAll(typeof(FilterWindow)); if (wins.Length > 0) { try { ((EditorWindow)wins[0]).Close(); return(false); } catch (Exception) { s_FilterWindow = null; } } // We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting // playmode, we assume an increasing time when comparing time. long nowMilliSeconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; bool justClosed = nowMilliSeconds < s_LastClosedTime + 50; if (!justClosed) { Event.current.Use(); if (s_FilterWindow == null) { s_FilterWindow = CreateInstance <FilterWindow>(); s_FilterWindow.hideFlags = HideFlags.HideAndDontSave; } s_FilterWindow.Init(position, provider); return(true); } return(false); }
public override void OnInspectorGUI() { serializedObject.Update(); if (actualTarget.isDirty) { RefreshEditors(); actualTarget.isDirty = false; } using (var vscope = new EditorGUILayout.VerticalScope()) { EditorGUILayout.PropertyField(m_IsGlobal); if (!m_IsGlobal.boolValue) // Blend radius is not needed for global volumes { EditorGUILayout.PropertyField(m_BlendRadius); m_BlendRadius.floatValue = Mathf.Max(m_BlendRadius.floatValue, 0f); } EditorGUILayout.PropertyField(m_Weight); EditorGUILayout.PropertyField(m_Priority); EditorGUILayout.Space(); // Component list for (int i = 0; i < m_Editors.Count; i++) { var editor = m_Editors[i]; string title = editor.GetDisplayTitle(); int id = i; // Needed for closure capture below CoreEditorUtils.DrawSplitter(); bool displayContent = CoreEditorUtils.DrawHeaderToggle( title, editor.baseProperty, editor.activeProperty, pos => OnContextClick(pos, editor.target, id) ); if (displayContent) { using (new EditorGUI.DisabledScope(!editor.activeProperty.boolValue)) editor.OnInternalInspectorGUI(); } } if (m_Editors.Count > 0) { CoreEditorUtils.DrawSplitter(); } else { EditorGUILayout.HelpBox("No override set on this volume. Drop a component here or use the Add button.", MessageType.Info); } EditorGUILayout.Space(); using (var hscope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(CoreEditorUtils.GetContent("Add component overrides..."), EditorStyles.miniButton)) { var r = hscope.rect; var pos = new Vector2(r.x + r.width / 2f, r.yMax + 18f); FilterWindow.Show(pos, new VolumeComponentProvider(actualTarget, this)); } } EditorGUILayout.Space(); // Handle components drag'n'drop var e = Event.current; if (e.type == EventType.DragUpdated) { if (IsDragValid(vscope.rect, e.mousePosition)) { DragAndDrop.visualMode = DragAndDropVisualMode.Link; e.Use(); } else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } } else if (e.type == EventType.DragPerform) { if (IsDragValid(vscope.rect, e.mousePosition)) { DragAndDrop.AcceptDrag(); var objs = DragAndDrop.objectReferences; foreach (var o in objs) { var compType = ((MonoScript)o).GetClass(); AddComponent(compType); } e.Use(); } } } serializedObject.ApplyModifiedProperties(); }
public virtual bool OnGUI(FilterWindow sFilterWindow) { return(false); }
public virtual bool HandleKeyboard(Event evt, FilterWindow window, Action goToParent) { return(false); }
void OnDisable() { s_LastClosedTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; s_FilterWindow = null; }
void OnEnable() { s_FilterWindow = this; m_Search = ""; }
public void OnGUI() { if (asset == null) { return; } if (asset.isDirty) { RefreshEditors(); asset.isDirty = false; } bool isEditable = !VersionControl.Provider.isActive || AssetDatabase.IsOpenForEdit(asset, StatusQueryOptions.UseCachedIfPossible); using (new EditorGUI.DisabledScope(!isEditable)) { // Component list for (int i = 0; i < m_Editors.Count; i++) { var editor = m_Editors[i]; string title = editor.GetDisplayTitle(); int id = i; // Needed for closure capture below CoreEditorUtils.DrawSplitter(); bool displayContent = CoreEditorUtils.DrawHeaderToggle( title, editor.baseProperty, editor.activeProperty, pos => OnContextClick(pos, editor.target, id) ); if (displayContent) { using (new EditorGUI.DisabledScope(!editor.activeProperty.boolValue)) editor.OnInternalInspectorGUI(); } } if (m_Editors.Count > 0) { CoreEditorUtils.DrawSplitter(); } else { EditorGUILayout.HelpBox("No override set on this volume. Drop a component here or use the Add button.", MessageType.Info); } EditorGUILayout.Space(); using (var hscope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(CoreEditorUtils.GetContent("Add component overrides..."), EditorStyles.miniButton)) { var r = hscope.rect; var pos = new Vector2(r.x + r.width / 2f, r.yMax + 18f); FilterWindow.Show(pos, new VolumeComponentProvider(asset, this)); } } } }