public void UIAssetImport() { string DynamicUIPath = Application.dataPath + AssetBundleImporter.UIDynamicAssetPatch.Remove(0, AssetBundleImporter.UIDynamicAssetPatch.IndexOf('/')); if (Directory.Exists(DynamicUIPath)) { DirectoryInfo fromDirInfo = new DirectoryInfo(DynamicUIPath); FileInfo[] allPngFiles = fromDirInfo.GetFiles("*.png", SearchOption.AllDirectories); m_ConfigTable.Clear(); string tmpPath = string.Empty; foreach (var files in allPngFiles) { tmpPath = files.FullName.Remove(0, files.FullName.IndexOf("Assets")); UFileData data = new UFileData(); data.configData = AssetBundleImporter.MakeTextureAssetBundleFromReference(tmpPath, string.Empty); if (null != data.configData) { PostprocessUITextureToCSV.nEditorInstance.InsetConfig(data); } else { Debug.LogError("取得UI资源失败:" + tmpPath); continue; } } PostprocessUITextureToCSV.nEditorInstance.ExportConfig(); } }
public void BakeRender(Water hostWater) { RefAreaRootObjTable.Clear(); ClearBake(hostWater); renderCheck.Clear(); hostWater.allTextureConfig.Clear(); hostWater.WaterRefObjRoot = new GameObject(); hostWater.WaterRefObjRoot.name = "WaterRefObjRoot"; hostWater.WaterRefObjRoot.transform.position = Vector3.zero; hostWater.WaterRefObjRoot.transform.rotation = Quaternion.identity; hostWater.WaterRefObjRoot.transform.localScale = Vector3.one; hostWater.allVisibleRenderList.Clear(); List <MeshRenderer> MeshRendersList = new List <MeshRenderer>(); List <SkinnedMeshRenderer> SkinnedMeshRenderList = new List <SkinnedMeshRenderer>(); MeshRendersList.AddRange(GameObject.FindObjectsOfType <MeshRenderer>()); SkinnedMeshRenderList.AddRange(GameObject.FindObjectsOfType <SkinnedMeshRenderer>()); MeshRenderer waterRender = hostWater.GetComponent <MeshRenderer>(); Collider waterCollider = hostWater.GetComponent <Collider>(); if (waterRender) { if (!waterCollider) { waterCollider = hostWater.gameObject.AddComponent <MeshCollider>(); } if (waterRender.sharedMaterial) { foreach (string spro in WaterTexturesPropertyNames) { if (waterRender.sharedMaterial.HasProperty(spro)) { Texture t = waterRender.sharedMaterial.GetTexture(spro); if (t) { string patch = AssetDatabase.GetAssetPath(t); if (!string.Empty.Equals(patch)) { ResConfigData cof = AssetBundleImporter.MakeTextureAssetBundleFromReference(patch, string.Empty); SceneTextureConfigData cd = new SceneTextureConfigData(); cd.AssetBundleName = cof.AssetBundleName; cd.AssetGUID = cof.AssetGUID; cd.AssetName = cof.AssetName; cd.ShaderKeyWordName = spro; if (null != cof) { hostWater.allTextureConfig.Add(cd); } } } } } } foreach (BoxCollider box in hostWater.WaterRefAeraList) { GameObject go = new GameObject(); go.name = box.gameObject.name; go.transform.SetParent(hostWater.WaterRefObjRoot.transform); go.transform.localPosition = Vector3.zero; go.transform.rotation = Quaternion.identity; go.transform.localScale = Vector3.one; hostWater.WaterRefAeraRootObjList.Add(go); RefAreaRootObjTable.Add(box, go); } BakeRender_MeshRender(MeshRendersList, hostWater, waterRender, waterCollider); BakeRender_SkinnedMeshRender(SkinnedMeshRenderList, hostWater, waterRender, waterCollider); } hostWater.bBaked = true; }
public void LoadFiles(UFileData data, string currentPath, int depth = 0) { GUIContent content = GetGUIContent(currentPath); if (content != null) { data.depth = depth; data.content = content; string patch1 = currentPath.Replace("\\", "/"); data.assetPath = patch1; if (patch1.Contains('.')) { ResConfigData config = AssetBundleImporter.MakeTextureAssetBundleFromReference(patch1, string.Empty); if (null == config) { Debug.LogError("找不资源的,资源路径:" + patch1); } data.configData = config; } } //当前路径下所有文件信息 foreach (var path in Directory.GetFiles(currentPath)) { content = GetGUIContent(path); if (content != null) { UFileData child = new UFileData(); child.depth = depth + 1; child.content = content; string patch1 = path.Replace("\\", "/"); child.assetPath = patch1; if (patch1.Contains('.')) { ResConfigData config = AssetBundleImporter.MakeTextureAssetBundleFromReference(patch1, string.Empty); if (null == config) { Debug.LogError("找不资源的,资源路径:" + patch1); } child.configData = config; } data.childs.Add(child); } } //WillTodo:排序这里无法判断没ID的图片,先不用 //data.childs.Sort((x, y) => //{ // UFileData XData = x as UFileData; // UFileData YData = y as UFileData; // int idX = Convert.ToInt32(XData.assetPath.Substring(XData.assetPath.LastIndexOf('_') + 1, XData.assetPath.LastIndexOf('.') - XData.assetPath.LastIndexOf('_') - 1)); // int idY = Convert.ToInt32(YData.assetPath.Substring(YData.assetPath.LastIndexOf('_') + 1, YData.assetPath.LastIndexOf('.') - YData.assetPath.LastIndexOf('_') - 1)); // return idX.CompareTo(idY); //}); foreach (var path in Directory.GetDirectories(currentPath)) { UFileData childDir = new UFileData(); data.childs.Add(childDir); LoadFiles(childDir, path, depth + 1); } }