/// <summary> /// Initiate a rename on the currently selected node /// </summary> public void RenameSelectedNode() { if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { XNode.Node node = Selection.activeObject as XNode.Node; if (nodeSizes.TryGetValue(node, out Vector2 size)) { RenamePopup.Show(Selection.activeObject, node.RenameAction, size.x); } else { RenamePopup.Show(Selection.activeObject, node.RenameAction); } } }
/// <summary> Show a rename popup for an asset at mouse position. Will trigger reimport of /// the asset on apply. public static RenamePopup Show(Object target, Action <string> renameAction = null, float width = 200) { RenamePopup window = EditorWindow.GetWindow <RenamePopup>(true, "Rename " + target.name, true); if (current != null) { current.Close(); } current = window; window._renameAction = renameAction; window.target = target; window.input = target.name; window.minSize = new Vector2(100, 44); window.position = new Rect(0, 0, width, 44); GUI.FocusControl("ClearAllFocus"); window.UpdatePositionToMouse(); return(window); }