Ejemplo n.º 1
0
        const int Version1          = 1;                                               //キャッシュ情報のファイルバージョン

        /// <summary>
        /// キャッシュデータテーブルをバイナリ読み込み
        /// </summary>
        /// <param name="reader">バイナリリーダー</param>
        void Read(BinaryReader reader, AssetFileManagerSettings settings, ConvertFileListManager convertFileListManager)
        {
            int magicID = reader.ReadInt32();

            if (magicID != MagicID)
            {
                throw new System.Exception("Read File Id Error");
            }

            int fileVersion = reader.ReadInt32();

            if (fileVersion == Version)
            {
                cacheFileID = reader.ReadInt32();
                int count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    Add(new AssetFileInfo(reader, settings, convertFileListManager));
                }
            }
            else if (fileVersion == Version1)
            {
                cacheFileID = reader.ReadInt32();
                int count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    Add(AssetFileInfo.ReadOld(reader, settings, convertFileListManager));
                }
            }
            else
            {
                throw new System.Exception(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.UnknownVersion, fileVersion));
            }
        }
Ejemplo n.º 2
0
 public AssetFileInfo(string path, AssetFileManagerSettings settings, AssetBundleInfo assetBundleInfo)
 {
     this.FileName        = path;
     this.Setting         = settings.FindSettingFromPath(path);
     this.AssetBundleInfo = assetBundleInfo;
     this.StrageType      = ParseStrageType();
 }
