示例#1
0
 public static void StandaloneWindows64()
 {
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
 }
示例#2
0
 static void GenericBuild(string[] scenes, string target_dir, BuildTarget build_target, BuildOptions build_options)
 {
     EditorUserBuildSettings.SwitchActiveBuildTarget(build_target);
     BuildReport res = BuildPipeline.BuildPlayer(scenes, target_dir, build_target, build_options);
 }
示例#3
0
 private static void BuildForAndroid()
 {
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
     BuildPlayer(BuildTarget.Android, BuilderConstants.DEFAULT_BUILD_DIRECTORY);
 }
示例#4
0
 public static void SwitchToAndroid()
 {
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
 }
示例#5
0
        public void OnGUI(Rect pos)
        {
            m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition);
            bool newState = false;

            //basic options
            EditorGUILayout.Space();
            GUILayout.BeginVertical();

            m_buildTarget = ABBuilder.Instance.CurBuildPlatform;
            EditorGUILayout.TextField(m_TargetContent, m_buildTarget.ToString());

            EditorPrefs.SetInt(kBuildPrefPrefix + "BuildTarget", (int)m_buildTarget);

            m_outputPath = ABBuilder.Instance.GetPathPrefix_Assetbundle();
            EditorUserBuildSettings.SetPlatformSettings(ABBuilder.GetCurrentBuildPlatformName(), "AssetBundleOutputPath", m_outputPath);

            //output path
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            var newPath = EditorGUILayout.TextField("Output Path", m_outputPath);

            if (newPath != m_outputPath)
            {
                m_useDefaultPath = false;
                m_outputPath     = newPath;
                EditorUserBuildSettings.SetPlatformSettings(ABBuilder.GetCurrentBuildPlatformName(), "AssetBundleOutputPath", m_outputPath);
            }

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (string.IsNullOrEmpty(m_outputPath))
            {
                m_outputPath = EditorUserBuildSettings.GetPlatformSettings(ABBuilder.GetCurrentBuildPlatformName(), "AssetBundleOutputPath");
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            newState = GUILayout.Toggle(
                m_ForceRebuild.state,
                m_ForceRebuild.content);
            if (newState != m_ForceRebuild.state)
            {
                EditorPrefs.SetBool(m_ForceRebuild.PrefKey, newState);
                m_ForceRebuild.state = newState;
            }
            newState = GUILayout.Toggle(
                m_CopyToStreaming.state,
                m_CopyToStreaming.content);
            if (newState != m_CopyToStreaming.state)
            {
                EditorPrefs.SetBool(m_CopyToStreaming.PrefKey, newState);
                m_CopyToStreaming.state = newState;
            }

            // advanced options
            EditorGUILayout.Space();
            m_advancedSettings = EditorGUILayout.Foldout(m_advancedSettings, "Advanced Settings");
            if (m_advancedSettings)
            {
                var indent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 1;
                CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup(
                    m_CompressionContent,
                    (int)m_compression,
                    m_CompressionOptions,
                    m_CompressionValues);

                if (cmp != m_compression)
                {
                    m_compression = cmp;
                    EditorPrefs.SetInt(kBuildPrefPrefix + "Compression", (int)m_compression);
                }
                foreach (var tog in m_toggleData)
                {
                    newState = EditorGUILayout.ToggleLeft(
                        tog.content,
                        tog.state);
                    if (newState != tog.state)
                    {
                        EditorPrefs.SetBool(tog.PrefKey, newState);
                        tog.state = newState;
                    }
                }
                EditorGUILayout.Space();
                EditorGUI.indentLevel = indent;
            }

            // build.
            EditorGUILayout.Space();
            if (GUILayout.Button("Build"))
            {
                ExecuteBuild();
            }
            GUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
示例#6
0
    void OnGUI()
    {
        GUIStyle styleCmdArea = new GUIStyle();

        styleCmdArea.normal.background = MakeTex(600, 80, Color.white);

        //	info area
        GUILayout.BeginArea(new Rect(10, 10, 600, 80), styleCmdArea);

        GUILayout.BeginHorizontal();
        GUILayout.Label("Platform:", GUILayout.Width(200));
        selectedPlatform = EditorGUILayout.Popup(selectedPlatform, listPlatform.ToArray());
        switch (selectedPlatform)
        {
        case 0:
            if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);
                LoadConfigXML(CommonPatcherData.cnfFN);
                LoadVersionXML();
            }
            else
            {
                GUILayout.EndHorizontal();
            }
            break;

        case 1:
            if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows)
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows);
                LoadConfigXML(CommonPatcherData.cnfFN);
                LoadVersionXML();
            }
            else
            {
                GUILayout.EndHorizontal();
            }
            break;
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label("Last Version : " + lastMajorVersion + "." + lastMinorVersion);
        GUILayout.Label(">>>");
        GUILayout.Label("New Version :");
        chkLastMajorVersion = GUILayout.TextField("" + chkLastMajorVersion);
        chkLastMinorVersion = GUILayout.TextField("" + chkLastMinorVersion);
        if (GUILayout.Button("Apply", GUILayout.Width(70)))
        {
            //	apply last version info and make folders and modify xml files.
            if (EditorUtility.DisplayDialog("You know that ?!", "This work just makes a folder for new version and change the text of last version. Later, you can make new resources for next patch when you press the button [Upload to repository].", "I see!!") == true)
            {
                SaveVersionXML();
            }
        }
        if (GUILayout.Button("Rollback", GUILayout.Width(70)))
        {
            string prevVersion = PatchVersion.getPreviousVersion(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN);
            int    prevMajor   = Convert.ToInt32(prevVersion.Split('_')[1]);
            int    prevMinor   = Convert.ToInt32(prevVersion.Split('_')[2]);

            string curVersion = verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes["LastVersion"].Value;
            int    curMajor   = Convert.ToInt32(curVersion.Split('_')[1]);
            int    curMinor   = Convert.ToInt32(curVersion.Split('_')[2]);

            if (EditorUtility.DisplayDialog("Caution!!", "Your last version(VER " + curMajor.ToString("D2") + "." + curMinor.ToString("D3") + ") data will remove complete. Are you sure?", "YES", "NO") == true)
            {
                //	check last version
                Debug.Log("Rollback to previous Version >> " + prevVersion);

                //	modify patch.xml file
                verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes["LastVersion"].Value = prevVersion;
                PatchVersion.removeVersionNode(verDoc, curMajor, curMinor);
                XmlTool.writeXml(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN, verDoc);

                //	remove assets.xml and files, and backup folder
                string _dn = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/VER_" + curMajor.ToString("D2") + "/" + curMinor.ToString("D3");
                Directory.Delete(_dn, true);

                //	latest folder change
                Directory.Delete(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo, true);
                Directory.Move(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo + "_VER_" + curMajor.ToString("D2") + "_" + curMinor.ToString("D3"),
                               CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo);

                lastMajorVersion    = prevMajor;
                chkLastMajorVersion = curMajor.ToString("D2");
                lastMinorVersion    = prevMinor;
                chkLastMinorVersion = curMinor.ToString("D3");
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Path :");
        CommonPatcherData.repoPath = GUILayout.TextField(CommonPatcherData.repoPath);
        //	read config file
        if (GUILayout.Button("Read", GUILayout.Width(100)))
        {
            LoadConfigXML(CommonPatcherData.cnfFN);
        }

        if (GUILayout.Button("Save", GUILayout.Width(100)))
        {
            cnfDoc.SelectSingleNode("/ToolConfig/Repository").Attributes ["path"].Value = CommonPatcherData.repoPath;
            SaveConfigXML(CommonPatcherData.cnfFN, cnfDoc);
            MakeLocalRepo();
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        //	command area
        GUILayout.BeginArea(new Rect(10, 100, 600, 140));
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Build AssetBundles", GUILayout.Width(150)))
        {
            ActiveABMWType = ABMWType.Build;
            BuildScript.BuildAssetBundles();
            return;
        }

        if (GUILayout.Button("unregisted assets", GUILayout.Width(150)))
        {
            ActiveABMWType = ABMWType.Unregisted;
            checkUnregistedAssets();
        }

        if (GUILayout.Button("All AssetBundles List", GUILayout.Width(150)))
        {
            ActiveABMWType = ABMWType.PatchInfo;
            checkRegistedAssets();
        }

        if (GUILayout.Button("Upload to repository", GUILayout.Width(150)))
        {
            if (EditorUtility.DisplayDialog("Upload !!", "Did you make a folder for new version?! If not, press the button [apply]. This will make a folder and change the version number for new version.", "I DID!!", "Ooops!") == true)
            {
                ActiveABMWType = ABMWType.Upload;
                BuildScript.BuildAssetBundles();

                //	compare all AssetBundles with "repoPath + lastVersionRepo"'s all files
                List <FileInfo> listNew     = new List <FileInfo>();
                List <FileInfo> listModify  = new List <FileInfo>();
                List <FileInfo> listRemoved = new List <FileInfo>();

                {
                    DirectoryInfo latestDir     = new DirectoryInfo(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget);
                    FileInfo []   latestABFiles = latestDir.GetFiles("*.*", SearchOption.AllDirectories);

                    DirectoryInfo buildDir   = new DirectoryInfo(BuildScript.GetAssetBundleBuildPath() + "/" + EditorUserBuildSettings.activeBuildTarget);
                    FileInfo []   newABFiles = buildDir.GetFiles("*.*", SearchOption.AllDirectories);

                    int newIndex = 0;
                    foreach (FileInfo fi in newABFiles)
                    {
                        int latestIndex = 0;
                        foreach (FileInfo latefi in latestABFiles)
                        {
                            int ret = compareFile(fi, latefi);
                            if (ret == 0)                              //	completely different
                            {
                            }
                            else if (ret == 1)                              //	same exactly
                            {
                                break;
                            }
                            else if (ret == 2)                               //	modified
                            {
                                listModify.Add(fi);
                                break;
                            }
                            latestIndex++;
                        }

                        if (latestIndex == latestABFiles.Length)
                        {
                            listNew.Add(fi);
                        }
                        newIndex++;
                    }

                    foreach (FileInfo latefiR in latestABFiles)
                    {
                        int chkIndex = 0;
                        foreach (FileInfo fiR in newABFiles)
                        {
                            if (fiR.Name == latefiR.Name)
                            {
                                break;
                            }
                            chkIndex++;
                        }
                        if (chkIndex == latestABFiles.Length)
                        {
                            listRemoved.Add(latefiR);
                        }
                    }
                }

                //	upload updated AssetBundles to the new repository.
                SaveAssetsXML(listNew, listModify, listRemoved);
            }
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        //	console area
        GUILayout.BeginArea(new Rect(10, 150, 600, 600));
        switch (ActiveABMWType)
        {
        case ABMWType.Build:

            break;

        case ABMWType.Unregisted:
            ListUnregistedAssets();
            break;

        case ABMWType.PatchInfo:
            ListRegistedAssets();
            break;

        case ABMWType.Upload:

            break;
        }
        GUILayout.EndArea();
    }
示例#7
0
 static void PerformBuild()
 {
     string[] scenes = { "Assets/_Scenes/Main.unity" };
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WebGL, BuildTarget.WebGL);
     BuildPipeline.BuildPlayer(scenes, "build/web", BuildTarget.WebGL, BuildOptions.None);
 }
示例#8
0
 static void SwitchPlatform()
 {
     Debug.Log("Switching BuildTarget");
     EditorUserBuildSettings.activeBuildTargetChanged += startBuildingPlayer;
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iOS);
 }
示例#9
0
        public bool Build(RuntimePlatform platform)
        {
            Debug.Log("Build");


            //対象プラットフォームごとに出力フォルダ作成
            string outputPath = Path.Combine(Config.OutputPath + "STYLY_ASSET", GetPlatformName(platform));

            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            bool switchResult = true;

            if (platform == RuntimePlatform.WindowsPlayer)
            {
                // プラットフォームとGraphic APIを常に同じにする
                switchResult = EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
                //PlayerSettings.colorSpace = ColorSpace.Gamma;
                PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.StandaloneWindows64, false);
                PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneWindows64, new UnityEngine.Rendering.GraphicsDeviceType[] {
                    //UnityEngine.Rendering.GraphicsDeviceType.Direct3D9,
                    UnityEngine.Rendering.GraphicsDeviceType.Direct3D11
                });
            }
            else if (platform == RuntimePlatform.Android)
            {
                switchResult = EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
                EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;

                //PlayerSettings.colorSpace = ColorSpace.Gamma;
                PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, false);
                PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, new UnityEngine.Rendering.GraphicsDeviceType[] {
                    UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2,
                    UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3
                });
            }
            else if (platform == RuntimePlatform.IPhonePlayer)
            {
                switchResult = EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS);
                //PlayerSettings.colorSpace = ColorSpace.Gamma;
                PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.iOS, false);
                PlayerSettings.SetGraphicsAPIs(BuildTarget.iOS, new UnityEngine.Rendering.GraphicsDeviceType[] {
                    UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2,
                    UnityEngine.Rendering.GraphicsDeviceType.Metal
                });
            }
            else if (platform == RuntimePlatform.OSXPlayer)
            {
                switchResult = EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneOSX);
                //PlayerSettings.colorSpace = ColorSpace.Gamma;
                PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.StandaloneOSX, false);
                PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneOSX, new UnityEngine.Rendering.GraphicsDeviceType[] {
                    UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2,
                    UnityEngine.Rendering.GraphicsDeviceType.Metal
                });
            }
            else if (platform == RuntimePlatform.WebGLPlayer)
            {
                switchResult = EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WebGL, BuildTarget.WebGL);
                //PlayerSettings.colorSpace = ColorSpace.Gamma;
                PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.WebGL, true);
                // web gl 1.0, web gl 2.0 がUnityEngine.Rendering.GraphicsDeviceTypeにないからautoで設定している
            }
            else if (platform == RuntimePlatform.WSAPlayerX86)
            {
                PlayerSettings.SetScriptingBackend(BuildTargetGroup.WSA, ScriptingImplementation.WinRTDotNET);
            }

            if (switchResult == false)
            {
                this.error = new Error("Can not switch Build target to " + GetPlatformName(platform) + ".\n"
                                       + "Make sure you have installed the target build module.\n"
                                       + "This tool requires Android, iOS, OSX, WebGL, Windows platforms.");
                return(false);
            }

            AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
            buildMap[0].assetBundleName = this.stylyGuid;
            buildMap[0].assetNames      = new string[] { this.renamedAssetPath };

            AssetBundleManifest buildResult = BuildPipeline.BuildAssetBundles(outputPath, buildMap, BuildAssetBundleOptions.ChunkBasedCompression, GetBuildTarget(platform));

            if (buildResult == null)
            {
                this.error = new Error("Buid asset bundle failed for platform " + GetPlatformName(platform));
                return(false);
            }
            return(true);
        }
