public void ProcessResource(int type, string name, ResourceUnit parentRes) { if (mTypeFileDictionary.ContainsKey(type)) { Dictionary <string, ResourceUnit> fileDictionary = mTypeFileDictionary[type]; if (fileDictionary.ContainsKey(name)) { ResourceUnit res = fileDictionary[name]; res.SetResourceAnalyzeType(type); res.AddReferrence(parentRes); parentRes.AddInclude(res); AnalyzeBase analyzer = GetAnalyzer(type); if (null != analyzer) { if (!res.IsQueued()) { res.SetQueued(); mResUnitQueue.Enqueue(res); } } } } }
public void AnalyzeResourceFiles() { // Step 1: Scene mScenePath = "D:\\XKX\\Main\\RTM0_02\\Client\\Assets\\Scene"; DirectoryInfo sceneDir = new DirectoryInfo(mScenePath); FileInfo[] fis = sceneDir.GetFiles("*.unity", SearchOption.TopDirectoryOnly); int sceneType = (int)(AnalyzeType.AT_SCENE); Dictionary <string, ResourceUnit> sceneFileDictionary = mTypeFileDictionary[sceneType]; foreach (FileInfo fi in fis) { string name = fi.DirectoryName.Replace('\\', '/'); name = name.Remove(0, mAssetPathStartIndex); name = name + "/" + fi.Name; if (sceneFileDictionary.ContainsKey(name)) { sceneFileDictionary[name].SetResourceAnalyzeType(sceneType); sceneFileDictionary[name].SetQueued(); mResUnitQueue.Enqueue(sceneFileDictionary[name]); } } // Step 2: Table // NPC List <string> tableFileList = new List <string> { "Assets/Resources/TableFile/NpcAttr.txt", "4", "Prefab/NPC/", "Assets/Resources/TableFile/UIInterface.txt", "2", "" }; int tableType = (int)(AnalyzeType.AT_TXT); Dictionary <string, ResourceUnit> tableFileDictionary = mTypeFileDictionary[tableType]; for (int i = 0; i < tableFileList.Count; i += 3) { string name = tableFileList[i]; int column = Convert.ToInt32(tableFileList[i + 1]); string secName = tableFileList[i + 2]; if (tableFileDictionary.ContainsKey(name)) { tableFileDictionary[name].SetResourceAnalyzeType(tableType); tableFileDictionary[name].SetQueued(); tableFileDictionary[name].SetTableValidColmn(column); tableFileDictionary[name].SetTablePathSectorName(secName); mResUnitQueue.Enqueue(tableFileDictionary[name]); } } // Player string playerPathName_0 = "D:\\XKX\\Main\\RTM0_02\\Client\\Assets\\Resources\\Prefab\\Player\\Player_SL.prefab"; string playerPathName_1 = "D:\\XKX\\Main\\RTM0_02\\Client\\Assets\\Resources\\Prefab\\Player\\Player_EM.prefab"; int prefabType = (int)(AnalyzeType.AT_PREFAB); Dictionary <string, ResourceUnit> prefabFileDictionary = mTypeFileDictionary[prefabType]; playerPathName_0 = playerPathName_0.Replace('\\', '/'); playerPathName_0 = playerPathName_0.Remove(0, mAssetPathStartIndex); if (prefabFileDictionary.ContainsKey(playerPathName_0)) { prefabFileDictionary[playerPathName_0].SetResourceAnalyzeType(prefabType); prefabFileDictionary[playerPathName_0].SetQueued(); mResUnitQueue.Enqueue(prefabFileDictionary[playerPathName_0]); } playerPathName_1 = playerPathName_1.Replace('\\', '/'); playerPathName_1 = playerPathName_1.Remove(0, mAssetPathStartIndex); if (prefabFileDictionary.ContainsKey(playerPathName_1)) { prefabFileDictionary[playerPathName_1].SetResourceAnalyzeType(prefabType); prefabFileDictionary[playerPathName_1].SetQueued(); mResUnitQueue.Enqueue(prefabFileDictionary[playerPathName_1]); } while (mResUnitQueue.Count > 0) { ResourceUnit resUnit = mResUnitQueue.Dequeue(); AnalyzeBase analyzer = GetAnalyzer(resUnit.GetResourceAnalyzeType()); if (null != analyzer) { analyzer.Analyze(resUnit); } } }
private void RegisterSingleAnalyzer(AnalyzeBase analyzer) { mAnalyzeDictionary.Add(analyzer.GetAnalyzeType(), analyzer); }