Ejemplo n.º 3
0
        //アセットバンドルのリストを取得
        List <MainAssetInfo> GetAssetBudleList(AssetFileManagerSettings settings)
        {
            List <MainAssetInfo> assets = new List <MainAssetInfo>();

            //指定ディレクトリ以下のアセットを全て取得
            MainAssetInfo inputDirAsset = new MainAssetInfo(AssetBundleDirectory);

            foreach (MainAssetInfo asset in inputDirAsset.GetAllChidren())
            {
                if (asset.IsDirectory)
                {
                    continue;
                }
                if (IsIgnoreAssetBundle(asset))
                {
                    continue;
                }
                AssetFileSetting    assetFileSetting = settings.FindSettingFromPath(asset.AssetPath);
                AssetFileEncodeType encodeType       = assetFileSetting.EncodeType;
                switch (encodeType)
                {
                case AssetFileEncodeType.AssetBundle:
                    assets.Add(asset);
                    break;

                default:
                    break;
                }
            }

            return(assets);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="fileVersion">バイナリリーダー</param>
        public AssetFileInfo(BinaryReader reader, AssetFileManagerSettings settings, ConvertFileListManager assetBundleManager)
        {
            string key = reader.ReadString();

            this.cacheVersion = reader.ReadInt32();
            this.cachePath    = reader.ReadString();
            InitSub(key, settings, assetBundleManager);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="fileVersion">バイナリリーダー</param>
        public static AssetFileInfo ReadOld(BinaryReader reader, AssetFileManagerSettings settings, ConvertFileListManager assetBundleManager)
        {
            string key = reader.ReadString();

            reader.ReadInt32();
            AssetFileInfo info = new AssetFileInfo(key, settings, assetBundleManager);

            info.cacheVersion = reader.ReadInt32();
            info.cachePath    = reader.ReadString();
            reader.ReadInt32();
            return(info);
        }
Ejemplo n.º 6
0
 public AssetFile Find(string filePath, AssetFileManagerSettings settings, StringGridRow rowData)
 {
     if (OnFindAsset != null)
     {
         AssetFile asset = null;
         OnFindAsset(filePath, settings, rowData, ref asset);
         if (asset != null)
         {
             return(asset);
         }
     }
     return(null);
 }
Ejemplo n.º 7
0
        public AssetFile FindAssetFile(string filePath, AssetFileManagerSettings settings, StringGridRow rowData)
        {
            if (Assets == null)
            {
                return(null);
            }
            string      assetName = FilePathUtil.GetFileNameWithoutExtension(filePath);
            StaticAsset asset     = Assets.Find((x) => (x.Asset.name == assetName));

            if (asset == null)
            {
                return(null);
            }

            return(new StaticAssetFile(asset, filePath, settings.FindSettingFromPath(filePath), rowData));
        }
Ejemplo n.º 8
0
        internal AssetFileUtage CreateFile(string path, AssetFileManagerSettings settings, StringGridRow rowData, ConvertFileListManager convertFileListManager)
        {
            //ファイル情報を取得or作成
            AssetFileInfo fileInfo;

            if (!TryGetValue(path, out fileInfo))
            {
                if (string.IsNullOrEmpty(path))
                {
                    Debug.LogError(path);
                }
                fileInfo = new AssetFileInfo(path, settings, convertFileListManager);
                this.Add(fileInfo);
            }
            //ロードファイルクラスを作成
            return(new AssetFileUtage(this, fileInfo, rowData, FileIOManger));
        }
Ejemplo n.º 9
0
        void InitSub(string path, AssetFileManagerSettings settings, ConvertFileListManager convertFileListManager)
        {
            InitKey(path);
            this.filePath = Key;
            //ファイル設定を取得
            this.setting = settings.FindSettingFromPath(FilePath);
            if (FileType == AssetFileType.Csv && FilePathUtil.CheckExtentionWithOutDouble(FilePath, ExtensionUtil.TSV, ExtensionUtil.UtageFile))
            {
                loadFlags |= AssetFileLoadFlags.Tsv;
            }
            //保存場所の設定
            this.strageType = ParseStrageType();

            //コンバートファイル情報を設定
            if (convertFileListManager.IsInitialized)
            {
                SetConvertFileInfo(convertFileListManager);
            }
        }
Ejemplo n.º 10
0
        //起動時初期化
        internal void BootInit(AssetFileManagerSettings settings, ConvertFileListManager convertFileListManager)
        {
#if !(UNITY_WEBPLAYER || UNITY_WEBGL)
            this.Clear();
            if (!AssetFileManager.DontUseCache)
            {
                if (!FileIOManger.ReadBinaryDecode(CacheTblPath, (reader) => Read(reader, settings, convertFileListManager)))
                {
                    this.Clear();
                }
            }
#endif
            if (AssetFileManager.isDebugBootDeleteChacheAll)
            {
                DeleteCacheFileAllSub();
            }
            else if (AssetFileManager.isDebugBootDeleteChacheTextAndBinary)
            {
                DeleteCacheFileAllSub(AssetFileType.Text);
                DeleteCacheFileAllSub(AssetFileType.Bytes);
                DeleteCacheFileAllSub(AssetFileType.Csv);
            }
        }
Ejemplo n.º 11
0
 public AdvFileListConverter(string outPutDirectoryPath, FileIOManager fileIOManager, AssetFileManagerSettings settings)
 {
     OutputResourcesPath = outPutDirectoryPath;
     FileIOManager       = fileIOManager;
     Settings            = settings;
 }
Ejemplo n.º 12
0
 public void InitLink(AssetFileManagerSettings settings)
 {
     this.settings = settings;
 }
Ejemplo n.º 13
0
 public AssetFileInfo(string path, AssetFileManagerSettings settings, ConvertFileListManager convertFileListManager)
 {
     InitSub(path, settings, convertFileListManager);
 }
Ejemplo n.º 14
0
        //アセットバンドルのビルド
        void BuildAssetBundles(string outPutDirectoryPath, FileIOManager fileIOManager, AssetFileManagerSettings settings, bool isOutputLog)
        {
            if (assetBundleBuildMode == AssetBundleBuildMode.None)
            {
                return;
            }

            //アセットバンドルをプラットフォーム別にビルド
            List <BuildTarget> buildTargets = new List <BuildTarget>();

            switch (assetBundleBuildMode)
            {
            case AssetBundleBuildMode.OnlyEditor:                    //エディタ上のみ
                buildTargets.Add(EditorUserBuildSettings.activeBuildTarget);
                break;

            case AssetBundleBuildMode.AllPlatform:                    //全プラットフォーム
            {
                buildTargets = AssetBundleHelper.BuildTargetFlagsToBuildTargetList(buildTargetFlags);
            }
            break;

            default:
                break;
            }

            List <MainAssetInfo> assets = GetAssetBudleList(settings);

            RenameAssetBundles(assets);
            AssetBundleBuild[] builds = ToAssetBundleBuilds(assets);
            if (builds.Length <= 0)
            {
                return;
            }


            foreach (BuildTarget buildTarget in buildTargets)
            {
                string outputPath = FilePathUtil.Combine(outPutDirectoryPath, AssetBundleHelper.BuildTargetToBuildTargetFlag(buildTarget).ToString());
                //出力先のディレクトリを作成
                if (!Directory.Exists(outputPath))
                {
                    Directory.CreateDirectory(outputPath);
                }
                //アセットバンドルを作成
                AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(outputPath, builds, BuildAssetBundleOptions.None, buildTarget);

                //アセットバンドルの情報をバージョンアップ
                AdvFileListConverter converter = new AdvFileListConverter(outputPath, fileIOManager, settings);
                converter.VersionUp(
                    (x) =>
                {
                    int count = x.ConvertFileList.EditorVersionUpAssetBundle(manifest, buildTarget);
                    Debug.Log("" + count + " AsseBundle version up to target " + buildTarget.ToString());
                });
                if (isOutputLog)
                {
                    converter.WriteLog(true);
                }
            }
        }
Ejemplo n.º 15
0
        //ファイルのコンバート
        void Convert()
        {
            try
            {
                AssetFileManager assetFileManager = FindObjectOfType <AssetFileManager>();
                if (assetFileManager == null)
                {
                    Debug.LogError("FileManager is not found in current scene");
                    return;
                }
                //ファイルの入出力に使う
                FileIOManager            fileIOManager = assetFileManager.FileIOManger;
                AssetFileManagerSettings settings      = assetFileManager.Settings;

                if (outputType == OutputType.Default)
                {
                    AssetFileManagerSettings.LoadType loadType = settings.LoadTypeSetting;
                    if (isOutputLocal && LocalDirectory != null)
                    {
                        //ローカルの場合は、LoadTypeをLocalCompressedに
                        settings.LoadTypeSetting = AssetFileManagerSettings.LoadType.LocalCompressed;
                        string output = new MainAssetInfo(LocalDirectory).FullPath;
                        //リソースをバージョンアップ
                        AdvFileListConverter converter = new AdvFileListConverter(output, fileIOManager, settings);
                        converter.VersionUp(VersionUpLocalFiles);
                        if (isOutputLocalLog)
                        {
                            converter.WriteLog(false);
                        }
                    }
                    if (isOutputServer && !string.IsNullOrEmpty(OutputServerResourcePath))
                    {
                        //サーバーの場合は、LoadTypeをServerに
                        settings.LoadTypeSetting = AssetFileManagerSettings.LoadType.Server;
                        //シナリオやリソースをバージョンアップ
                        AdvFileListConverter converter = new AdvFileListConverter(OutputServerResourcePath, fileIOManager, settings);
                        converter.VersionUp(VersionUpServerFiles);
                        if (isOutputServerLog)
                        {
                            converter.WriteLog(false);
                        }
                        //アセットバンドルをビルド
                        BuildAssetBundles(OutputServerResourcePath, fileIOManager, settings, isOutputServerLog);
                    }
                    settings.LoadTypeSetting = loadType;
                }
                else
                {
                    //シナリオやリソースをバージョンアップ
                    AdvFileListConverter converter = new AdvFileListConverter(AdvancedOutputPath, fileIOManager, settings);
                    converter.VersionUp(VersionUpAdvanceFiles);
                    if (isOutputAdvancedLog)
                    {
                        converter.WriteLog(false);
                    }
                    //アセットバンドルをビルド
                    BuildAssetBundles(AdvancedOutputPath, fileIOManager, settings, isOutputAdvancedLog);
                }

                AssetDatabase.Refresh();
            }
            catch (System.Exception e)
            {
                Debug.LogException(e);
            }
        }