示例#10
0
    public override void OnInspectorGUI()
    {
                #if UNITY_WEBPLAYER
        EditorGUILayout.HelpBox("Editing IOS Native Settings not available with web player platfo​rm. Please switch to any other platform under Build Settings menu", MessageType.Warning);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.Space();
        if (GUILayout.Button("Switch To IOS Platfo​rm", GUILayout.Width(150)))
        {
                        #if UNITY_5
            EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iOS);
                        #else
            EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iPhone);
                        #endif
        }
        EditorGUILayout.EndHorizontal();

        if (Application.isEditor)
        {
            return;
        }
                #endif



        GUI.changed = false;


        InstallOptions();



        GUI.SetNextControlName("toolbar");
        IOSNativeSettings.Instance.ToolbarIndex = GUILayout.Toolbar(IOSNativeSettings.Instance.ToolbarIndex, ToolbarHeaders, new GUILayoutOption[] { GUILayout.Height(25f) });


        switch (IOSNativeSettings.Instance.ToolbarIndex)
        {
        case 0:
            APISettings();
            EditorGUILayout.Space();
            MoreActions();
            EditorGUILayout.Space();
            AboutGUI();
            break;

        case 1:
            BillingSettings();
            break;

        case 2:
            GameCenterSettings();
            break;

        case 3:
            CameraAndGallery();
            ReplayKitSetings();
            ThirdPartySettings();
            break;
        }


        if (GUI.changed)
        {
            DirtyEditor();
        }
    }
        public static BuildPipelineCodes BuildAssetBundles(BuildInput input, BuildSettings settings, BuildCompression compression, string outputFolder, out BuildResultInfo result, object callbackUserData = null, bool useCache = true)
        {
            var buildTimer = new Stopwatch();

            buildTimer.Start();

            if (ProjectValidator.HasDirtyScenes())
            {
                result = new BuildResultInfo();
                buildTimer.Stop();
                BuildLogger.LogError("Build Asset Bundles failed in: {0:c}. Error: {1}.", buildTimer.Elapsed, BuildPipelineCodes.UnsavedChanges);
                return(BuildPipelineCodes.UnsavedChanges);
            }

            var exitCode = BuildPipelineCodes.Success;

            result = new BuildResultInfo();

            AssetDatabase.SaveAssets();

            // TODO: Until new AssetDatabaseV2 is online, we need to switch platforms
            EditorUserBuildSettings.SwitchActiveBuildTarget(settings.group, settings.target);

            var stepCount = BundleDependencyStep.StepCount + BundlePackingStep.StepCount + BundleWritingStep.StepCount;

            using (var progressTracker = new BuildProgressTracker(stepCount))
            {
                using (var buildCleanup = new BuildStateCleanup(true, kTempBundleBuildPath))
                {
                    BuildDependencyInfo buildInfo;
                    exitCode = BundleDependencyStep.Build(input, settings, out buildInfo, useCache, progressTracker);
                    if (exitCode < BuildPipelineCodes.Success)
                    {
                        return(exitCode);
                    }

                    if (PostBuildDependency != null)
                    {
                        exitCode = PostBuildDependency.Invoke(buildInfo, callbackUserData);
                        if (exitCode < BuildPipelineCodes.Success)
                        {
                            return(exitCode);
                        }
                    }

                    BuildWriteInfo writeInfo;
                    exitCode = BundlePackingStep.Build(buildInfo, out writeInfo, useCache, progressTracker);
                    if (exitCode < BuildPipelineCodes.Success)
                    {
                        return(exitCode);
                    }

                    if (PostBuildPacking != null)
                    {
                        exitCode = PostBuildPacking.Invoke(buildInfo, writeInfo, callbackUserData);
                        if (exitCode < BuildPipelineCodes.Success)
                        {
                            return(exitCode);
                        }
                    }

                    exitCode = BundleWritingStep.Build(settings, compression, outputFolder, buildInfo, writeInfo, out result, useCache, progressTracker);
                    if (exitCode < BuildPipelineCodes.Success)
                    {
                        return(exitCode);
                    }

                    if (PostBuildWriting != null)
                    {
                        exitCode = PostBuildWriting.Invoke(buildInfo, writeInfo, result, callbackUserData);
                        if (exitCode < BuildPipelineCodes.Success)
                        {
                            return(exitCode);
                        }
                    }
                }
            }

            buildTimer.Stop();
            if (exitCode >= BuildPipelineCodes.Success)
            {
                BuildLogger.Log("Build Asset Bundles successful in: {0:c}", buildTimer.Elapsed);
            }
            else if (exitCode == BuildPipelineCodes.Canceled)
            {
                BuildLogger.LogWarning("Build Asset Bundles canceled in: {0:c}", buildTimer.Elapsed);
            }
            else
            {
                BuildLogger.LogError("Build Asset Bundles failed in: {0:c}. Error: {1}.", buildTimer.Elapsed, exitCode);
            }

            return(exitCode);
        }
