コード例 #1
0
        public void LoadConfig()
        {
            string      path     = Application.streamingAssetsPath + "/myabconfig";
            AssetBundle configAB = AssetBundle.LoadFromFile(path);
            MyABConfig  config   = configAB.LoadAsset <MyABConfig>("myabconfig");

            if (config == null)
            {
                throw new Exception("config is not exist");
            }

            foreach (var item in config.List)
            {
                foreach (var res in item.resList)
                {
                    var resItem = new ResItem
                    {
                        AssetName   = res.name,
                        Crc         = Crc32.GetCrc32(res.path),
                        ABName      = item.abName,
                        DependentAB = item.dependencies
                    };
                    ResItem tempRes;
                    if (!resItemDict.TryGetValue(resItem.Crc, out tempRes))
                    {
                        resItemDict.Add(resItem.Crc, resItem);
                    }
                    else
                    {
                        throw new Exception($"资源重复{resItem.AssetName}");
                    }
                }
            }
        }
コード例 #2
0
ファイル: ResMgr.cs プロジェクト: midgithub/MyGameFramework
    public ResourceRes <T> Load <T>(string name, bool cache = false) where T : Object
    {
        ResItem item = null;

        item = GetItemFromName(name);

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

        T tRes = null;

        if (htCache.Contains(item.path))
        {
            tRes = htCache[item.path] as T;
        }
        else
        {
            tRes = Resources.Load <T>(item.path);
        }

        if (tRes != null && cache && !htCache.ContainsKey(item.path))
        {
            htCache.Add(item.path, tRes);
        }

        Debug.Assert(tRes != null, item.path);
        return(new ResourceRes <T>(name, tRes));
    }
コード例 #3
0
    static void GenerateIndexFile(string destDir, string language, string moduleName, string indexFileName,
                                  string releasePath, string packagePath, bool useSubDir = true, FileType fileType = FileType.Zip,
                                  bool ignoreItems = false)
    {
        releasePath = "AssetBundles/" + SystemTag + "/" + releasePath;

        ResIndex resIndex = new ResIndex();

        resIndex.language    = language;
        resIndex.belong      = moduleName;
        resIndex.packageDict = new Dictionary <string, ResPack>();

        string[] dirs = new string[] { destDir };

        if (useSubDir)
        {
            dirs = Directory.GetDirectories(destDir);
        }

        for (int i = 0; i < dirs.Length; i++)
        {
            ResPack resPack = new ResPack();
            resPack.id = new FileInfo(dirs[i]).Name;

            if (ignoreItems == false)
            {
                resPack.items = new List <ResItem>();
                string[] files = Directory.GetFiles(dirs[i]);
                for (int j = 0; j < files.Length; j++)
                {
                    string   filePath = files[j];
                    FileInfo fileInfo = new FileInfo(filePath);
                    ResItem  resItem  = new ResItem();
                    resItem.Path = fileInfo.Name;
                    resItem.Md5  = MD5Util.Get(filePath);
                    resItem.Size = fileInfo.Length;
                    resPack.items.Add(resItem);
                }
            }

            resPack.packageType = fileType;
            if (fileType == FileType.Zip)
            {
                resPack.packageMd5   = MD5Util.Get(packagePath + "/" + resPack.id + ".zip");
                resPack.packageSize  = new FileInfo(packagePath + "/" + resPack.id + ".zip").Length;
                resPack.downloadPath = GetPackageStorePath() + "/" + resIndex.belong + "/" + resPack.id + ".zip";
            }
            else
            {
                resPack.downloadPath = GetPackageStorePath() + "/" + resIndex.belong;
            }

            resPack.releasePath = releasePath;
            resIndex.packageDict.Add(resPack.id, resPack);
        }

        string json = JsonConvert.SerializeObject(resIndex, Formatting.Indented);

        FileUtil.SaveFileText(OutputPath, indexFileName + ".json", json);
    }
コード例 #4
0
        public ResItem GetResItem(uint crc)
        {
            ResItem item = null;

            resItemDict.TryGetValue(crc, out item);
            return(item);
        }
