Пример #1
0
        List <AssetSelectorElement> BuildElements(bool logToConsole)
        {
            List <Object> assets = AssetTools.FindAssetsByType(type, logToConsole);

            List <AssetSelectorElement> r = new List <AssetSelectorElement>();

            for (int i = 0; i < assets.Count; i++)
            {
                r.Add(new AssetSelectorElement(assets[i]));
            }
            return(r);
        }
Пример #2
0
        static void UpdateDynamicObjectReferencesInPrefabObjects()
        {
            if (Application.isPlaying)
            {
                return;
            }

            List <PrefabReferenceCollection> refs = AssetTools.FindAssetsByType <PrefabReferenceCollection>(log: false, null);

            for (int i = 0; i < refs.Count; i++)
            {
                PrefabReferenceCollectionEditor.UpdateDynamicObjectReferencesInPrefabCollection(refs[i]);
            }
        }
        void Init()
        {
            company     = PlayerSettings.companyName;
            productName = PlayerSettings.productName;

            List <SceneAsset> sceneAssets = AssetTools.FindAssetsByType <SceneAsset>(false, new AutoBuildSceneAttribute().OnAssetsFound);

            SceneAssetArrayElement[] arrayElements = new SceneAssetArrayElement[sceneAssets.Count];
            for (int i = 0; i < sceneAssets.Count; i++)
            {
                arrayElements[i] = new SceneAssetArrayElement(sceneAssets[i]);
            }
            scenes = new SceneAssetArray(arrayElements);
        }
Пример #4
0
        List <AssetSelectorElement> BuildElements(OnAssetsLoaded onAssetsLoaded, Func <List <Object>, List <Object> > onAssetsFound, bool addNull, bool logToConsole)
        {
            List <Object> assets = AssetTools.FindAssetsByType(type, logToConsole, onAssetsFound);

            List <AssetSelectorElement> r = new List <AssetSelectorElement>();

            for (int i = 0; i < assets.Count; i++)
            {
                r.Add(new AssetSelectorElement(assets[i], type.Name));
            }

            if (onAssetsLoaded != null)
            {
                r = onAssetsLoaded(r);
            }

            if (addNull)
            {
                r.Insert(0, new AssetSelectorElement(null, type.Name));
            }

            return(r);
        }
Пример #5
0
        public static void PerformBuild(List <EditorBuildSettingsScene> buildScenes, string company, string productName, List <BuildTargetDef> buildTargets, VersionUpdate versionUpdate, bool forceVersion, Vector3Int forcedVersion, bool devBuild, bool connectProfiler, bool allowDebugging, bool headless, string bundleID)
        {
            CheckBuildTargetsForDuplicatesAndOnlyOneAutoRun(buildTargets);

            if (buildTargets.Count == 0)
            {
                return;
            }

            AddAutoIncludedScenes(buildScenes, AssetTools.FindAssetsByType <SceneAsset>(log: false, null));

            BuildOptions options = BuildOptions.None;

            if (devBuild)
            {
                options |= BuildOptions.Development;
            }
            if (allowDebugging)
            {
                options |= BuildOptions.AllowDebugging;
            }
            if (headless)
            {
                options |= BuildOptions.EnableHeadlessMode;
            }
            if (connectProfiler)
            {
                options |= BuildOptions.ConnectWithProfiler;
            }

            // Save current player settings, and then set target settings.
            string preBuildCompanyName = PlayerSettings.companyName;
            string preBuildProductName = PlayerSettings.productName;
            string oldVersion          = PlayerSettings.bundleVersion;

            EditorBuildSettingsScene[] scenes = CheckForNullsAndDuplicateScenes(buildScenes);

            Vector3Int version;

            if (forceVersion)
            {
                version = forcedVersion;
            }
            else
            {
                GetLatestVersion(out version);
                switch (versionUpdate)
                {
                case VersionUpdate.Major: version.x++; break;

                case VersionUpdate.Minor: version.y++; break;

                case VersionUpdate.Patch: version.z++; break;
                }
            }

            string versionS = version.x.ToString() + "." + version.y.ToString() + "." + version.z.ToString();

            string versionDir = GenerateVersionDirectory(versionS);

            PlayerSettings.companyName   = company;
            PlayerSettings.productName   = productName;
            PlayerSettings.bundleVersion = versionS;

            int successCount = 0;
            int failCount    = 0;

            for (int i = 0; i < buildTargets.Count; i++)
            {
                bool success = BuildPlayer(scenes, options, versionDir, productName, buildTargets[i].buildTarget, buildTargets[i].autoRun, buildTargets[i].customDefines, bundleID);

                if (success)
                {
                    ++successCount;
                }
                else
                {
                    ++failCount;
                }
            }

            //restore old player settings
            PlayerSettings.companyName   = preBuildCompanyName;
            PlayerSettings.productName   = preBuildProductName;
            PlayerSettings.bundleVersion = oldVersion;

            // Report success/failure.
            Debug.Log("Build Complete. " + string.Format("{0} success. {1} failure.", successCount, failCount));

            System.Diagnostics.Process.Start(versionDir);
        }