示例#12
0
    // xxx/Unity.exe -quit -batchmode -executeMethod CommandBuild.BuildAndroid
    public static void BuildAPK(bool release = true, string version = "0.0.1")
    {
        Debug.Log("开始 Build( Android )");
#if !Unity_Android
        Debug.Log("切换到 Android平台");
        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
#endif
        EditorUserBuildSettings.androidBuildSystem           = AndroidBuildSystem.Gradle;
        EditorUserBuildSettings.exportAsGoogleAndroidProject = false;
        PlayerSettings.defaultInterfaceOrientation           = UIOrientation.Portrait;
        PlayerSettings.allowedAutorotateToLandscapeLeft      = true;
        PlayerSettings.allowedAutorotateToLandscapeRight     = true;
        PlayerSettings.allowedAutorotateToPortrait           = false;
        PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
        PlayerSettings.keyaliasPass  = "******";
        PlayerSettings.keystorePass  = "******";
        PlayerSettings.bundleVersion = version;
        // build option
        BuildOptions opt = BuildOptions.None;
        System.DateTime.Now.Date.ToString();

        string export = "../" + Application.productName + "_" + PlayerSettings.bundleVersion.Replace('.', '_') + "_" + System.DateTime.Now.ToString("yyyyMMddHHmmss");
        //+ ".apk";
        if (release)
        {
            export += "_release.apk";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, "");
        }
        else
        {
            export += "_debug.apk";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, "DEBUG_BUILD");
        }

        bool isDebug = false;
        //export 参数 导出目录
        var args  = System.Environment.GetCommandLineArgs();
        int index = Array.IndexOf(args, "-export");
        if (-1 != index)
        {
            export = args[index + 1];
        }
        Debug.Log("##### Export 路径 : " + export);

        index   = Array.IndexOf(args, "-debug");
        isDebug = (-1 != index);
        Debug.Log("##### Debug 版本 : " + isDebug);


        if (isDebug)
        {
            opt |= BuildOptions.Development | BuildOptions.ConnectWithProfiler | BuildOptions.AllowDebugging;
        }

        //opt |= BuildOptions.Il2CPP;
        //PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);

        //opt |= BuildOptions.AcceptExternalModificationsToPlayer;
        var           scenes = GetScenes();
        DirectoryInfo dir    = new DirectoryInfo(export);
        if (dir.Exists)
        {
            dir.Delete(true);
        }
        BuildReport report = BuildPipeline.BuildPlayer(scenes, export, BuildTarget.Android, opt);

        // error check
        if (report.summary.result == BuildResult.Succeeded)
        {
            Debug.Log("Build( Android ) 成功.");
        }
        else
        {
            Debug.Log("Build( Android ) 失败!");
            Debug.LogError(report.summary.result.ToString());
        }
    }
示例#13
0
    // xxx/Unity.exe -quit -batchmode -executeMethod CommandBuild.BuildAndroid
    public static void BuildAndroid()
    {
        Debug.Log("开始 Build( Android )");
#if !Unity_Android
        Debug.Log("切换到 Android平台");
        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
#endif
        EditorUserBuildSettings.androidBuildSystem           = AndroidBuildSystem.Gradle;
        EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
        PlayerSettings.defaultInterfaceOrientation           = UIOrientation.Portrait;
        PlayerSettings.allowedAutorotateToLandscapeLeft      = true;
        PlayerSettings.allowedAutorotateToLandscapeRight     = true;
        PlayerSettings.allowedAutorotateToPortrait           = false;
        PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
        // build option
        BuildOptions opt     = BuildOptions.None;
        string       export  = "../Output";
        bool         isDebug = false;
        //export 参数 导出目录
        var args  = System.Environment.GetCommandLineArgs();
        int index = Array.IndexOf(args, "-export");
        if (-1 != index)
        {
            export = args[index + 1];
        }
        Debug.Log("##### Export 路径 : " + export);

        index   = Array.IndexOf(args, "-debug");
        isDebug = (-1 != index);
        Debug.Log("##### Debug 版本 : " + isDebug);

        if (isDebug)
        {
            PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, "DEBUG_BUILD");
            opt |= BuildOptions.Development | BuildOptions.ConnectWithProfiler | BuildOptions.AllowDebugging;
        }
        else
        {
        }

        //opt |= BuildOptions.Il2CPP;
        opt |= BuildOptions.AcceptExternalModificationsToPlayer;
        var           scenes = GetScenes();
        DirectoryInfo dir    = new DirectoryInfo(export);
        if (dir.Exists)
        {
            dir.Delete(true);
        }
        BuildReport report = BuildPipeline.BuildPlayer(scenes, export, BuildTarget.Android, opt);

        // error check
        if (report.summary.result == BuildResult.Succeeded)
        {
            Debug.Log("Build( Android ) 成功.");
        }
        else
        {
            Debug.Log("Build( Android ) 失败!");
            Debug.LogError(report.summary.result.ToString());
        }
    }
示例#14
0
 public static void WebGL()
 {
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WebGL, BuildTarget.WebGL);
 }
示例#15
0
 static void Apply()
 {
     PlayerSettings.bundleVersion = ConstantData.g_version;
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows);
     EditorWindow.GetWindow(typeof(NDBuildVersionPC));
 }
示例#16
0
        public OpenVRRecommendedSettings()
        {
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Virtual Reality Supported with OpenVR",
                skipCheckFunc    = () => !VIUSettingsEditor.canSupportOpenVR,
                currentValueFunc = () => VIUSettingsEditor.supportOpenVR,
                setValueFunc     = v => VIUSettingsEditor.supportOpenVR = v,
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <BuildTarget>()
            {
                settingTitle     = "Build Target",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => EditorUserBuildSettings.activeBuildTarget,
                setValueFunc     = v =>
                {
#if UNITY_2017_1_OR_NEWER
                    EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, v);
#elif UNITY_5_6_OR_NEWER
                    EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, v);
#else
                    EditorUserBuildSettings.SwitchActiveBuildTarget(v);
#endif
                },
                recommendedValue = BuildTarget.StandaloneWindows64,
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Load Binding Config on Start",
                skipCheckFunc    = () => !VIUSettingsEditor.supportOpenVR,
                toolTip          = "You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.autoLoadBindingConfigOnStart,
                setValueFunc     = v => { VIUSettings.autoLoadBindingConfigOnStart = v; },
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Binding Interface Switch",
                skipCheckFunc    = () => !VIUSettingsEditor.supportOpenVR,
                toolTip          = VIUSettings.BIND_UI_SWITCH_TOOLTIP + " You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.enableBindingInterfaceSwitch,
                setValueFunc     = v => { VIUSettings.enableBindingInterfaceSwitch = v; },
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "External Camera Switch",
                skipCheckFunc    = () => !VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportOpenVR,
                toolTip          = VIUSettings.EX_CAM_UI_SWITCH_TOOLTIP + " You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.enableExternalCameraSwitch,
                setValueFunc     = v => { VIUSettings.enableExternalCameraSwitch = v; },
                recommendedValue = true,
            });