コード例 #5
0
        public static void DownloadExtendCache(Action <string> onComplete = null, string tag = null, Action <string> onError = null)
        {
            _onComplete = onComplete;
            _onError    = onError;
            _tag        = tag;

            ResIndex resIndex = GetIndexFile(ResPath.Extend);
            ResPack  resPack  = resIndex.packageDict[ResPath.Extend];

            _releasePath = resPack.releasePath;
            if (resPack.packageType == FileType.Zip)
            {
                ResItem item = new ResItem()
                {
                    Md5  = resPack.packageMd5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath,
                    Size     = resPack.packageSize,
                    FileType = resPack.packageType
                };

                DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                     OnCompleteFullLoading, OnError, OnProgressFullLoading);
                LoadingProgress.Instance.Show(resPack.packageSize);
                LoadingProgress.Instance.SetPercent(0);
            }
        }
コード例 #6
0
        public ResItem LoadResAB(uint crc)
        {
            ResItem item = GetResItem(crc);

            if (item == null)
            {
                Debug.LogError($"res is null :{crc}");
                return(item);
            }

            if (item.AB != null)
            {
                return(item);
            }

            item.AB = LoadAB(item.ABName);

            if (item.DependentAB == null)
            {
                return(item);
            }

            foreach (var ab in item.DependentAB)
            {
                LoadAB(ab);
            }

            return(item);
        }
コード例 #7
0
ファイル: ResourceMgr.cs プロジェクト: brush1990/PEFramework
    //----------------------------------------------------------------//

    ///////////////////////////MainFunctions////////////////////////////
    public static Object GetInstantiateOB(string resName, ResType resType, ResCacheType cacheType = ResCacheType.Never)
    {
        ResKey  reskey = new ResKey(resType, resName);
        ResItem resItem;

        if (!ressDic.ContainsKey(reskey))
        {
            Object ob = LoadObj(resType, resName);
            if (ob != null)
            {
                resItem = new ResItem(ob, cacheType);
                ressDic.Add(reskey, resItem);
            }
            else
            {
                resItem = null;
            }
        }
        else
        {
            resItem = ressDic[reskey];
        }

        if (!ressDic.ContainsKey(reskey))
        {
            Debug.LogError("Load Res:" + reskey.name + "Error!");
            return(null);
        }
        return(Instantiate(resItem.obj));
    }
コード例 #8
0
ファイル: ResMgr.cs プロジェクト: midgithub/MyGameFramework
    private IEnumerator AsyncLoading <T>(ResItem item, Action <ResourceRes <T> > Oncomplete) where T : Object
    {
        T obj = null;

        if (!string.IsNullOrEmpty(item.path))
        {
            ResourceRequest req = Resources.LoadAsync <T>(item.path);
            if (req != null)
            {
                while (!req.isDone)
                {
                    yield return(null);
                }
                obj = req.asset as T;
            }
        }
        else
        {
            Debug.Log("path is null or empty");
        }

        if (Oncomplete != null)
        {
            Oncomplete(new ResourceRes <T>(item.name, obj));
        }
    }
コード例 #9
0
        public static void DownloadEvoCardAll(Action <string> onComplete = null, string tag = null)
        {
            _onComplete = onComplete;
            _tag        = tag;

            ResIndex resIndex = GetIndexFile(ResPath.EvoCardPackageIndex);

            DownloadManager.Clear();

            ResPack resPack = resIndex.packageDict["EvoCard"];

            _releasePath = resPack.releasePath;
            if (resPack.packageType == FileType.Zip)
            {
                ResItem item = new ResItem()
                {
                    Md5  = resPack.packageMd5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath,
                    Size     = resPack.packageSize,
                    FileType = resPack.packageType
                };

                _downloadingWindow          = PopupManager.ShowWindow <DownloadingWindow>(Constants.DownloadingWindowPath);
                _downloadingWindow.Content  = I18NManager.Get("Download_Downloading");
                _downloadingWindow.Progress = I18NManager.Get("Download_Progress", 0);
                DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                     OnCompleteEvoCard,
                                     OnErrorEvoCard, OnProgress);
            }
        }
