Beispiel #1
0
    public static EditorInputWindow show(InputCommit func)
    {
        Vector2           winSize = new Vector2(400, 122);
        EditorInputWindow wnd     = GetWindowWithRect <EditorInputWindow>(new Rect((Screen.width - winSize.x) * 0.5f, (Screen.height - winSize.y) * 0.5f, winSize.x, winSize.y));

        wnd.inputCommit = func;
        wnd.Show();
        return(wnd);
    }
Beispiel #2
0
 static void CreateNewScene()
 {
     EditorInputWindow.show(delegate(string newSceneName)
     {
         if (string.IsNullOrEmpty(newSceneName))
         {
             Debug.LogError("请输入场景名");
             return;
         }
         Scene newScene      = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
         string newSceneDir  = "Assets/Res/BundleScenes/" + newSceneName + "/";
         string newScenePath = "Assets/Res/BundleScenes/" + newSceneName + ".unity";
         if (File.Exists(newScenePath))
         {
             EditorUtility.DisplayDialog("", "默认场景\"" + newSceneName + "\"已经存在!", "确定");
         }
         else
         {
             if (!Directory.Exists(newSceneDir))
             {
                 Directory.CreateDirectory(newSceneDir);
             }
             if (!Directory.Exists(newSceneDir + "Materials/"))
             {
                 Directory.CreateDirectory(newSceneDir + "Materials/");
             }
             if (!Directory.Exists(newSceneDir + "Models/"))
             {
                 Directory.CreateDirectory(newSceneDir + "Models/");
             }
             if (!Directory.Exists(newSceneDir + "Textures/"))
             {
                 Directory.CreateDirectory(newSceneDir + "Textures/");
             }
             EditorSceneManager.SaveScene(newScene, newScenePath);
         }
     });
 }