#if UNITY_5_3
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Stereoscopic Rendering",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyVR,
                currentValueFunc = () => PlayerSettings.stereoscopic3D,
                setValueFunc     = v => PlayerSettings.stereoscopic3D = v,
                recommendedValue = false,
            });
#endif

#if UNITY_5_3 || UNITY_5_4
            Add(new VIUVersionCheck.RecommendedSetting <RenderingPath>()
            {
                settingTitle        = "Rendering Path",
                skipCheckFunc       = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyVR,
                recommendBtnPostfix = "required for MSAA",
                currentValueFunc    = () => PlayerSettings.renderingPath,
                setValueFunc        = v => PlayerSettings.renderingPath = v,
                recommendedValue    = RenderingPath.Forward,
            });

            // Unity 5.3 doesn't have SplashScreen for VR
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Show Unity Splash Screen",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !InternalEditorUtility.HasPro() || !VIUSettingsEditor.supportAnyVR,
                currentValueFunc = () => PlayerSettings.showUnitySplashScreen,
                setValueFunc     = v => PlayerSettings.showUnitySplashScreen = v,
                recommendedValue = false,
            });
#endif

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "GPU Skinning",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyVR,
                currentValueFunc = () => PlayerSettings.gpuSkinning,
                setValueFunc     = v =>
                {
                    if (VIUSettingsEditor.supportAnyAndroidVR)
                    {
                        VIUSettingsEditor.SetGraphicsAPI(BuildTarget.Android, GraphicsDeviceType.OpenGLES3);
                    }
                    PlayerSettings.gpuSkinning = v;
                },
                recommendedValueFunc = () => !VIUSettingsEditor.supportWaveVR,
            });

            Add(new VIUVersionCheck.RecommendedSetting <Vector2>()
            {
                settingTitle     = "Default Screen Size",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => new Vector2(PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight),
                setValueFunc     = v => { PlayerSettings.defaultScreenWidth = (int)v.x; PlayerSettings.defaultScreenHeight = (int)v.y; },
                recommendedValue = new Vector2(1024f, 768f),
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Run In Background",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.runInBackground,
                setValueFunc     = v => PlayerSettings.runInBackground = v,
                recommendedValue = true,
            });

#if !UNITY_2019_2_OR_NEWER
            Add(new VIUVersionCheck.RecommendedSetting <ResolutionDialogSetting>()
            {
                settingTitle     = "Display Resolution Dialog",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.displayResolutionDialog,
                setValueFunc     = v => PlayerSettings.displayResolutionDialog = v,
                recommendedValue = ResolutionDialogSetting.HiddenByDefault,
            });
#endif

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Resizable Window",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.resizableWindow,
                setValueFunc     = v => PlayerSettings.resizableWindow = v,
                recommendedValue = true,
            });

#if !UNITY_2018_1_OR_NEWER
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Default Is Fullscreen",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.defaultIsFullScreen,
                setValueFunc     = v => PlayerSettings.defaultIsFullScreen = v,
                recommendedValue = false,
            });

            Add(new VIUVersionCheck.RecommendedSetting <D3D11FullscreenMode>()
            {
                settingTitle     = "D3D11 Fullscreen Mode",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.d3d11FullscreenMode,
                setValueFunc     = v => PlayerSettings.d3d11FullscreenMode = v,
                recommendedValue = D3D11FullscreenMode.FullscreenWindow,
            });
#else
            Add(new VIUVersionCheck.RecommendedSetting <FullScreenMode>()
            {
                settingTitle     = "Fullscreen Mode",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.fullScreenMode,
                setValueFunc     = v => PlayerSettings.fullScreenMode = v,
                recommendedValue = FullScreenMode.FullScreenWindow,
            });
#endif

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Visible In Background",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.visibleInBackground,
                setValueFunc     = v => PlayerSettings.visibleInBackground = v,
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <ColorSpace>()
            {
                settingTitle        = "Color Space",
                skipCheckFunc       = () => (VRModule.isSteamVRPluginDetected && VIUSettingsEditor.activeBuildTargetGroup == BuildTargetGroup.Standalone) || !VIUSettingsEditor.supportAnyVR,
                recommendBtnPostfix = "requires reloading scene",
                currentValueFunc    = () => PlayerSettings.colorSpace,
                setValueFunc        = v =>
                {
                    if (VIUSettingsEditor.supportAnyAndroidVR)
                    {
                        VIUSettingsEditor.SetGraphicsAPI(BuildTarget.Android, GraphicsDeviceType.OpenGLES3);
                    }
                    PlayerSettings.colorSpace = v;
                },
                recommendedValue = ColorSpace.Linear,
            });
#if VIU_STEAMVR_2_0_0_OR_NEWER
            Add(new RecommendedSteamVRInputFileSettings());
#endif
        }
 static void PerformiOSBuild()
 {
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iOS);
     BuildPipeline.BuildPlayer(GetScenePaths(), "Builds/iOS", BuildTarget.iOS, BuildOptions.None);
 }
示例#18
0
    //导出xcode工程
    public static void Build()
    {
        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS);
        string buildType = string.Empty, platform = string.Empty, subPlatform = string.Empty, versionName = string.Empty, versionCode = string.Empty,
               package = string.Empty, appName = string.Empty, cdn = string.Empty, plugins = string.Empty, splash = string.Empty, icon = string.Empty,
               xcodeOut = string.Empty;

        foreach (string arg in Environment.GetCommandLineArgs())
        {
            if (arg.StartsWith("appName", StringComparison.OrdinalIgnoreCase))
            {
                appName = arg.Split('=')[1];
                PlayerSettings.productName = appName;
                PlayerSettings.iOS.applicationDisplayName = appName;
            }
            else if (arg.StartsWith("package", StringComparison.OrdinalIgnoreCase))
            {
                package = arg.Split('=')[1];
                PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, package);
            }
            else if (arg.StartsWith("versionName", StringComparison.OrdinalIgnoreCase))
            {
                versionName = arg.Split('=')[1];
                PlayerSettings.bundleVersion = versionName;
            }
            else if (arg.StartsWith("versionCode", StringComparison.OrdinalIgnoreCase))
            {
                versionCode = arg.Split('=')[1];
                PlayerSettings.iOS.buildNumber = versionCode;
            }
            else if (arg.StartsWith("buildType", StringComparison.OrdinalIgnoreCase))
            {
                buildType = arg.Split('=')[1];
            }
            else if (arg.StartsWith("platform", StringComparison.OrdinalIgnoreCase))
            {
                platform = arg.Split('=')[1];
            }
            else if (arg.StartsWith("subPlatform", StringComparison.OrdinalIgnoreCase))
            {
                subPlatform = arg.Split('=')[1];
            }
            else if (arg.StartsWith("plugins", StringComparison.OrdinalIgnoreCase))
            {
                plugins = arg.Split('=')[1];
            }
            else if (arg.StartsWith("splash", StringComparison.OrdinalIgnoreCase))
            {
                splash = arg.Split('=')[1];
            }
            else if (arg.StartsWith("icon", StringComparison.OrdinalIgnoreCase))
            {
                icon = arg.Split('=')[1];
            }
            else if (arg.StartsWith("url", StringComparison.OrdinalIgnoreCase))
            {
                cdn = arg.Split('=')[1];
            }
            else if (arg.StartsWith("xcodeOut", StringComparison.OrdinalIgnoreCase))
            {
                xcodeOut = arg.Split('=')[1];
            }
        }

        PlayerSettings.iOS.appleEnableAutomaticSigning = false;
        // SetAutomaticallyAddCapabilities(false);

        // PlayerSettings.iOS.targetDevice = iOSTargetDevice.iPhoneAndiPad; //目标设备
        // PlayerSettings.iOS.targetOSVersionString = "8.0"; //最低iOS版本要求
        // PlayerSettings.iOS.statusBarStyle = iOSStatusBarStyle.Default;
        // PlayerSettings.statusBarHidden = true;
        // PlayerSettings.allowedAutorotateToLandscapeLeft = true;
        // PlayerSettings.allowedAutorotateToLandscapeRight = true;
        // PlayerSettings.allowedAutorotateToPortrait = false;
        // PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
        // PlayerSettings.accelerometerFrequency = 30;

        PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.iOS, ApiCompatibilityLevel.NET_Standard_2_0);
        // PlayerSettings.SetPropertyInt("ScriptingBackend", (int)ScriptingImplementation.IL2CPP, BuildTargetGroup.iOS);
        // PlayerSettings.SetPropertyInt("Architecture", (int)iOSTargetDevice.iPhoneAndiPad, BuildTargetGroup.iOS); //支持armv7和arm64
        PlayerSettings.SetScriptingBackend(BuildTargetGroup.iOS, ScriptingImplementation.IL2CPP);
        // PlayerSettings.SetArchitecture(BuildTargetGroup.iOS, 2);
        // PlayerSettings.iOS.requiresPersistentWiFi = true;


        BuildPipeline.BuildPlayer(GetBuildScenes(), xcodeOut, BuildTarget.iOS, BuildOptions.None);
    }
