コード例 #1
0
 void OnClick_BuildGameAndRun()
 {
     BuildTools.BuildGame(andRun: true);
 }
コード例 #2
0
ファイル: BuildWindow.cs プロジェクト: JinKitamura/learn
    void DrawBuildTools()
    {
        var action = BuildAction.None;

        if (GUILayout.Button("Update Registry"))
        {
            Debug.Log("Updating registries...");
            BundledResourceBuilder.UpdateRegistries(false);
            Debug.Log("Updating registries done");
        }

        GUILayout.Label("Bundles (" + PrettyPrintTimeStamp(TimeLastBuildBundles()) + ")", EditorStyles.boldLabel);

        var buildBundledLevels           = false;
        var buildBundledAssets           = false;
        var forceBuildBundles            = false;
        List <LevelInfo> buildOnlyLevels = null;

        s_SingleLevelBuilding = EditorGUILayout.Toggle("Single level building", s_SingleLevelBuilding);
        if (s_SingleLevelBuilding)
        {
            GUILayout.BeginVertical();
            foreach (var l in m_LevelInfos)
            {
                if (GUILayout.Button("Build only: " + l.name + " [force]"))
                {
                    buildBundledLevels = true;
                    forceBuildBundles  = true;
                    buildOnlyLevels    = new List <LevelInfo>();
                    buildOnlyLevels.Add(l);
                    break;
                }
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Levels [force]"))
        {
            buildBundledLevels = true;
            forceBuildBundles  = true;
        }
        if (GUILayout.Button("Assets [force]"))
        {
            buildBundledAssets = true;
            forceBuildBundles  = true;
        }
        if (GUILayout.Button("All [force]"))
        {
            buildBundledLevels = true;
            buildBundledAssets = true;
            forceBuildBundles  = true;
        }
        GUILayout.EndHorizontal();

        var buildTarget = EditorUserBuildSettings.activeBuildTarget;    // BuildTarget.StandaloneWindows64

        if (buildBundledLevels || buildBundledAssets)
        {
            BuildTools.BuildBundles(GetBundlePath(buildTarget), buildTarget, buildBundledAssets, buildBundledLevels, forceBuildBundles, buildOnlyLevels);
            if (buildTarget == BuildTarget.PS4)
            {
                // Copy the asset bundles into the PS4 game folder too
                var bundlePathSrc = GetBundlePath(buildTarget) + "/" + SimpleBundleManager.assetBundleFolder;
                var bundlePathDst = GetBuildPath(buildTarget) + "/" + GetBuildExeName(buildTarget) + "/Media/StreamingAssets/" + SimpleBundleManager.assetBundleFolder;
                BuildTools.CopyDirectory(bundlePathSrc, bundlePathDst);
            }
            GUIUtility.ExitGUI();
        }

        GUILayout.Space(10.0f);
        GUILayout.Label("Game (" + PrettyPrintTimeStamp(TimeLastBuildGame()) + ")", EditorStyles.boldLabel);
        GUILayout.Space(1.0f);

        GUILayout.Label("Building for: " + buildTarget.ToString() + " use normal build window to change.", GUILayout.ExpandWidth(false));

        GUILayout.BeginHorizontal();
        m_BuildDevelopment = EditorGUILayout.Toggle("Development build", m_BuildDevelopment);
        GUI.enabled        = m_BuildDevelopment;
        m_ConnectProfiler  = EditorGUILayout.Toggle("Connect profiler", m_ConnectProfiler);
        GUI.enabled        = true;
        GUILayout.EndHorizontal();

        m_IL2CPP         = EditorGUILayout.Toggle("IL2CPP", m_IL2CPP);
        m_AllowDebugging = EditorGUILayout.Toggle("Allow debugging", m_AllowDebugging);

        var m_RunArguments = EditorPrefTextField("Arguments", "RunArguments");

        GUILayout.BeginHorizontal();
        var buildGame        = false;
        var buildOnlyScripts = false;

        if (GUILayout.Button("Build game"))
        {
            buildGame = true;
        }
        if (GUILayout.Button("Build ONLY scripts"))
        {
            buildOnlyScripts = true;
        }
        if (buildGame || buildOnlyScripts)
        {
            StopAll();

            var buildOptions = m_AllowDebugging ? BuildOptions.AllowDebugging : BuildOptions.None;
            if (buildOnlyScripts)
            {
                buildOptions |= BuildOptions.BuildScriptsOnly;
            }

            if (m_BuildDevelopment)
            {
                buildOptions |= BuildOptions.Development;
                if (m_ConnectProfiler)
                {
                    buildOptions |= BuildOptions.ConnectWithProfiler;
                }
            }

            BuildTools.BuildGame(GetBuildPath(buildTarget), GetBuildExeName(buildTarget), buildTarget, buildOptions, "AutoBuild", m_IL2CPP);

            if (action == BuildAction.BuildAndRun)
            {
                RunBuild("");
            }
            GUIUtility.ExitGUI(); // prevent warnings from gui about unmatched layouts
        }
        if (GUILayout.Button("Run"))
        {
            RunBuild(m_RunArguments);
            GUIUtility.ExitGUI(); // prevent warnings from gui about unmatched layouts
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        var path        = Application.dataPath.BeforeLast("Assets") + GetBuildPath(buildTarget);
        var windowsPath = path.Replace("/", "\\");

        if (GUILayout.Button("Open build folder"))
        {
            if (Directory.Exists(windowsPath))
            {
                var p = new System.Diagnostics.Process();
                p.StartInfo = new System.Diagnostics.ProcessStartInfo("explorer.exe", windowsPath);
                p.Start();
            }
            else
            {
                EditorUtility.DisplayDialog("Folder missing", string.Format("Folder {0} doesn't exist yet", windowsPath), "Ok");
            }
        }
        GUILayout.EndHorizontal();
    }
コード例 #3
0
 void OnClick_BuildGame()
 {
     BuildTools.BuildGame(andRun: false);
 }