コード例 #10
0
        public static void DownloadAllBundle(Action <string> onComplete, string tag = null)
        {
            _onComplete = onComplete;
            _tag        = tag;

            _releasePath = "";

            ResIndex resIndex = GetIndexFile(ResPath.AllResources);

            if (resIndex == null)
            {
                onComplete?.Invoke(tag);
                return;
            }

            ResPack resPack = resIndex.packageDict[ResPath.AllResources];

            if (resPack.packageType == FileType.Zip)
            {
                ResItem item = new ResItem()
                {
                    Md5  = resPack.packageMd5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath,
                    Size     = resPack.packageSize,
                    FileType = resPack.packageType
                };

                DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                     OnCompleteFullLoading, OnFullLoadingError, OnProgressFullLoading);

                LoadingProgress.Instance.Show(resPack.packageSize);
                LoadingProgress.Instance.SetPercent(0);
            }
        }
コード例 #11
0
        override protected void initImpl(ResItem res)
        {
            string text = res.getText(GetPath());

            Ctx.m_instance.m_aiSystem.behaviorTreeMgr.parseXml(text);

            base.initImpl(res);
        }
コード例 #12
0
ファイル: SkillActionRes.cs プロジェクト: zhutaorun/unitygame
        override protected void initImpl(ResItem res)
        {
            string text = res.getText(GetPath());
            m_attackActionSeq = new AttackActionSeq();
            m_attackActionSeq.parseXml(text);

            base.initImpl(res);
        }
コード例 #13
0
ファイル: ResMgr.cs プロジェクト: midgithub/MyGameFramework
    private ResItem GetItemFromName(string name)
    {
        ResItem resItem = ResList.Find((item) =>
        {
            return(item.name == name);
        });

        return(resItem);
    }
コード例 #14
0
        override protected void initImpl(ResItem res)
        {
            string text = res.getText(GetPath());

            m_attackActionSeq = new AttackActionSeq();
            m_attackActionSeq.parseXml(text);

            base.initImpl(res);
        }
コード例 #15
0
        public static void DownloadLoveDiaryCache(string musicId, Action <string> onComplete = null, Action onCancel = null, string tag = null)
        {
            _onComplete        = onComplete;
            _onLoveDiaryCancel = onCancel;
            _tag = tag;

            ResIndex resIndex = GetIndexFile(ResPath.Special);

            string packKey = "lovediary";

            if (!resIndex.packageDict.ContainsKey(packKey))
            {
                FlowText.ShowMessage(I18NManager.Get("Download_ErrorLoveDiary") + musicId);
                _onLoveDiaryCancel?.Invoke();
                return;
            }

            DownloadManager.Clear();
            ResPack resPack = resIndex.packageDict[packKey.ToString()];
            string  resPath = "music/mainplay/" + musicId + ".music";
            var     rm      = resPack.items.Find((m) => { return(m.Path == resPath); });

            if (rm == null)
            {
                return;
            }

            _releasePath = resPack.releasePath;
            if (resPack.packageType == FileType.Original)
            {
                ResItem item = new ResItem()
                {
                    Md5  = rm.Md5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath + "/" + resPath,
                    Size     = rm.Size,
                    FileType = resPack.packageType
                };

                //_downloadingWindow = PopupManager.ShowWindow<DownloadingWindow>(Constants.DownloadingWindowPath);
                //_downloadingWindow.Content = I18NManager.Get("Download_Downloading");
                //_downloadingWindow.Progress = I18NManager.Get("Download_Progress", 0);

                string storePath = AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + resPath;
                Debug.Log(storePath);
                var downItem = DownloadManager.Load(item, storePath, OnCompleteLoveDiary,
                                                    OnErrorLoveDiary, null, OnErrorLoveDiary);
                //_downloadingWindow.WindowActionCallback = evt =>
                //{
                //    if (evt == WindowEvent.Cancel)
                //    {
                //        onCancel?.Invoke();
                //        downItem.Cancel();
                //    }
                //};
            }
        }
コード例 #16
0
    private static ResItem CreateConfigItem(string realPath, string fileName, string refPath)
    {
        ResItem resItem = new ResItem {
            name = fileName, path = refPath
        };

        byte[] fileBytes = GetFileBytes(realPath);
        resItem.hash = GetMD5(fileBytes);
        resItem.size = fileBytes.Length;
        return(resItem);
    }
コード例 #17
0
        public virtual void onLoadEventHandle(IDispatchObject dispObj)
        {
            ResItem res = dispObj as ResItem;

            if (res.refCountResLoadResultNotify.resLoadState.hasSuccessLoaded())
            {
            }
            else if (res.refCountResLoadResultNotify.resLoadState.hasFailed())
            {
            }
        }