示例#19
0
    public static void Build(string appName, string packageId, string version, BuildTarget target, BuildOptions options)
    {
        string ProjPath   = Application.dataPath.Replace("/Assets", "");
        string target_dir = ProjPath + BatchBuildConfig.TARGET_DIR;

        string           locationPath = null;
        BuildTargetGroup targetGroup  = BuildTargetGroup.Unknown;

        if (target == BuildTarget.Android)
        {
            locationPath = target_dir + "/" + appName + ".apk";
            targetGroup  = BuildTargetGroup.Android;
        }
        else if (target == BatchBuild.BuildTarget_iOS)
        {
            locationPath = target_dir;
            targetGroup  = BatchBuild.BuildTargetGroup_iOS;
        }
        else if (target == BuildTarget.WP8Player)
        {
            locationPath = target_dir;
            targetGroup  = BuildTargetGroup.WP8;
        }
        else
        {
            Debug.LogError("No plan to support this platform yet.");
            return;
        }

        PlayerSettings.bundleIdentifier = packageId;
        PlayerSettings.bundleVersion    = version;
        for (int i = 0; i < BatchBuildConfig.DEFINE_MACRO.Length; i++)
        {
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, BatchBuildConfig.DEFINE_MACRO);
        }

        // Clean previous build
        try {
            if (Directory.Exists(target_dir))
            {
                Directory.Delete(target_dir, true);
            }

            Directory.CreateDirectory(target_dir);
        } catch (Exception ex) {
            Debug.LogError(ex.Message);
        }

        // switch active build target
        string strTarget = EditorUserBuildSettings.activeBuildTarget.ToString();

        if (!strTarget.Equals(target.ToString()))
        {
            EditorUserBuildSettings.SwitchActiveBuildTarget(target);
        }

        // build pipeline
        string res = BuildPipeline.BuildPlayer(BatchBuildMenu.SCENES, locationPath, target, options);

        if (res.Length > 0)
        {
            throw new Exception("BuildPlayer failure: " + res);
            return;
        }
    }
示例#20
0
        public static void PerformBuild(BuildInfo buildInfo)
        {
            BuildTargetGroup buildTargetGroup = GetGroup(buildInfo.BuildTarget);
            string           oldBuildSymbols  = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);

            if (!string.IsNullOrEmpty(oldBuildSymbols))
            {
                if (buildInfo.HasConfigurationSymbol())
                {
                    buildInfo.AppendSymbols(BuildInfo.RemoveConfigurationSymbols(oldBuildSymbols));
                }
                else
                {
                    buildInfo.AppendSymbols(oldBuildSymbols.Split(';'));
                }
            }

            if ((buildInfo.BuildOptions & BuildOptions.Development) == BuildOptions.Development)
            {
                if (!buildInfo.HasConfigurationSymbol())
                {
                    buildInfo.AppendSymbols(BuildSymbolDebug);
                }
            }

            if (buildInfo.HasAnySymbols(BuildSymbolDebug))
            {
                buildInfo.BuildOptions |= BuildOptions.Development | BuildOptions.AllowDebugging;
            }

            if (buildInfo.HasAnySymbols(BuildSymbolRelease))
            {
                //Unity automatically adds the DEBUG symbol if the BuildOptions.Development flag is
                //specified. In order to have debug symbols and the RELEASE symbols we have to
                //inject the symbol Unity relies on to enable the /debug+ flag of csc.exe which is "DEVELOPMENT_BUILD"
                buildInfo.AppendSymbols("DEVELOPMENT_BUILD");
            }

            BuildTarget      oldBuildTarget      = EditorUserBuildSettings.activeBuildTarget;
            BuildTargetGroup oldBuildTargetGroup = GetGroup(oldBuildTarget);

            EditorUserBuildSettings.SwitchActiveBuildTarget(buildTargetGroup, buildInfo.BuildTarget);

            WSAUWPBuildType?oldWSAUWPBuildType = EditorUserBuildSettings.wsaUWPBuildType;

            if (buildInfo.WSAUWPBuildType.HasValue)
            {
                EditorUserBuildSettings.wsaUWPBuildType = buildInfo.WSAUWPBuildType.Value;
            }

            var oldWSAGenerateReferenceProjects = EditorUserBuildSettings.wsaGenerateReferenceProjects;

            if (buildInfo.WSAGenerateReferenceProjects.HasValue)
            {
                EditorUserBuildSettings.wsaGenerateReferenceProjects = buildInfo.WSAGenerateReferenceProjects.Value;
            }

            var oldColorSpace = PlayerSettings.colorSpace;

            if (buildInfo.ColorSpace.HasValue)
            {
                PlayerSettings.colorSpace = buildInfo.ColorSpace.Value;
            }

            if (buildInfo.BuildSymbols != null)
            {
                PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, buildInfo.BuildSymbols);
            }

            string buildError = "Error";

            try
            {
                VerifyWsaUwpSdkIsInstalled(EditorUserBuildSettings.wsaUWPSDK);

                // For the WSA player, Unity builds into a target directory.
                // For other players, the OutputPath parameter indicates the
                // path to the target executable to build.
                if (buildInfo.BuildTarget == BuildTarget.WSAPlayer)
                {
                    Directory.CreateDirectory(buildInfo.OutputDirectory);
                }

                OnPreProcessBuild(buildInfo);
                buildError = BuildPipeline.BuildPlayer(
                    buildInfo.Scenes.ToArray(),
                    buildInfo.OutputDirectory,
                    buildInfo.BuildTarget,
                    buildInfo.BuildOptions);

                if (buildError.StartsWith("Error"))
                {
                    throw new Exception(buildError);
                }
            }
            finally
            {
                OnPostProcessBuild(buildInfo, buildError);

                if (buildInfo.BuildTarget == BuildTarget.WSAPlayer && EditorUserBuildSettings.wsaGenerateReferenceProjects)
                {
                    UwpProjectPostProcess.Execute(buildInfo.OutputDirectory);
                }

                PlayerSettings.colorSpace = oldColorSpace;
                PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, oldBuildSymbols);

                if (oldWSAUWPBuildType.HasValue)
                {
                    EditorUserBuildSettings.wsaUWPBuildType = oldWSAUWPBuildType.Value;
                }

                EditorUserBuildSettings.wsaGenerateReferenceProjects = oldWSAGenerateReferenceProjects;

                EditorUserBuildSettings.SwitchActiveBuildTarget(oldBuildTargetGroup, oldBuildTarget);
            }
        }
