public void GetMaterials() { if (isCanGetMaterials == false) { return; } isCanGetMaterials = false; if (matEntitys == null) { matEntitys = new List <StardardMaterialEntity>(); } Renderer[] renders = gameObject.GetComponentsInChildren <Renderer>(true); foreach (Renderer r in renders) { foreach (Material m in r.sharedMaterials) { StardardMaterialEntity entity = matEntitys.Find((item) => item.mat == m); if (entity == null) { if (m == null || m.name == "Default-Material") { continue; } StardardMaterialEntity entityT = new StardardMaterialEntity(m); matEntitys.Add(entityT); } } } //SkinnedMeshRenderer[] skinnedMeshRenderers = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(true); //foreach (Renderer r in skinnedMeshRenderers) //{ // foreach (Material m in r.sharedMaterials) // { // StardardMaterialEntity entity = matEntitys.Find((item) => item.mat == m); // if (entity == null) // { // if (m == null) // { // continue; // } // StardardMaterialEntity entityT = new StardardMaterialEntity(m); // matEntitys.Add(entityT); // } // } //} }
/// <summary> /// 获取标准材质实体 /// </summary> public static StardardMaterialEntity GetStardardMaterialBackups(Material mat) { StardardMaterialEntity entity = new StardardMaterialEntity(mat); return(entity); }