コード例 #18
0
        private static ResItem CreateConfigItem(string realPath, string fileName, string refPath)
        {
            ResItem resItem = new ResItem();

            resItem.name = fileName;
            resItem.path = refPath;
            byte[] platformFileBytes = getFileBytes(realPath);
            resItem.hash = getMD5(platformFileBytes);
            resItem.size = platformFileBytes.Length;

            return(resItem);
        }
コード例 #19
0
        public void UnloadRes(ResItem item)
        {
            if (item?.DependentAB == null || item.DependentAB.Count <= 0)
            {
                return;
            }
            foreach (var dpAB in item.DependentAB)
            {
                UnloadAB(dpAB);
            }

            UnloadAB(item.ABName);
        }
コード例 #20
0
    public static ResItem FetchItem(string path)
    {
        ResItem item = null;

        for (int i = 0; i < _ResList.Count; i++)
        {
            if (_ResList[i].path.Equals(path))
            {
                item = _ResList[i];
                break;
            }
        }
        return(item);
    }
コード例 #21
0
        protected void onLoadEventHandle(IDispatchObject dispObj)
        {
            ResItem res = dispObj as ResItem;

            if (res.refCountResLoadResultNotify.resLoadState.hasSuccessLoaded())
            {
                res.InstantiateObject("Anim/boxcampush");
            }
            else if (res.refCountResLoadResultNotify.resLoadState.hasFailed())
            {
            }

            Ctx.m_instance.m_resLoadMgr.unload("Anim/boxcampush", onLoadEventHandle);
        }
コード例 #22
0
 public static void AddRestItem(ResItem item)
 {
     if (item == null)
     {
         return;
     }
     for (int i = 0; i < _ResList.Count; i++)
     {
         if (_ResList[i].path.Equals(item.path))
         {
             _ResList[i] = item;
             return;
         }
     }
     _ResList.Add(item);
 }
コード例 #23
0
        public static void DownloadLoveStoryCache(int cardId, Action <string> onComplete = null, string tag = null, Action <string> onCancle = null)
        {
            _onComplete = onComplete;
            _tag        = tag;

            ResIndex resIndex = GetIndexFile(ResPath.LoveStoryIndex);

            if (!resIndex.packageDict.ContainsKey(cardId.ToString()))
            {
                FlowText.ShowMessage(I18NManager.Get("Download_ErrorRole") + cardId);
                return;
            }

            DownloadManager.Clear();

            ResPack resPack = resIndex.packageDict[cardId.ToString()];

            _releasePath = resPack.releasePath;
            if (resPack.packageType == FileType.Zip)
            {
                ResItem item = new ResItem()
                {
                    Md5  = resPack.packageMd5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath,
                    Size     = resPack.packageSize,
                    FileType = resPack.packageType
                };

                _downloadingWindow          = PopupManager.ShowWindow <DownloadingWindow>(Constants.DownloadingWindowPath);
                _downloadingWindow.Content  = I18NManager.Get("Download_Downloading");
                _downloadingWindow.Progress = I18NManager.Get("Download_Progress", 0);
                var downloadItem = DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                                        OnCompleteLoveStory,
                                                        OnErrorLoveStory, OnProgress);
                //downloadItems = downloadItem;
                _downloadingWindow.WindowActionCallback = evt =>
                {
                    if (evt == WindowEvent.Cancel)
                    {
                        downloadItem.Cancel();
                        onCancle?.Invoke(downloadItem.ErrorText);
                    }
                };
            }
        }
コード例 #24
0
        protected void testLoadAnimatorController()
        {
            LoadParam param;

            param = Ctx.m_instance.m_poolSys.newObject <LoadParam>();
            LocalFileSys.modifyLoadParam("Animation/Scene/CommonCard.controller", param);
            param.m_loadNeedCoroutine = false;
            param.m_resNeedCoroutine  = false;
            ResItem bbb = Ctx.m_instance.m_resLoadMgr.getAndLoad(param);

            System.Type type = bbb.getObject("").GetType();
            Ctx.m_instance.m_logSys.log(string.Format("类型名字 {0}", type.FullName));
            Ctx.m_instance.m_poolSys.deleteObj(param);

            //GameObject _go = UtilApi.createGameObject("AnimatorController");
            //Animator animator = _go.AddComponent<Animator>();
            //animator.runtimeAnimatorController = bbb.getObject() as ;
        }