示例#21
0
        public override void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();
            DrawDefaultInspector();
            if (EditorGUI.EndChangeCheck())
            {
                _energyBar.bundleId = _energyBar.author + "." + _energyBar.name;
            }

            if (GUILayout.Button("Export"))
            {
                string path = EditorUtility.SaveFilePanel("Save Custom Energy Bar", "", _energyBar.name + ".energy", "energy");

                if (!string.IsNullOrWhiteSpace(path))
                {
                    string fileName   = Path.GetFileName(path);
                    string folderPath = Path.GetDirectoryName(path);

                    foreach (EventManager em in _energyBar.GetComponentsInChildren <EventManager>())
                    {
                        em.SerializeEvents();
                    }
                    _deactivatedGos        = new List <GameObject>();
                    _activatedGos          = new List <GameObject>();
                    _energyBar.batteryBars = new List <GameObject>();
                    _energyBar.standardBar = null;
                    _foundStandardBar      = false;
                    DeactivateBatteryBars(_energyBar.transform);
                    if (!_foundStandardBar)
                    {
                        ReactivateBars();
                        EditorUtility.DisplayDialog("Export Failed!", "StandardBar GameObject could not be found.", "OK");
                        return;
                    }

                    Selection.activeObject = _energyBar.gameObject;
                    EditorUtility.SetDirty(_energyBar);
                    EditorSceneManager.MarkSceneDirty(_energyBar.gameObject.scene);
                    EditorSceneManager.SaveScene(_energyBar.gameObject.scene);

                    PrefabUtility.CreatePrefab("Assets/_CustomEnergyBar.prefab", _energyBar.gameObject as GameObject);
                    AssetBundleBuild assetBundleBuild = default(AssetBundleBuild);
                    assetBundleBuild.assetNames = new string[] {
                        "Assets/_CustomEnergyBar.prefab"
                    };
                    assetBundleBuild.assetBundleName = fileName;

                    BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
                    BuildTarget      buildTarget      = EditorUserBuildSettings.activeBuildTarget;

                    BuildPipeline.BuildAssetBundles(Application.temporaryCachePath, new AssetBundleBuild[] { assetBundleBuild }, BuildAssetBundleOptions.ForceRebuildAssetBundle, buildTarget);
                    EditorPrefs.SetString("currentBuildingAssetBundlePath", folderPath);
                    EditorUserBuildSettings.SwitchActiveBuildTarget(buildTargetGroup, buildTarget);

                    AssetDatabase.DeleteAsset("Assets/_CustomEnergyBar.prefab");

                    if (File.Exists(path))
                    {
                        bool isDirectory = (File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory;
                        if (!isDirectory)
                        {
                            File.Delete(path);
                        }
                    }

                    File.Move(Path.Combine(Application.temporaryCachePath, fileName), path);
                    AssetDatabase.Refresh();
                    EditorUtility.DisplayDialog("Export Successful!", "Export Successful!", "OK");

                    ReactivateBars();
                }
                else
                {
                    EditorUtility.DisplayDialog("Export Failed!", "Save path is invalid.", "OK");
                }
            }
        }
        public void Show()
        {
            string errorMessage = null;

            var buildTarget   = EditorUserBuildSettings.activeBuildTarget;
            var scenes        = EditorBuildSettings.scenes.Select(s => s.path).ToArray();
            var buildLocation = EditorUserBuildSettings.GetBuildLocation(buildTarget);

            if (buildTarget == BuildTarget.StandaloneLinuxUniversal || buildTarget == BuildTarget.StandaloneOSXIntel64)
            {
                OnFailure("Unsupported build target.");
                return;
            }

            if (string.IsNullOrEmpty(buildLocation))
            {
                buildLocation = EditorUtility.SaveFilePanel("Select build location:", "", "", "");
                EditorUserBuildSettings.SetBuildLocation(buildTarget, buildLocation);
                return;
            }

            bool buildDirectoryExists = Directory.Exists(Path.GetDirectoryName(buildLocation));
            bool buildExists          = File.Exists(buildLocation);

            GUILayout.Label(_selectedApp.Value.Name, EditorStyles.centeredGreyMiniLabel);

            if (GUILayout.Button(new GUIContent("←", "Change application"), GUILayout.Width(40)))
            {
                if (OnChangeApp != null)
                {
                    OnChangeApp();
                }
            }
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label("\n                               * Building *\n" +
                                " The project will be built with the following settings. \n", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Label("Target: " + buildTarget.ToString());
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Location: " + buildLocation, buildLocation), GUILayout.MaxWidth(300));
                if (GUILayout.Button(new GUIContent("Change", "Change build location")))
                {
                    buildLocation = EditorUtility.SaveFilePanel("Select build location:", "", "", "");
                    EditorUserBuildSettings.SetBuildLocation(buildTarget, buildLocation);
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label("Scenes: ", EditorStyles.boldLabel);
                if (GUILayout.Button(new GUIContent("Edit Scenes", "Button open Build Settings window."), GUILayout.Width(120)))
                {
                    EditorWindow.GetWindow(System.Type.GetType("UnityEditor.BuildPlayerWindow,UnityEditor"));
                }
            }
            EditorGUILayout.EndHorizontal();
            for (int i = 0; i < scenes.Length; i++)
            {
                GUILayout.Label(i + ". " + scenes[i]);
            }
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                if (!_buildExecuted && GUILayout.Button(new GUIContent("Build", "Build a new version"), GUILayout.Width(150)))
                {
                    UnityEngine.Debug.Log("Building the player");
                    errorMessage = BuildPipeline.BuildPlayer(scenes, buildLocation, buildTarget, BuildOptions.None);

                    _buildExecuted = true;

                    if (!string.IsNullOrEmpty(errorMessage))
                    {
                        if (OnFailure != null)
                        {
                            OnFailure(errorMessage);
                        }
                    }
                    else
                    {
                        if (OnSuccess != null)
                        {
                            OnSuccess();
                        }
                    }
                }
                GUILayout.FlexibleSpace();

                /*
                 * if (buildDirectoryExists && buildExists && GUILayout.Button(new GUIContent("Skip", "Use the last build")))
                 * {
                 *  if (OnSuccess != null)
                 *  {
                 *      OnSuccess();
                 *  }
                 * }
                 */
            }
            EditorGUILayout.EndHorizontal();
        }
示例#23
0
 public static void SwitchToIOS()
 {
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS);
 }
示例#24
0
	// BUILD STEPS:

	static bool InitializeBuild ()
	{
		try {

			HeadlessCallbacks.InvokeCallbacks ("HeadlessBuildBefore");

            if (manualBuild || debugBuild)
            {
                // Hide progress window if visible
                HeadlessProgress.Hide();
            }

            if (manualBuild) {
				// If this is a manual build, store the currently selected build target
				// so we can revert to that later
				regularTarget = EditorUserBuildSettings.activeBuildTarget;
				regularTargetGroup = BuildPipeline.GetBuildTargetGroup (regularTarget);
			}

			if (!batchBuild) {
				// Get the current build path for regular builds so we can use it as a default value
				try {
					buildPath = Directory.GetParent (EditorUserBuildSettings.GetBuildLocation (EditorUserBuildSettings.activeBuildTarget)).ToString ();
				} catch (Exception e) {
					if (e.Message.Equals ("never")) {
						// These errors are no problem at all, so we use this workaround to supress them
						UnityEngine.Debug.LogWarning (e);
					}
				}
			}

			if (manualBuild || debugBuild) {

                if (EditorApplication.isCompiling)
                {
                    EditorUtility.DisplayDialog("Headless Builder",
                        "You can't build while the editor is compiling.\n\n" +
                        "Please wait for compilation to finish and try again.", "OK");

                    return false;
                }

                if (EditorApplication.isPlaying)
                {
                    EditorUtility.DisplayDialog("Headless Builder",
                        "You can't build while the editor is in play mode.\n\n" +
                        "Please exit play mode by clicking the stop button and try again.", "OK");

                    return false;
                }

				if (headlessSettings.valueDummy && !headlessSettings.valueSkipConfirmation) {

					if (!EditorUtility.DisplayDialog ("Headless Builder",
						"You have enabled a feature that replaces your visual and audio assets with dummies.\n\n" +
						"This will greatly enhance your build's performance,\n" + 
						"but will also force Unity to re-import all assets, which might take a long time.\n\n" + 
						"Are you sure you want to continue?", "Yes", "Cancel")) {
					
						return false;

					}
				}

				if (headlessSettings.valueGI && 
					UnityEditor.EditorSettings.serializationMode != UnityEditor.SerializationMode.ForceText) {

					if (EditorUtility.DisplayDialog ("Headless Builder",
						"You have enabled a feature that requires Unity's serialization mode to be set to 'Force Text',\n" + 
						"but your current serialization mode is something else.\n\n" +
						"Should we change the serialization mode for you?\n" + 
						"This might take a long time.\n\n" + 
						"If you choose to not change the serialization mode, the relevant features will be skipped.", "Change to 'Force Text'", "Ignore")) {

						UnityEditor.EditorSettings.serializationMode = UnityEditor.SerializationMode.ForceText;

					}
				}


				// If this is a manual build, make sure the scene is saved, because we'll reload it later
				EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo ();

				for (int i = 0; i < EditorSceneManager.sceneCount; i++) {
					if (EditorSceneManager.GetSceneAt (i).isDirty) {
						UnityEngine.Debug.LogError ("Any changes to scenes must be changed before doing a headless build\nHeadless Builder (v" + Headless.version + ")");
						return false;
					}
				}

                if (manualBuild)
                {
                    // Get the build path used for previous headless builds and use it as a default, if there is any
                    bool foundPreviousPath = false;
                    if (headlessSettings.buildPath != null && headlessSettings.buildPath.Length > 3)
                    {
                        if (Directory.Exists(headlessSettings.buildPath))
                        {
                            buildPath = headlessSettings.buildPath;
                            foundPreviousPath = true;
                        }
                    }

                    // Ask output folder
                    if (!foundPreviousPath || !headlessSettings.valueRememberPath)
                    {
                        buildPath = EditorUtility.SaveFolderPanel("Choose Destination For Headless Build (" + headlessSettings.profileName + ")", buildPath, "");
                        if (buildPath.Length == 0)
                        {
                            UnityEngine.Debug.LogError("You must choose a destination path for the headless build\nHeadless Builder (v" + Headless.version + ")");
                            return false;
                        }
                    }
                }

			}

			// Set the build number
			headlessSettings.buildPath = buildPath;
            if (!debugBuild)
            {
                if (headlessSettings.buildID < int.MaxValue - 128)
                {
                    headlessSettings.buildID++;
                }
            }

            if (manualBuild || debugBuild)
            {
                // If this is a manual build, show the progress bar window
                progressWindow = HeadlessProgress.Init();
            }

            SetProgress ("INIT");

			return true;
		} catch (Exception e) {
			UnityEngine.Debug.LogError (e);
			return false;
		}

	}
