private void OnGUI() { switch (Event.current.type) { case EventType.KeyDown: if ((Event.current.modifiers & ~EventModifiers.FunctionKey) == EventModifiers.Control && (Event.current.keyCode == KeyCode.PageUp || Event.current.keyCode == KeyCode.PageDown)) { SelectAdjacentCodeTab(Event.current.keyCode == KeyCode.PageDown); Event.current.Use(); GUIUtility.ExitGUI(); } else if (Event.current.alt && EditorGUI.actionKey) { if (Event.current.keyCode == KeyCode.RightArrow || Event.current.keyCode == KeyCode.LeftArrow) { if (Event.current.shift) { MoveThisTab(Event.current.keyCode == KeyCode.RightArrow); } else { SelectAdjacentCodeTab(Event.current.keyCode == KeyCode.RightArrow); } Event.current.Use(); GUIUtility.ExitGUI(); } } else if (!Event.current.alt && !Event.current.shift && EditorGUI.actionKey) { if (Event.current.keyCode == KeyCode.W || Event.current.keyCode == KeyCode.F4) { Event.current.Use(); FGCodeWindow codeTab = GetAdjacentCodeTab(false); if (codeTab == null) codeTab = GetAdjacentCodeTab(true); Close(); if (codeTab != null) codeTab.Focus(); } } //else if (!Event.current.alt && !Event.current.shift && EditorGUI.actionKey) //{ // if (Event.current.keyCode == KeyCode.M) // { // Event.current.Use(); // ToggleMaximized(); // GUIUtility.ExitGUI(); // } //} break; case EventType.DragUpdated: case EventType.DragPerform: if (DragAndDrop.objectReferences.Length > 0) { bool ask = false; HashSet<Object> accepted = new HashSet<Object>(); foreach (Object obj in DragAndDrop.objectReferences) { if (AssetDatabase.GetAssetPath(obj).EndsWith(".dll", System.StringComparison.OrdinalIgnoreCase)) continue; if (obj is MonoScript) accepted.Add(obj); else if (obj is TextAsset || obj is Shader) accepted.Add(obj); else if (obj is Material) { Material material = obj as Material; if (material.shader != null) { int shaderID = material.shader.GetInstanceID(); if (shaderID != 0) { if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(shaderID))) accepted.Add(material.shader); } } } else if (obj is GameObject) { GameObject gameObject = obj as GameObject; MonoBehaviour[] monoBehaviours = gameObject.GetComponents<MonoBehaviour>(); foreach (MonoBehaviour mb in monoBehaviours) { MonoScript monoScript = MonoScript.FromMonoBehaviour(mb); if (monoScript != null) { if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(monoScript))) { accepted.Add(monoScript); ask = true; } } } } } if (accepted.Count > 0) { DragAndDrop.AcceptDrag(); DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (Event.current.type == EventType.DragPerform) { Object[] sorted = accepted.OrderBy((x) => x.name, System.StringComparer.OrdinalIgnoreCase).ToArray(); if (ask && sorted.Length > 1) { GenericMenu popupMenu = new GenericMenu(); foreach (Object target in sorted) { Object tempTarget = target; popupMenu.AddItem( new GUIContent("Open " + System.IO.Path.GetFileName(AssetDatabase.GetAssetPath(target))), false, () => { OpenNewWindow(tempTarget, this, true); }); } popupMenu.AddSeparator(""); popupMenu.AddItem( new GUIContent("Open All"), false, () => { foreach (Object target in sorted) OpenNewWindow(target, this); }); popupMenu.ShowAsContext(); } else { foreach (Object target in sorted) OpenNewWindow(target, this, sorted.Length == 1); } } Event.current.Use(); return; } } break; case EventType.ValidateCommand: if (Event.current.commandName == "ScriptInspector.AddTab") { Event.current.Use(); return; } break; case EventType.ExecuteCommand: if (Event.current.commandName == "ScriptInspector.AddTab") { Event.current.Use(); OpenNewWindow(targetAsset, this); return; } break; } wantsMouseMove = true; textEditor.OnWindowGUI(this, new RectOffset(0, 0, 19, 1)); }