コード例 #25
0
        private static void DownloadBackEndCache()
        {
            ResPack resPack = _backendPackQueue.Dequeue();

            _releasePath = resPack.releasePath;
            ResItem item = new ResItem()
            {
                Md5  = resPack.packageMd5,
                Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                       resPack.downloadPath,
                Size     = resPack.packageSize,
                FileType = resPack.packageType
            };

            Debug.LogError("StarDownloadBackEnd " + resPack.downloadPath);
            DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                 OnBackendStepEnd, OnError, OnProgressFullLoading);
            LoadingProgress.Instance.TotalSize = Math.Round(resPack.packageSize * 1f / 1048576f, 2);
        }
コード例 #26
0
ファイル: TableConverter.cs プロジェクト: yskgit/UnityFrame
    /// <summary>
    /// 存储json文件
    /// </summary>
    /// <param name="jsonFileName"></param>
    /// <returns></returns>
    private static ResFile ParseJsonToResFile(string jsonFileName)
    {
        List <string>         colName = new List <string>();
        List <List <string> > colItem = new List <List <string> >();

        if (!ParseJson(jsonFileName, colName, colItem))
        {
            Debug.LogError("can't parse json " + jsonFileName);
            return(null);
        }

        int rowCnt = colItem[0].Count;
        int colCnt = colName.Count;

        if (colCnt == 0 || rowCnt == 0)
        {
            Debug.LogError("empty file " + jsonFileName);
            return(null);
        }
        for (int i = 0; i < colItem.Count; ++i)
        {
            if (colItem[i].Count != rowCnt)
            {
                Debug.LogError("row isn't matched. of file " + jsonFileName);
                return(null);
            }
        }


        var res = new ResFile();

        for (int j = 0; j < colCnt; ++j)
        {
            var col = new ResItem();
            col.key   = colName[j];
            col.value = colItem[j];
            res.items.Add(col);
        }

        return(res);
    }
コード例 #27
0
    public static void UpdateData(string data)
    {
        JsonData jsonData = C_Json.GetJsonKeyJsonData(data, "_ResList");

        if (jsonData != null)
        {
            _ResList.Clear();
            for (int i = 0; i < jsonData.Count; i++)
            {
                ResItem resItem = new ResItem();
                resItem.name    = C_Json.GetJsonKeyString(jsonData[i], "name");
                resItem.path    = C_Json.GetJsonKeyString(jsonData[i], "path");
                resItem.resType = C_Json.GetJsonKeyString(jsonData[i], "resType");
                // resItem.overriden = C_Json.GetJsonKeyBool(jsonData[i], "overriden");
                if (string.IsNullOrEmpty(resItem.resType))
                {
                    continue;
                }
                else if (resItem.resType.Equals("texture"))
                {
                    resItem.textureType     = C_Json.GetJsonKeyInt(jsonData[i], "textureType");
                    resItem.readEnable      = C_Json.GetJsonKeyInt(jsonData[i], "readEnable");
                    resItem.gengrateMipMaps = C_Json.GetJsonKeyInt(jsonData[i], "gengrateMipMaps");
                    resItem.maxSize         = C_Json.GetJsonKeyString(jsonData[i], "maxSize");
                    resItem.format          = C_Json.GetJsonKeyInt(jsonData[i], "format");
                }
                else if (resItem.resType.Equals("audioclip"))
                {
                    resItem.loadtype          = C_Json.GetJsonKeyInt(jsonData[i], "loadtype");
                    resItem.compressionFormat = C_Json.GetJsonKeyInt(jsonData[i], "compressionFormat");
                    resItem.quality           = C_Json.GetJsonKeyString(jsonData[i], "quality");
                    resItem.sampleRateSet     = C_Json.GetJsonKeyInt(jsonData[i], "sampleRateSet");
                }

                _ResList.Add(resItem);
            }
        }
    }