示例#25
0
    public void OnGUI()
    {
        var resourcePath = GetResourcePath();
        var logo         = AssetDatabase.LoadAssetAtPath <Texture2D>(resourcePath + "logo.png");
        var rect         = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box);

        if (logo)
        {
            GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
        }

        EditorGUILayout.HelpBox("Recommended project settings for SteamVR:", MessageType.Warning);

        scrollPosition = GUILayout.BeginScrollView(scrollPosition);

        int numItems = 0;

        if (!EditorPrefs.HasKey(ignore + buildTarget) &&
            EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget)
        {
            ++numItems;

            GUILayout.Label(buildTarget + string.Format(currentValue, EditorUserBuildSettings.activeBuildTarget));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_BuildTarget)))
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget);
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + buildTarget, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
            PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen)
        {
            ++numItems;

            GUILayout.Label(showUnitySplashScreen + string.Format(currentValue, PlayerSettings.showUnitySplashScreen));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_ShowUnitySplashScreen)))
            {
                PlayerSettings.showUnitySplashScreen = recommended_ShowUnitySplashScreen;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
            PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen)
        {
            ++numItems;

            GUILayout.Label(defaultIsFullScreen + string.Format(currentValue, PlayerSettings.defaultIsFullScreen));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_DefaultIsFullScreen)))
            {
                PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
            (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
             PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight))
        {
            ++numItems;

            GUILayout.Label(defaultScreenSize + string.Format(" ({0}x{1})", PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format("Use recommended ({0}x{1})", recommended_DefaultScreenWidth, recommended_DefaultScreenHeight)))
            {
                PlayerSettings.defaultScreenWidth  = recommended_DefaultScreenWidth;
                PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + defaultScreenSize, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + runInBackground) &&
            PlayerSettings.runInBackground != recommended_RunInBackground)
        {
            ++numItems;

            GUILayout.Label(runInBackground + string.Format(currentValue, PlayerSettings.runInBackground));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_RunInBackground)))
            {
                PlayerSettings.runInBackground = recommended_RunInBackground;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + runInBackground, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
            PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog)
        {
            ++numItems;

            GUILayout.Label(displayResolutionDialog + string.Format(currentValue, PlayerSettings.displayResolutionDialog));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_DisplayResolutionDialog)))
            {
                PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + displayResolutionDialog, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + resizableWindow) &&
            PlayerSettings.resizableWindow != recommended_ResizableWindow)
        {
            ++numItems;

            GUILayout.Label(resizableWindow + string.Format(currentValue, PlayerSettings.resizableWindow));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_ResizableWindow)))
            {
                PlayerSettings.resizableWindow = recommended_ResizableWindow;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + resizableWindow, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + fullscreenMode) &&
            PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode)
        {
            ++numItems;

            GUILayout.Label(fullscreenMode + string.Format(currentValue, PlayerSettings.d3d11FullscreenMode));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_FullscreenMode)))
            {
                PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + fullscreenMode, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + visibleInBackground) &&
            PlayerSettings.visibleInBackground != recommended_VisibleInBackground)
        {
            ++numItems;

            GUILayout.Label(visibleInBackground + string.Format(currentValue, PlayerSettings.visibleInBackground));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_VisibleInBackground)))
            {
                PlayerSettings.visibleInBackground = recommended_VisibleInBackground;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + visibleInBackground, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + renderingPath) &&
            PlayerSettings.renderingPath != recommended_RenderPath)
        {
            ++numItems;

            GUILayout.Label(renderingPath + string.Format(currentValue, PlayerSettings.renderingPath));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_RenderPath) + " - required for MSAA"))
            {
                PlayerSettings.renderingPath = recommended_RenderPath;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + renderingPath, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + colorSpace) &&
            PlayerSettings.colorSpace != recommended_ColorSpace)
        {
            ++numItems;

            GUILayout.Label(colorSpace + string.Format(currentValue, PlayerSettings.colorSpace));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_ColorSpace) + " - requires reloading scene"))
            {
                PlayerSettings.colorSpace = recommended_ColorSpace;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + colorSpace, true);
            }

            GUILayout.EndHorizontal();
        }

        if (!EditorPrefs.HasKey(ignore + gpuSkinning) &&
            PlayerSettings.gpuSkinning != recommended_GpuSkinning)
        {
            ++numItems;

            GUILayout.Label(gpuSkinning + string.Format(currentValue, PlayerSettings.gpuSkinning));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_GpuSkinning)))
            {
                PlayerSettings.gpuSkinning = recommended_GpuSkinning;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + gpuSkinning, true);
            }

            GUILayout.EndHorizontal();
        }

#if false
        if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
            PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering)
        {
            ++numItems;

            GUILayout.Label(singlePassStereoRendering + string.Format(currentValue, PlayerSettings.singlePassStereoRendering));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format(useRecommended, recommended_SinglePassStereoRendering)))
            {
                PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ignore"))
            {
                EditorPrefs.SetBool(ignore + singlePassStereoRendering, true);
            }

            GUILayout.EndHorizontal();
        }
#endif

        GUILayout.BeginHorizontal();

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Clear All Ignores"))
        {
            EditorPrefs.DeleteKey(ignore + buildTarget);
            EditorPrefs.DeleteKey(ignore + showUnitySplashScreen);
            EditorPrefs.DeleteKey(ignore + defaultIsFullScreen);
            EditorPrefs.DeleteKey(ignore + defaultScreenSize);
            EditorPrefs.DeleteKey(ignore + runInBackground);
            EditorPrefs.DeleteKey(ignore + displayResolutionDialog);
            EditorPrefs.DeleteKey(ignore + resizableWindow);
            EditorPrefs.DeleteKey(ignore + fullscreenMode);
            EditorPrefs.DeleteKey(ignore + visibleInBackground);
            EditorPrefs.DeleteKey(ignore + renderingPath);
            EditorPrefs.DeleteKey(ignore + colorSpace);
            EditorPrefs.DeleteKey(ignore + gpuSkinning);
#if false
            EditorPrefs.DeleteKey(ignore + singlePassStereoRendering);
#endif
        }

        GUILayout.EndHorizontal();

        GUILayout.EndScrollView();

        GUILayout.FlexibleSpace();

        GUILayout.BeginHorizontal();

        if (numItems > 0)
        {
            if (GUILayout.Button("Accept All"))
            {
                // Only set those that have not been explicitly ignored.
                if (!EditorPrefs.HasKey(ignore + buildTarget))
                {
                    EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget);
                }
                if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen))
                {
                    PlayerSettings.showUnitySplashScreen = recommended_ShowUnitySplashScreen;
                }
                if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen))
                {
                    PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen;
                }
                if (!EditorPrefs.HasKey(ignore + defaultScreenSize))
                {
                    PlayerSettings.defaultScreenWidth  = recommended_DefaultScreenWidth;
                    PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight;
                }
                if (!EditorPrefs.HasKey(ignore + runInBackground))
                {
                    PlayerSettings.runInBackground = recommended_RunInBackground;
                }
                if (!EditorPrefs.HasKey(ignore + displayResolutionDialog))
                {
                    PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog;
                }
                if (!EditorPrefs.HasKey(ignore + resizableWindow))
                {
                    PlayerSettings.resizableWindow = recommended_ResizableWindow;
                }
                if (!EditorPrefs.HasKey(ignore + fullscreenMode))
                {
                    PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode;
                }
                if (!EditorPrefs.HasKey(ignore + visibleInBackground))
                {
                    PlayerSettings.visibleInBackground = recommended_VisibleInBackground;
                }
                if (!EditorPrefs.HasKey(ignore + renderingPath))
                {
                    PlayerSettings.renderingPath = recommended_RenderPath;
                }
                if (!EditorPrefs.HasKey(ignore + colorSpace))
                {
                    PlayerSettings.colorSpace = recommended_ColorSpace;
                }
                if (!EditorPrefs.HasKey(ignore + gpuSkinning))
                {
                    PlayerSettings.gpuSkinning = recommended_GpuSkinning;
                }
