Ejemplo n.º 1
0
        public static void Show(Vector2 pos, string header, string input, bool emptyAcceptable, Action <string> OnAccepted)
        {
            if (!_singleton)
            {
                _singleton = CreateInstance <InputStringPopup>();
            }

            _singleton.header          = header;
            _singleton.input           = input;
            _singleton.isFirstGUI      = true;
            _singleton.emptyAcceptable = emptyAcceptable;
            _singleton.OnAccepted      = OnAccepted;
            _singleton.ShowAsDropDown(GUIUtility.GUIToScreenPoint(pos).ToRect(),
                                      new Vector2(200, 90));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Open dialog to quickly rename object (support bulk rename)
        /// </summary>
        static public void OpenRenameDialog()
        {
            var names     = Array.ConvertAll(Selection.gameObjects, x => (x.name));
            var baseNames = Array.ConvertAll(names, x => kBaseName.Replace(x, ""));

            // Check if name consistent
            // 0 = Names consistent, 1 = Base Name consistent, 2 = All mixed
            int flag = names.All(x => x == names[0]) ? 0 :
                       (baseNames.All(x => x == baseNames[0]) ? 1 : 2);

            InputStringPopup.Show(ev.mousePosition, "Rename",
                                  flag == 0 ? names[0] : (flag == 1 ? baseNames[0] : ""), false, (x) =>
            {
                foreach (var g in Selection.gameObjects)
                {
                    g.name = flag == 1 ? x + (kBaseName.Match(g.name)) : x;
                }
            });
        }