コード例 #28
0
        public static void DownloadAllAudio(Action <string> onComplete = null, string tag = null)
        {
            _onComplete = onComplete;
            _tag        = tag;

            ResIndex resIndex = GetIndexFile(ResPath.AllAudioIndex);
            ResPack  resPack  = resIndex.packageDict["AllAudio"];

            _releasePath = resPack.releasePath;
            if (resPack.packageType == FileType.Zip)
            {
                ResItem item = new ResItem()
                {
                    Md5  = resPack.packageMd5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath,
                    Size     = resPack.packageSize,
                    FileType = resPack.packageType
                };

                _downloadingWindow          = PopupManager.ShowWindow <DownloadingWindow>(Constants.DownloadingWindowPath);
                _downloadingWindow.Content  = I18NManager.Get("Download_Downloading");
                _downloadingWindow.Progress = I18NManager.Get("Download_Progress", 0);
                var downItem = DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                                    OnComplete,
                                                    OnError, OnProgressAll);

                _downloadingWindow.WindowActionCallback = evt =>
                {
                    if (evt == WindowEvent.Cancel)
                    {
                        downItem.Cancel();
                    }
                };
            }
        }
コード例 #29
0
        public static void DownloadEvoCard(int cardId, Action <string> onComplete = null, string tag = null)
        {
            _onComplete = onComplete;
            _tag        = tag;

            ResIndex resIndex = GetIndexFile(ResPath.EvoCardIndex);
            ResPack  resPack  = resIndex.packageDict["EvoCard"];

            string  id      = cardId + ".bytes";
            ResItem resItem = null;

            foreach (var item in resPack.items)
            {
                if (item.Path == id)
                {
                    resItem = item;
                    break;
                }
            }

            if (resItem == null)
            {
                FlowText.ShowMessage(I18NManager.Get("Download_IndexNoExist") + cardId);
            }
            else
            {
                resItem.Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                               resPack.downloadPath + "/" + id;

                _downloadingWindow          = PopupManager.ShowWindow <DownloadingWindow>(Constants.DownloadingWindowPath);
                _downloadingWindow.Content  = I18NManager.Get("Download_Downloading");
                _downloadingWindow.Progress = I18NManager.Get("Download_Progress", 0);
                DownloadManager.Load(resItem, AssetLoader.ExternalHotfixPath + "/" + resPack.releasePath + "/" + id,
                                     OnCompleteEvoCard, OnErrorEvoCard, OnProgress);
            }
        }
コード例 #30
0
ファイル: InsResBase.cs プロジェクト: zhutaorun/unitygame
        // 这个是内部初始化实现,初始化都重载这个,但是现在很多都是重在了
        virtual protected void initImpl(ResItem res)
        {

        }
コード例 #31
0
        public static void GenerateResConfig(string outputPath, string resVersion, bool generateClass, string classPath)
        {
            List <AssetBundleInfo> assetBundleInfos = new List <AssetBundleInfo>();

            string[] abNames = AssetDatabase.GetAllAssetBundleNames();

            foreach (var abName in abNames)
            {
                string[] astNames = AssetDatabase.GetAssetPathsFromAssetBundle(abName);

                AssetBundleInfo abInfo = new AssetBundleInfo();
                abInfo.name   = abName;
                abInfo.assets = astNames;

                assetBundleInfos.Add(abInfo);
            }


            string assetConfig = JsonUtility.ToJson(new AssetConfig()
            {
                abInfos = assetBundleInfos
            }, true);

            File.WriteAllText(outputPath + "/assetconfig.json", assetConfig);


            CopyResFiles(outputPath);

            AssetDatabase.Refresh();



            ABConfig abConfig = new ABConfig
            {
                items      = new List <ResItem>(),
                resversion = resVersion
            };

            //避免把resconfig 本身也统计进去
            if (File.Exists(outputPath + "/resconfig.json"))
            {
                File.Delete(outputPath + "/resconfig.json");
            }


            //此处是在Asset目录之外 的output目录遍历的,所以没有.meta文件
            string[] files = Directory.GetFiles(outputPath, "*", SearchOption.AllDirectories)
                             .Where(s => s.GetFileExtendName() != ".manifest" && s.GetFileExtendName() != ".DS_Store").ToArray();

            foreach (var file in files)
            {
                string  realPath = Path.GetFullPath(file);
                string  refPath  = file.Replace(outputPath + Path.DirectorySeparatorChar, "");
                ResItem resItem  = CreateConfigItem(realPath, Path.GetFileNameWithoutExtension(file), refPath);
                abConfig.items.Add(resItem);
            }

            string content = JsonUtility.ToJson(abConfig, true);

            File.WriteAllText(outputPath + "/resconfig.json", content);


            if (generateClass)
            {
                if (!classPath.EndsWith(".cs"))
                {
                    classPath += ".cs";
                }

                string dir = Path.GetDirectoryName(classPath);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }


                var          path   = Path.GetFullPath(classPath);
                StreamWriter writer = new StreamWriter(File.Open(path, FileMode.Create));
                PTBundleInfoGenerator.WriteClass(writer, "PTGame.AssetBundle", assetBundleInfos);
                writer.Close();
                AssetDatabase.Refresh();
            }
        }
