コード例 #1
0
 private static void tvOSDemoOff()
 {
             #if UNITY_TVOS
     DefineSymbolUtil.RemoveDefineSymbol(BuildTargetGroup.tvOS, "SAGO_TVOS_DEMO");
     DefineSymbolUtil.RemoveDefineSymbol(BuildTargetGroup.tvOS, "SAGO_DISABLE_SAGOBIZ");
             #endif
 }
コード例 #2
0
        /// <summary>
        /// Implements the build logic. Subclasses should override this method
        /// to implement custom runner functionality.
        /// </summary>
        virtual protected void Build()
        {
            // add define symbols
            DefineSymbolUtil.AddDefineSymbols(this.BuildTargetGroup, this.DefineSymbols);

            // preprocess
            this.OnPreprocess(null);

            // build
            BuildPipeline.BuildPlayer(
                this.BuildScenes.ToArray(),
                this.BuildPath,
                this.BuildTarget,
                this.BuildOptions
                );

            // postprocess
            this.OnPostprocess(this.BuildPath);

            // remove defined symbols
            DefineSymbolUtil.RemoveDefineSymbols(this.BuildTargetGroup, this.DefineSymbols);
        }
コード例 #3
0
 private static void iOSDemoOff()
 {
     DefineSymbolUtil.RemoveDefineSymbol(BuildTargetGroup.iOS, "SAGO_IOS_DEMO");
     DefineSymbolUtil.RemoveDefineSymbol(BuildTargetGroup.iOS, "SAGO_DISABLE_SAGOBIZ");
 }
コード例 #4
0
        /// <summary>
        /// Switches the active build target, adds the define symbol for the
        /// specified platform and removes the defines symbols for all other
        /// platforms.
        /// </summary>
        public static bool Activate(Platform platform)
        {
            // bootstrap
            Bootstrap();

            // get platforms
            Platform newPlatform = platform;
            Platform oldPlatform = PlatformUtil.ActivePlatform;

            // get build targets
            // BuildTarget oldBuildTarget = oldPlatform.ToBuildTarget();

            // change build target
                        #if !(UNITY_CLOUD_BUILD || TEAMCITY_BUILD)
            BuildTarget newBuildTarget = newPlatform.ToBuildTarget();
            if (EditorUserBuildSettings.activeBuildTarget != newBuildTarget)
            {
                if (!EditorUserBuildSettings.SwitchActiveBuildTarget(BuildPipeline.GetBuildTargetGroup(newBuildTarget), newBuildTarget))
                {
                    Debug.LogError(string.Format("Could not switch active build target: {0}", newBuildTarget));
                    return(false);
                }
            }
                        #endif

            // platform will change callback
            OnPlatformWillChangeAttribute.Invoke(oldPlatform, newPlatform);

            // change define symbols
                        #if !(UNITY_CLOUD_BUILD || TEAMCITY_BUILD)
            HashSet <int> obsoleteBuildTargets = new HashSet <int>()
            {
                2,                          // (int)BuildTargetGroup.WebPlayer,
                5,                          // (int)BuildTargetGroup.PS3,
                6,                          // (int)BuildTargetGroup.XBOX360,
                15,                         // (int)BuildTargetGroup.WP8,
                16,                         // (int)BuildTargetGroup.BlackBerry,
                20,                         // (int)BuildTargetGroup.PSM,
                22,                         // (int)BuildTargetGroup.SamsungTV,
            };

            // Clean up the enum - Unity has left in some values which some of
            // their other APIs don't like
            IEnumerable <BuildTargetGroup> targetGroups = System.Enum.
                                                          GetValues(typeof(BuildTargetGroup)).
                                                          Cast <BuildTargetGroup>().
                                                          Where(bt => !obsoleteBuildTargets.Contains((int)bt));

            foreach (BuildTargetGroup buildTargetGroup in targetGroups)
            {
                // find all the platforms that do not belong to the build target group
                Platform[] excludedPlatforms = System.Enum
                                               .GetValues(typeof(Platform))
                                               .Cast <Platform>()
                                               .Where(p => buildTargetGroup != p.ToBuildTargetGroup())
                                               .ToArray();

                // remove defines
                foreach (Platform excludedPlatform in excludedPlatforms)
                {
                    DefineSymbolUtil.DefineSymbol(
                        buildTargetGroup,
                        excludedPlatform.ToDefineSymbol(),
                        false
                        );
                }

                // find all the platforms that belong to the build target group
                Platform[] includedPlatforms = System.Enum
                                               .GetValues(typeof(Platform))
                                               .Cast <Platform>()
                                               .Where(p => buildTargetGroup == p.ToBuildTargetGroup())
                                               .ToArray();


                // add the define for the new platform and remove the defines for all other platforms
                foreach (Platform includedPlatform in includedPlatforms)
                {
                    DefineSymbolUtil.DefineSymbol(
                        buildTargetGroup,
                        includedPlatform.ToDefineSymbol(),
                        includedPlatform == platform
                        );
                }
            }
            AssetDatabase.SaveAssets();
                        #endif

            // platform did change callback
            OnPlatformDidChangeAttribute.Invoke(oldPlatform, newPlatform);

            return(true);
        }