Exemplo n.º 1
0
        public void OnPreprocessBuild(BuildTarget target, string path)
        {
            BuildScript.CopyAssetBundlesTo(Path.Combine(Application.streamingAssetsPath, Assets.AssetBundles));
            var platformName = BuildScript.GetPlatformName();
            var searchPath   = Path.Combine(Path.Combine(Application.streamingAssetsPath, Assets.AssetBundles),
                                            platformName);

            if (!Directory.Exists(searchPath))
            {
                return;
            }
            var files = Directory.GetFiles(searchPath, "*.manifest", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                var info = new FileInfo(file);
                if (info.Exists)
                {
                    info.Delete();
                }
            }

            files = Directory.GetFiles(searchPath, "*.meta", SearchOption.AllDirectories);
            foreach (var item in files)
            {
                var info = new FileInfo(item);
                info.Delete();
            }
        }
Exemplo n.º 2
0
        private static void OnInitialize()
        {
            var sceneAssets = new List <string>();
            var rules       = BuildScript.GetBuildRules();

            foreach (var guid in AssetDatabase.FindAssets("t:Scene", rules.scenesFolders))
            {
                var assetPath = AssetDatabase.GUIDToAssetPath(guid);
                sceneAssets.Add(assetPath);
            }

            var patches     = new List <Patch>();
            var assets      = new List <AssetRef>();
            var searchPaths = new List <string>();
            var dirs        = new Dictionary <string, int>();

            foreach (var asset in rules.assets)
            {
                if (!File.Exists(asset.name))
                {
                    continue;
                }
                var dir = Path.GetDirectoryName(asset.name);
                if (!string.IsNullOrEmpty(dir))
                {
                    if (!searchPaths.Contains(dir))
                    {
                        dirs[dir] = searchPaths.Count;
                        searchPaths.Add(dir);
                    }
                }
                var ar = new AssetRef {
                    name = Path.GetFileName(asset.name), bundle = -1, dir = dirs[dir]
                };
                assets.Add(ar);
            }

            var scenes = new EditorBuildSettingsScene[sceneAssets.Count];

            for (var index = 0; index < sceneAssets.Count; index++)
            {
                var asset = sceneAssets[index];
                scenes[index] = new EditorBuildSettingsScene(asset, true);
                var dir = Path.GetDirectoryName(asset);
                if (!searchPaths.Contains(dir))
                {
                    searchPaths.Add(dir);
                }
            }

            for (var i = 0; i < rules.patches.Count; i++)
            {
                var item  = rules.patches[i];
                var patch = new Patch();
                patch.name = item.name;
                patches.Add(patch);
            }

            var developVersions = new Versions();

            developVersions.dirs    = searchPaths.ToArray();
            developVersions.assets  = assets;
            developVersions.patches = patches;
            Assets.platform         = BuildScript.GetPlatformName();
            //Assets.basePath = Environment.CurrentDirectory.Replace("\\", "/") + "/" + BuildScript.outputPath + "/";
            Assets.assetLoader      = AssetDatabase.LoadAssetAtPath;
            Assets.versionsLoader  += () => developVersions;
            Assets.onAssetLoaded   += rules.OnLoadAsset;
            Assets.onAssetUnloaded += rules.OnUnloadAsset;
            rules.BeginSample();
            EditorBuildSettings.scenes              = scenes;
            EditorApplication.playModeStateChanged += EditorApplicationOnplayModeStateChanged;
        }