#if false
                if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering))
                {
                    PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering;
                }
#endif

                EditorUtility.DisplayDialog("Accept All", "You made the right choice!", "Ok");

                Close();
            }

            if (GUILayout.Button("Ignore All"))
            {
                if (EditorUtility.DisplayDialog("Ignore All", "Are you sure?", "Yes, Ignore All", "Cancel"))
                {
                    // Only ignore those that do not currently match our recommended settings.
                    if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget)
                    {
                        EditorPrefs.SetBool(ignore + buildTarget, true);
                    }
                    if (PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen)
                    {
                        EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
                    }
                    if (PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen)
                    {
                        EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
                    }
                    if (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
                        PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)
                    {
                        EditorPrefs.SetBool(ignore + defaultScreenSize, true);
                    }
                    if (PlayerSettings.runInBackground != recommended_RunInBackground)
                    {
                        EditorPrefs.SetBool(ignore + runInBackground, true);
                    }
                    if (PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog)
                    {
                        EditorPrefs.SetBool(ignore + displayResolutionDialog, true);
                    }
                    if (PlayerSettings.resizableWindow != recommended_ResizableWindow)
                    {
                        EditorPrefs.SetBool(ignore + resizableWindow, true);
                    }
                    if (PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode)
                    {
                        EditorPrefs.SetBool(ignore + fullscreenMode, true);
                    }
                    if (PlayerSettings.visibleInBackground != recommended_VisibleInBackground)
                    {
                        EditorPrefs.SetBool(ignore + visibleInBackground, true);
                    }
                    if (PlayerSettings.renderingPath != recommended_RenderPath)
                    {
                        EditorPrefs.SetBool(ignore + renderingPath, true);
                    }
                    if (PlayerSettings.colorSpace != recommended_ColorSpace)
                    {
                        EditorPrefs.SetBool(ignore + colorSpace, true);
                    }
                    if (PlayerSettings.gpuSkinning != recommended_GpuSkinning)
                    {
                        EditorPrefs.SetBool(ignore + gpuSkinning, true);
                    }
#if false
                    if (PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering)
                    {
                        EditorPrefs.SetBool(ignore + singlePassStereoRendering, true);
                    }
#endif

                    Close();
                }
            }
        }
        else if (GUILayout.Button("Close"))
        {
            Close();
        }

        GUILayout.EndHorizontal();
    }
        public void OnGUI(Rect pos)
        {
            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
            bool newState = false;

            //basic options
            EditorGUILayout.Space();
            GUILayout.BeginVertical();

            // build target
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildTarget)) {
                ValidBuildTarget tgt = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_BuildTarget);
                if (tgt != m_BuildTarget)
                {
                    m_BuildTarget = tgt;
                    if (m_UseDefaultPath)
                    {
                        m_OutputPath  = "AssetBundles/";
                        m_OutputPath += m_BuildTarget.ToString();
                        EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath);
                    }
                }
            }


            ////output path
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOutputDirectory)) {
                EditorGUILayout.Space();
                GUILayout.BeginHorizontal();
                var newPath = EditorGUILayout.TextField("Output Path", m_OutputPath);
                if (newPath != m_OutputPath)
                {
                    m_UseDefaultPath = false;
                    m_OutputPath     = newPath;
                    EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath);
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f)))
                {
                    BrowseForFolder();
                }
                if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f)))
                {
                    ResetPathToDefault();
                }
                if (string.IsNullOrEmpty(m_OutputPath))
                {
                    m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath");
                }
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();

                newState = GUILayout.Toggle(
                    m_ForceRebuild.state,
                    m_ForceRebuild.content);
                if (newState != m_ForceRebuild.state)
                {
                    if (newState)
                    {
                        m_OnToggles.Add(m_ForceRebuild.content.text);
                    }
                    else
                    {
                        m_OnToggles.Remove(m_ForceRebuild.content.text);
                    }
                    m_ForceRebuild.state = newState;
                }
                newState = GUILayout.Toggle(
                    m_CopyToStreaming.state,
                    m_CopyToStreaming.content);
                if (newState != m_CopyToStreaming.state)
                {
                    if (newState)
                    {
                        m_OnToggles.Add(m_CopyToStreaming.content.text);
                    }
                    else
                    {
                        m_OnToggles.Remove(m_CopyToStreaming.content.text);
                    }
                    m_CopyToStreaming.state = newState;
                }
            }

            // advanced options
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOptions)) {
                EditorGUILayout.Space();
                m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings");
                if (m_AdvancedSettings)
                {
                    var indent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel = 1;
                    CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup(
                        m_CompressionContent,
                        (int)m_Compression,
                        m_CompressionOptions,
                        m_CompressionValues);

                    if (cmp != m_Compression)
                    {
                        m_Compression = cmp;
                    }
                    foreach (var tog in m_ToggleData)
                    {
                        newState = EditorGUILayout.ToggleLeft(
                            tog.content,
                            tog.state);
                        if (newState != tog.state)
                        {
                            if (newState)
                            {
                                m_OnToggles.Add(tog.content.text);
                            }
                            else
                            {
                                m_OnToggles.Remove(tog.content.text);
                            }
                            tog.state = newState;
                        }
                    }
                    EditorGUILayout.Space();
                    EditorGUI.indentLevel = indent;
                }
            }

            // build.
            EditorGUILayout.Space();
            if (GUILayout.Button("Build"))
            {
                ExecuteBuild();
            }
            GUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
示例#27
0
 private static void BuildForWin64()
 {
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
     BuildPlayer(BuildTarget.StandaloneWindows64, BuilderConstants.DEFAULT_BUILD_DIRECTORY);
 }
示例#28
0
 static void SwitchPlatform(BuildTarget buildTarget)
 {
     EditorUserBuildSettings.SwitchActiveBuildTarget(buildTarget);
 }
示例#29
0
        public static void BuildPlayer(bool run = false)
        {
            //Just in case, we save the settings
            BuildSettings.Save();

            string path = EditorUtility.SaveFolderPanel("Choose Location of Built Game", EditorUserBuildSettings.GetBuildLocation(BuildTarget.WebGL), "");

            if (Directory.Exists(path))
            {
                ProgressHelper progress = new ProgressHelper();
                progress.Reset(5);


                //Set Template
                string lastUsedTemplate = TemplateManager.SetChromeTemplate("PROJECT:ChromeApp");
                //Define symbols
                Builder.SetDefineSymbol(true);
                //Create subfolder
                path = Builder.CreateSubFolder(path);

                progress.SetCleanupCallback(() => {
                    //Clean up
                    //Reset Webgl template
                    TemplateManager.SetChromeTemplate(lastUsedTemplate);
                    //Define symbols
                    Builder.SetDefineSymbol(false);
                });
                //BUILD
                if (!Builder.BuildPlayer(path))
                {
                    progress.Done();
                    return;
                }
                //Process template
                progress.Step("Building Player - Chrome App", "Postprocessing Template Variables");
                TemplateManager.ProcessTemplateFiles(path);
                //Creatig Icons
                progress.Step("Building Player - Chrome App", "Creating icons");
                Icons.CreateIcons(path);
                //Creating Manifest
                progress.Step("Building Player - Chrome App", "Creating manifest");
                Manifest.CreateManifestFile(path);
                //Packing Extention
                progress.Step("Building Player - Chrome App", "Packing Extension into .crx file");
                if (BuildSettings.Get.packExtension)
                {
                    if (!ChromeHelper.PackExtension(path))
                    {
                        Debug.LogWarning("Chrome app was not packed into a .crx file.");
                    }
                }
                //launch player or reveal in explorer
                progress.Step("Building Player - Chrome App", "Launching");
                if (run)
                {
                    if (File.Exists(path + ".crx"))
                    {
                        CrxHeader header = new CrxHeader(path + ".crx");
                        Manifest.AddKeyToManifest(Path.Combine(path, "manifest.json"), header.PublicKey);
                    }
                    ChromeHelper.LoadAndRunExtension(path);
                }
                else
                {
                    EditorUtility.RevealInFinder(path);
                }
                //Clear progress and cleanup
                progress.Done();
            }
        }
示例#30
0
 static void Build()
 {
     EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows);
     BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, @"Build/Sports Team Manager/SportsTeamManager.exe", BuildTarget.StandaloneWindows, BuildOptions.None);
 }