Пример #1
0
        public int Apply(BuilderState state)
        {
            int errors = 0;

            this._recover.Clear();

            if (this._ignore.Count == 0)
            {
                DeleteRecoverData();
                return(errors);
            }

            for (int i = this._ignore.Count - 1; i >= 0; i--)
            {
                var path = AssetDatabase.GUIDToAssetPath(this._ignore[i]);
                if (string.IsNullOrEmpty(path))
                {
                    this._ignore.RemoveAt(i);
                    continue;
                }

                this._recover.Add(new RecoverData {
                    guid = this._ignore[i],
                    path = path
                });
            }
            this.SaveRecoverData();

            EnsureDirectory(ExcludeFolder.TrimEnd('/'));

            foreach (var guid in this._ignore)
            {
                string path = AssetDatabase.GUIDToAssetPath(guid);
                if (string.IsNullOrEmpty(path) || path.StartsWith(ExcludeFolder))
                {
                    this._recover.RemoveAll(x => x.guid == guid);
                    continue;
                }

                if (state != null)
                {
                    state.Log("Excluding " + path);
                }
                var error = AssetDatabase.MoveAsset(path, ExcludeFolder + guid + Path.GetExtension(path));
                if (!string.IsNullOrEmpty(error))
                {
                    errors++;
                    if (state != null)
                    {
                        state.Log(error);
                    }
                    Debug.LogError(error);
                }
            }
            this.SaveRecoverData();

            return(errors);
        }
        public static string GetStreamingAssetsDirectory(this BuilderState config)
        {
            var target = config.buildTarget;

            if (target == BuildTarget.iPhone)
            {
                return(Path.Combine(config.buildPath, "Data/Raw/"));
            }

            if (target == BuildTarget.StandaloneOSXIntel || target == BuildTarget.StandaloneOSXIntel64 || target == BuildTarget.StandaloneOSXUniversal)
            {
                return(Path.Combine(config.buildPath, "Contents/Data/StreamingAssets/"));
            }

            if (target == BuildTarget.StandaloneWindows || target == BuildTarget.StandaloneWindows64 || target == BuildTarget.StandaloneLinux || target == BuildTarget.StandaloneLinux64 || target == BuildTarget.StandaloneLinuxUniversal)
            {
                var dir    = Path.GetFileNameWithoutExtension(config.buildPath) + "_Data";
                var parent = Path.GetDirectoryName(config.buildPath);
                if (!string.IsNullOrEmpty(parent))
                {
                    dir = Path.Combine(parent, dir);
                }
                return(Path.Combine(dir, "StreamingAssets/"));
            }

            if (target == BuildTarget.WP8Player)
            {
                return(Path.Combine(config.buildPath, config.productName + "/Data/StreamingAssets/"));
            }


            if (target == BuildTarget.Android && (config.buildOptions & BuildOptions.AcceptExternalModificationsToPlayer) != 0)
            {
                return
                    (PlayerSettings.Android.useAPKExpansionFiles
                                        ? Path.Combine(config.buildPath, config.productName + ".main/assets/")
                                        : Path.Combine(config.buildPath, config.productName + "/assets/"));
            }

            return(null);
        }
Пример #3
0
        public void Recover(BuilderState state)
        {
            foreach (var d in this._recover)
            {
                var path = AssetDatabase.GUIDToAssetPath(d.guid);
                if (string.IsNullOrEmpty(path) || string.Equals(path, d.path, StringComparison.InvariantCultureIgnoreCase) || !path.StartsWith(ExcludeFolder))
                {
                    continue;
                }

                var targetParent = Path.GetDirectoryName(d.path);
                if (!Directory.Exists(targetParent))
                {
                    continue;
                }

                if (state != null)
                {
                    state.Log("Recovering " + d.path + " from " + path);
                }
                string error = AssetDatabase.MoveAsset(path, d.path);
                if (!string.IsNullOrEmpty(error))
                {
                    if (state != null)
                    {
                        state.Log(error);
                    }
                    Debug.LogError(error);
                }
            }

            if (Directory.Exists(ExcludeFolder) && Directory.GetFileSystemEntries(ExcludeFolder).Length == 0)
            {
                AssetDatabase.DeleteAsset(ExcludeFolder.TrimEnd('/'));
                AssetDatabase.SaveAssets();
            }

            this._recover.Clear();
            DeleteRecoverData();
        }
Пример #4
0
 public virtual void OnCleanupBuild(BuilderState state)
 {
 }
Пример #5
0
 public virtual void OnFinishBuild(BuilderState state)
 {
 }
Пример #6
0
 public virtual void OnAfterBuild(BuilderState state)
 {
 }
Пример #7
0
 public virtual void OnBeforeBuild(BuilderState state)
 {
 }