Ejemplo n.º 1
0
        internal PlayerLauncherBuildOptions GetBuildOptions(string scenePath)
        {
            var buildOnly   = false;
            var runSettings = m_OverloadTestRunSettings as PlayerLauncherTestRunSettings;

            if (runSettings != null)
            {
                buildOnly = runSettings.buildOnly;
            }

            var buildOptions = new BuildPlayerOptions();

            var scenes = new List <string>()
            {
                scenePath
            };

            scenes.AddRange(EditorBuildSettings.scenes.Select(x => x.path));
            buildOptions.scenes = scenes.ToArray();

            buildOptions.options |= BuildOptions.Development | BuildOptions.ConnectToHost | BuildOptions.IncludeTestAssemblies | BuildOptions.StrictMode;
            buildOptions.target   = m_TargetPlatform;

            if (EditorUserBuildSettings.waitForPlayerConnection)
            {
                buildOptions.options |= BuildOptions.WaitForPlayerConnection;
            }

            if (EditorUserBuildSettings.allowDebugging)
            {
                buildOptions.options |= BuildOptions.AllowDebugging;
            }

            if (EditorUserBuildSettings.installInBuildFolder)
            {
                buildOptions.options |= BuildOptions.InstallInBuildFolder;
            }
            else if (!buildOnly)
            {
                buildOptions.options |= BuildOptions.AutoRunPlayer;
            }

            var buildTargetGroup = EditorUserBuildSettings.activeBuildTargetGroup;

            //Check if Lz4 is supported for the current buildtargetgroup and enable it if need be
            if (PostprocessBuildPlayer.SupportsLz4Compression(buildTargetGroup, m_TargetPlatform))
            {
                if (EditorUserBuildSettings.GetCompressionType(buildTargetGroup) == Compression.Lz4)
                {
                    buildOptions.options |= BuildOptions.CompressWithLz4;
                }
                else if (EditorUserBuildSettings.GetCompressionType(buildTargetGroup) == Compression.Lz4HC)
                {
                    buildOptions.options |= BuildOptions.CompressWithLz4HC;
                }
            }

            string buildLocation;

            if (buildOnly)
            {
                buildLocation = buildOptions.locationPathName = runSettings.buildOnlyLocationPath;
            }
            else
            {
                var reduceBuildLocationPathLength = false;

                //Some platforms hit MAX_PATH limits during the build process, in these cases minimize the path length
                if ((m_TargetPlatform == BuildTarget.WSAPlayer)
#if !UNITY_2021_1_OR_NEWER
                    || (m_TargetPlatform == BuildTarget.XboxOne)
#endif
                    )
                {
                    reduceBuildLocationPathLength = true;
                }

                var uniqueTempPathInProject = FileUtil.GetUniqueTempPathInProject();
                var playerDirectoryName     = "PlayerWithTests";

                //Some platforms hit MAX_PATH limits during the build process, in these cases minimize the path length
                if (reduceBuildLocationPathLength)
                {
                    playerDirectoryName     = "PwT";
                    uniqueTempPathInProject = Path.GetTempFileName();
                    File.Delete(uniqueTempPathInProject);
                    Directory.CreateDirectory(uniqueTempPathInProject);
                }

                var tempPath = Path.GetFullPath(uniqueTempPathInProject);
                buildLocation = Path.Combine(tempPath, playerDirectoryName);

                // iOS builds create a folder with Xcode project instead of an executable, therefore no executable name is added
                if (m_TargetPlatform == BuildTarget.iOS)
                {
                    buildOptions.locationPathName = buildLocation;
                }
                else
                {
                    string extensionForBuildTarget =
                        PostprocessBuildPlayer.GetExtensionForBuildTarget(buildTargetGroup, buildOptions.target,
                                                                          buildOptions.options);
                    var playerExecutableName = "PlayerWithTests";
                    if (!string.IsNullOrEmpty(extensionForBuildTarget))
                    {
                        playerExecutableName += $".{extensionForBuildTarget}";
                    }

                    buildOptions.locationPathName = Path.Combine(buildLocation, playerExecutableName);
                }
            }

            return(new PlayerLauncherBuildOptions
            {
                BuildPlayerOptions = ModifyBuildOptions(buildOptions),
                PlayerDirectory = buildLocation,
            });
        }
Ejemplo n.º 2
0
        private PlayerLauncherBuildOptions GetBuildOptions(string scenePath)
        {
            var buildOptions = new BuildPlayerOptions();
            var reduceBuildLocationPathLength = false;

            //Some platforms hit MAX_PATH limits during the build process, in these cases minimize the path length
            if ((m_TargetPlatform == BuildTarget.WSAPlayer) || (m_TargetPlatform == BuildTarget.XboxOne))
            {
                reduceBuildLocationPathLength = true;
            }

            var scenes = new List <string>()
            {
                scenePath
            };

            scenes.AddRange(EditorBuildSettings.scenes.Select(x => x.path));
            buildOptions.scenes = scenes.ToArray();

            buildOptions.options |= BuildOptions.AutoRunPlayer | BuildOptions.Development | BuildOptions.ConnectToHost | BuildOptions.IncludeTestAssemblies | BuildOptions.StrictMode;
            buildOptions.target   = m_TargetPlatform;

            if (EditorUserBuildSettings.waitForPlayerConnection)
            {
                buildOptions.options |= BuildOptions.WaitForPlayerConnection;
            }

            var buildTargetGroup = EditorUserBuildSettings.activeBuildTargetGroup;

            //Check if Lz4 is supported for the current buildtargetgroup and enable it if need be
            if (PostprocessBuildPlayer.SupportsLz4Compression(buildTargetGroup, m_TargetPlatform))
            {
                if (EditorUserBuildSettings.GetCompressionType(buildTargetGroup) == Compression.Lz4)
                {
                    buildOptions.options |= BuildOptions.CompressWithLz4;
                }
                else if (EditorUserBuildSettings.GetCompressionType(buildTargetGroup) == Compression.Lz4HC)
                {
                    buildOptions.options |= BuildOptions.CompressWithLz4HC;
                }
            }

            var uniqueTempPathInProject = FileUtil.GetUniqueTempPathInProject();
            var playerDirectoryName     = reduceBuildLocationPathLength ? "PwT" : "PlayerWithTests";

            if (reduceBuildLocationPathLength)
            {
                uniqueTempPathInProject = Path.GetTempFileName();
                File.Delete(uniqueTempPathInProject);
                Directory.CreateDirectory(uniqueTempPathInProject);
            }
            var tempPath      = Path.GetFullPath(uniqueTempPathInProject);
            var buildLocation = Path.Combine(tempPath, playerDirectoryName);

            // iOS builds create a folder with Xcode project instead of an executable, therefore no executable name is added
            if (m_TargetPlatform == BuildTarget.iOS)
            {
                buildOptions.locationPathName = buildLocation;
            }
            else
            {
                string extensionForBuildTarget = PostprocessBuildPlayer.GetExtensionForBuildTarget(buildTargetGroup, buildOptions.target, buildOptions.options);
                var    playerExecutableName    = "PlayerWithTests";
                playerExecutableName         += string.Format(".{0}", extensionForBuildTarget);
                buildOptions.locationPathName = Path.Combine(buildLocation, playerExecutableName);
            }

            return(new PlayerLauncherBuildOptions
            {
                BuildPlayerOptions = ModifyBuildOptions(buildOptions),
                PlayerDirectory = buildLocation,
            });
        }