private static void OnSceneGUIDelegate(SceneView sceneview) { Event e = Event.current; if (e.type == EventType.KeyDown) { switch (e.keyCode) { case KeyCode.N: if (e.alt) { AssetsMenuItem.CopyName(); e.Use(); } break; case KeyCode.M: if (e.alt) { PasteName(); e.Use(); } break; case KeyCode.Space: ToggleGameObjcetActiveSelf(); e.Use(); break; } } }
private static void ProjectWindowItemOnGui(string guid, Rect selectionRect) { Event e = Event.current; if (e.type == EventType.KeyDown) { switch (e.keyCode) { case KeyCode.N: if (e.alt) { AssetsMenuItem.CopyName(); e.Use(); } break; } } else if (e.type == EventType.MouseDown && e.button == 2 && selectionRect.Contains(e.mousePosition)) { ProcessingPath(e.alt, AssetDatabase.GUIDToAssetPath(guid)); e.Use(); } }
private static void HierarchyWindowItemOnGui(int instanceID, Rect selectionRect) { if (Selection.gameObjects.Length == 0) { return; } void MoveTargetAnchoredPosition(Vector2 v2Unit, IEnumerable <Transform> targets) { foreach (Transform item in targets) { RectTransform rtf = item as RectTransform; if (rtf) { rtf.anchoredPosition += v2Unit; } } } Event e = Event.current; if (e.type == EventType.KeyDown) { if (e.control) { int nUnit = e.shift ? 10 : 1; switch (e.keyCode) { case KeyCode.UpArrow: Undo.RecordObjects(Selection.transforms, "UpArrow"); MoveTargetAnchoredPosition(Vector2.up * nUnit, Selection.transforms); e.Use(); break; case KeyCode.DownArrow: Undo.RecordObjects(Selection.transforms, "DownArrow"); MoveTargetAnchoredPosition(Vector2.down * nUnit, Selection.transforms); e.Use(); break; case KeyCode.LeftArrow: Undo.RecordObjects(Selection.transforms, "LeftArrow"); MoveTargetAnchoredPosition(Vector2.left * nUnit, Selection.transforms); e.Use(); break; case KeyCode.RightArrow: Undo.RecordObjects(Selection.transforms, "RightArrow"); MoveTargetAnchoredPosition(Vector2.right * nUnit, Selection.transforms); e.Use(); break; } } if (e.alt) { Transform newActiveTransform = Selection.activeTransform; if (activeTransform != newActiveTransform) { if (activeTransform && changeSiblingIndex) { changeSiblingIndex = false; if (activeTransform.parent == newActiveTransform.parent) { int s1 = activeTransform.GetSiblingIndex(); int s2 = newActiveTransform.GetSiblingIndex(); Undo.SetTransformParent(activeTransform, activeTransform.parent, "Set sibling"); activeTransform.SetSiblingIndex(s1 < s2 ? s2 : s2 + 1); } return; } activeTransform = newActiveTransform; } switch (e.keyCode) { case KeyCode.N: AssetsMenuItem.CopyName(); e.Use(); break; case KeyCode.M: PasteName(); e.Use(); break; case KeyCode.DownArrow: if (e.alt) { if (!AddSelectionTransformsBySameParent()) { return; } list.Sort((t1, t2) => t2.GetSiblingIndex() - t1.GetSiblingIndex()); for (int i = 0; i < list.Count; i++) { Transform transform = list[i]; int target = transform.GetSiblingIndex() + 1; if (transform.parent) { if (target >= transform.parent.childCount) { target = 0; } } Undo.SetTransformParent(transform, transform.parent, "Set sibling"); transform.SetSiblingIndex(target); } e.Use(); } break; case KeyCode.UpArrow: if (e.alt) { if (!AddSelectionTransformsBySameParent()) { return; } list.Sort((t1, t2) => t1.GetSiblingIndex() - t2.GetSiblingIndex()); for (int i = 0; i < list.Count; i++) { Transform transform = list[i]; int target = transform.GetSiblingIndex() - 1; if (target < 0 && !transform.parent) { continue; } Undo.SetTransformParent(transform, transform.parent, "Set sibling"); transform.SetSiblingIndex(target); } e.Use(); } break; } } switch (e.keyCode) { case KeyCode.Space: ToggleGameObjcetActiveSelf(); e.Use(); break; } } else if (e.type == EventType.MouseDown) { if (e.button == 2) { if (e.alt) { StringBuilder sb = new StringBuilder(256); for (int i = 0; i < Selection.gameObjects.Length; i++) { GameObject gameObject = Selection.gameObjects[i]; sb.AppendLine(gameObject.transform.GetPathExt()); } sb.Remove(sb.Length - 1, 1); string paths = sb.ToString(); GUIUtility.systemCopyBuffer = paths; Debug.Log(paths); } else if (e.shift) { ToggleGameObjcetActive(); } else { ToggleGameObjcetActiveSelf(); } e.Use(); } if (e.button == 0) { if (e.alt) { changeSiblingIndex = true; return; } } changeSiblingIndex = false; } }