/// <summary> /// 收集依赖 /// </summary> public static void CollectRendererDependencies(GameObject go, bool bCollectChildren, List <ResDepBase> list, GameObject refObject = null, bool bCollectLightmap = true) { // 模型 { MeshFilter meshfilter = null; if (refObject != null) { meshfilter = refObject.GetComponent <MeshFilter>(); } var dep = ResDepMesh.CollectDependencies(go, bCollectChildren, meshfilter); if (null != dep) { list.Add(dep); } } // 蒙皮 { var dep = ResDepSkinnedMesh.CollectDependencies(go, bCollectChildren); if (null != dep) { list.Add(dep); } } // 贴图 { var dep = ResDepTexture.CollectDependencies(go, bCollectChildren); if (null != dep) { list.Add(dep); } } // Lightmap if (bCollectLightmap) { var dep = ResDepLightMap.CollectDependencies(refObject ?? go, bCollectChildren); if (null != dep) { list.Add(dep); } } }
/// <summary> /// 收集依赖 /// </summary> /// <param name="go"></param> /// <returns></returns> public static ResDepMesh CollectDependencies(GameObject go, bool bCollectChildren, MeshFilter meshfilter) { ResDepMesh dep = null; EditorUtil.VisitComponents <MeshFilter>(go, bCollectChildren, filter => { // 没有Mesh if (null == filter.sharedMesh) { Debug.LogErrorFormat("Null mesh of \"{0}\"!", go.name); return; } if (null == dep) { dep = new ResDepMesh(); } var item = new Item(); item.go = go; if (meshfilter != null) { item.filter = meshfilter; } else { item.filter = filter; } item.mesh = filter.sharedMesh; dep._items.Add(item); AssetsBackuper.inst.Backup(item.filter); }); return(dep); }