コード例 #32
0
ファイル: InsResBase.cs プロジェクト: zhutaorun/unitygame
 virtual public void failed(ResItem res)
 {
     unload();
     refCountResLoadResultNotify.onLoadEventHandle(this);
 }
コード例 #33
0
ファイル: ExcelReader.cs プロジェクト: linxscc/LoveGame
    private static void CreateSpecial(ExcelWorksheet worksheet, string resId)
    {
        ResIndex resIndex = new ResIndex();

        resIndex.packageDict = new Dictionary <string, ResPack>();

//        1内容	2筛选路径	3白名单	4黑名单 5ID
        var row = worksheet.Dimension.End.Row;

        List <BundleFilter> filterList = new List <BundleFilter>();
        BundleFilter        filter     = null;

        for (int i = 2; i < row; i++)
        {
            object date = worksheet.Cells[i, 2].Value;
            if (date != null)
            {
                filter = new BundleFilter();
                filterList.Add(filter);
                filter.DirPath = date.ToString().Replace("\\", "/");

                string rootFolder = filter.DirPath;

                rootFolder = PackageManager.GetAssetBundleDir() + "/" + rootFolder;

                filter.BlackList = new BlackList();
                filter.WhiteList = new WhiteList();

                filter.BlackList.RootFolder = rootFolder;
                filter.WhiteList.RootFolder = rootFolder;

                AddToNameList(filter.WhiteList, worksheet.Cells[i, 3].Value);
                AddToNameList(filter.BlackList, worksheet.Cells[i, 4].Value);

                filter.Id = worksheet.Cells[i, 5].Value.ToString();
            }
            else
            {
                AddToNameList(filter.WhiteList, worksheet.Cells[i, 3].Value);
                AddToNameList(filter.BlackList, worksheet.Cells[i, 4].Value);
            }
        }

        Dictionary <string, FileInfo> fileDict = new Dictionary <string, FileInfo>();

        foreach (var bundleFilter in filterList)
        {
            List <FileInfo> files = bundleFilter.SearchFile();
            foreach (var fileInfo in files)
            {
                string key = fileInfo.FullName.Replace("\\", "/");
                if (!fileDict.ContainsKey(key))
                {
                    fileDict.Add(key, fileInfo);
                }
            }
            string releasePath = "AssetBundles/" + PackageManager.SystemTag;

            ResPack resPack = new ResPack();
            resPack.id           = bundleFilter.Id;
            resPack.downloadPath = PackageManager.GetPackageStorePath() + "/" + resId;
            resPack.releasePath  = releasePath;
            resPack.items        = new List <ResItem>();
            resIndex.packageDict.Add(resPack.id, resPack);
            foreach (var fileInfo in fileDict)
            {
                ResItem resItem = new ResItem();
                resItem.Path        = GetRelatePath(fileInfo.Value.FullName);
                resItem.Md5         = MD5Util.Get(fileInfo.Key);
                resItem.Size        = fileInfo.Value.Length;
                resPack.packageType = FileType.Original;
                resPack.items.Add(resItem);

                CopyFile(fileInfo.Value.FullName, PackageManager.OutputPath + resId + "/" + resItem.Path);
            }
        }

        string json = JsonConvert.SerializeObject(resIndex, Formatting.Indented);

        FileUtil.SaveFileText(PackageManager.OutputPath, resId + ".json", json);
    }
コード例 #34
0
ファイル: SkillActionRes.cs プロジェクト: zhutaorun/unitygame
 override public void failed(ResItem res)
 {
     base.failed(res);
 }
コード例 #35
0
ファイル: InsResBase.cs プロジェクト: zhutaorun/unitygame
 public void init(ResItem res)
 {
     initImpl(res);         // 内部初始化完成后,才分发事件
     refCountResLoadResultNotify.onLoadEventHandle(this);
 }