public IAssetRequest CreateAssetRequest(string path, AssetRequestFinishedEventHandler callback, AssetPRI assetPRI, EnumAssetType assetType)
        {
            if (string.IsNullOrEmpty(path))
            {
                AssetLogger.Error("string.IsNullOrEmpty(path) == true");
                return(null);
            }
            string arg  = Path.GetDirectoryName(path).ToLower();
            string text = LocalResourceManager.ChangePathToFilenameWithoutExtension(path);

            path = string.Format("data/{0}/{1}.ab", arg, text);
            ResourceData resourceData = CollectDepResourceDataMap.RefResource(text, path, 0, assetType);

            return(this.CreateAssetRequest(resourceData, null, callback, assetPRI));
        }
 /// <summary>
 /// 初始化UI资源配置信息,从Json读取数据转成CollectDepResourceDataMap类型实例,并初始化
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 private bool InitUIResourceData(string path)
 {
     using (StreamReader streamReader = new StreamReader(path, Encoding.UTF8))
     {
         JsonReader reader = new JsonReader(streamReader);
         this.m_DicUIResourceData = JsonMapper.ToObject <CollectDepResourceDataMap>(reader);
     }
     if (this.m_DicUIResourceData == null)
     {
         this.m_DicUIResourceData = new CollectDepResourceDataMap();
         return(false);
     }
     CollectDepResourceDataMap.AddResourceDatas(this.m_DicUIResourceData.mDicResourceData); //初始化<string,ResoureData>ALL(包括独立和带引用)
     this.m_DicUIResourceData.mDicResourceData.Clear();                                     //清除从配置信息加载的资源集合
     return(true);
 }
 /// <summary>
 /// 初始化图集资源,从Json读取数据转成CollectDepResourceDataMap类型实例,并初始化
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 private bool InitAtlasResourceData(string path)
 {
     using (StreamReader streamReader = new StreamReader(path, Encoding.UTF8))
     {
         JsonReader reader = new JsonReader(streamReader);
         this.m_DicAtlasResourceData = JsonMapper.ToObject <CollectDepResourceDataMap>(reader);
     }
     if (this.m_DicAtlasResourceData == null)
     {
         this.m_DicAtlasResourceData = new CollectDepResourceDataMap();
         return(false);
     }
     CollectDepResourceDataMap.AddResourceDatas(this.m_DicAtlasResourceData.mDicResourceData);
     this.m_DicAtlasResourceData.mDicResourceData.Clear();
     return(true);
 }
        public IAssetRequest LoadScene(string path, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType)
        {
            IAssetRequest result;

            if (string.IsNullOrEmpty(path))
            {
                AssetLogger.Error("string.IsNullOrEmpty(path) == true");
                result = null;
            }
            else
            {
                string directoryName = Path.GetDirectoryName(path);
                string text          = LocalResourceManager.ChangePathToFilenameWithoutExtension(path);
                path = string.Format("data/{0}/{1}.unity3d", directoryName, text);
                ResourceData resourceData = CollectDepResourceDataMap.RefResource(text, path, 0, EnumAssetType.eAssetType_Scene);
                result = this.CreateAssetRequest(resourceData, null, callBackFun, assetPRIType);
            }
            return(result);
        }
예제 #5
0
    private static void DumpResourceInfoFile()
    {
        if (allLevelAssets.Count == 0)
        {
            return;
        }
        CollectDepResourceDataMap uiMap     = new CollectDepResourceDataMap();
        CollectDepResourceDataMap effectMap = new CollectDepResourceDataMap();
        CollectDepResourceDataMap atlasMap  = new CollectDepResourceDataMap();

        for (int level = 1; level <= allLevelAssets.Count; level++)
        {
            Dictionary <string, AssetUnit> levelAssets = allLevelAssets[level];
            foreach (var current in levelAssets)//Assets/Resources/ui/233.prefab
            {
                //取得资源的名称,不包括后缀名
                current.Value.mAssetSize = GetFileSize(current.Value.mPath);
                foreach (var dep in current.Value.mAllDependencies)
                {
                    for (int level1 = 1; level1 <= allLevelAssets.Count; level1++)
                    {
                        Dictionary <string, AssetUnit> levelAssets1 = allLevelAssets[level1];
                        foreach (var current1 in levelAssets1)
                        {
                            if (dep == current1.Key)
                            {
                                current1.Value.mRefCount++;
                            }
                        }
                    }
                }
                if (current.Value.mAllDependencies.Count >= 2)
                {
                    try
                    {
                        current.Value.mAllDependencies.Sort((left, right) =>
                        {
                            if (allFiles[left].mIndex > allFiles[right].mIndex)
                            {
                                return(1);
                            }
                            else if (allFiles[left].mIndex == allFiles[right].mIndex)
                            {
                                return(0);
                            }
                            else
                            {
                                return(-1);
                            }
                        });
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e.ToString());
                    }
                }
            }
        }
        for (int level2 = 1; level2 <= allLevelAssets.Count; level2++)
        {
            Dictionary <string, AssetUnit> levelAssets = allLevelAssets[level2];
            foreach (var current in levelAssets)
            {
                Debug.Log(current.Value.mName);
                if (current.Value.mName.Contains("ui_"))
                {
                    uiMap.InitResourceData(current.Value, allFiles);
                    if (level2 > 1)
                    {
                        uiMap.InitCollectDepData(current.Value);
                    }
                }
                if (current.Value.mName.Contains("atla"))
                {
                    atlasMap.InitResourceData(current.Value, allFiles);
                    if (level2 > 1)
                    {
                        atlasMap.InitCollectDepData(current.Value);
                    }
                }
            }
        }
        WirteToFile(JsonMapper.ToJson(uiMap), "ui.config");
        WirteToFile(JsonMapper.ToJson(atlasMap), "atlas.config");
    }