示例#1
0
        private void OnGUI()
        {
            if (firstFrame)
            {
                UpdatePositionToMouse();
                firstFrame = false;
            }
            input = EditorGUILayout.TextField(input);
            Event e = Event.current;

            // If input is empty, revert name to default instead
            if (input == null || input.Trim() == "")
            {
                if (GUILayout.Button("Revert to default") || (e.isKey && e.keyCode == KeyCode.Return))
                {
                    target.name = NodeEditorUtilities.NodeDefaultName(target.GetType());
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
                    Close();
                    NodeEditorWindow.TriggerOnValidate(target);
                }
            }
            // Rename asset to input text
            else
            {
                if (GUILayout.Button("Apply") || (e.isKey && e.keyCode == KeyCode.Return))
                {
                    target.name = input;
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
                    Close();
                    NodeEditorWindow.TriggerOnValidate(target);
                }
            }
        }