Exemplo n.º 1
0
        public static void Show(string titleText, string labelText, string submitText, string cancelText, string defaultValue, Action <string> onSubmit, Action onCancel = null)
        {
            TextFieldDialog dialog = CreateInstance <TextFieldDialog>();

            dialog._labelText  = labelText;
            dialog._submitText = submitText;
            dialog._cancelText = cancelText;
            dialog._value      = defaultValue;
            dialog._onSubmit   = onSubmit;
            dialog._onCancel   = onCancel;

            dialog.titleContent = new GUIContent(titleText);
            dialog.ShowAuxWindow();
            dialog.CenterInScreen(250, 100);
        }
Exemplo n.º 2
0
        private static void DuplicateScript(MenuCommand command)
        {
            void Duplicate(string name)
            {
                MonoScript script = Selection.activeObject as MonoScript;

                if (script.name != name)
                {
                    string text = script.text.Replace("\r\n", "\n");
                    text = text.Replace(script.name, name);

                    string path = AssetDatabase.GetAssetPath(script);
                    path = path.Substring(0, path.LastIndexOf(script.name)) + name + ".cs";

                    EditorUtils.CreateTextFile(path, text);
                }
            }

            TextFieldDialog.Show("Duplicate Script", "Script name:", "Ok", "Cancel", Selection.activeObject.name, Duplicate, null);
        }