public void Process(PlayerModelHair playerModelHair, HairDyeCollection dyeCollection, HairDye dye, MaterialPropertyBlock block) { List <SkinnedMeshRenderer> obj = Pool.GetList <SkinnedMeshRenderer>(); playerModelHair.gameObject.GetComponentsInChildren(true, obj); foreach (SkinnedMeshRenderer item in obj) { if (!(item.sharedMesh == null) && !(item.sharedMaterial == null)) { string materialName = item.sharedMesh.name; string name2 = item.sharedMaterial.name; if (!item.gameObject.activeSelf) { item.gameObject.SetActive(true); } for (int i = 0; i < MeshReplacements.Length; i++) { MeshReplacements[i].Test(materialName); } if (dye != null && item.gameObject.activeSelf) { dye.Apply(dyeCollection, block); } } } Pool.FreeList(ref obj); }
public void Process(PlayerModelHair playerModelHair, HairDyeCollection dyeCollection, HairDye dye, MaterialPropertyBlock block) { PlayerModelHair.RendererMaterials replace; List <SkinnedMeshRenderer> list = Pool.GetList <SkinnedMeshRenderer>(); playerModelHair.gameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true, list); foreach (SkinnedMeshRenderer bones in list) { if (bones.sharedMesh == null || bones.sharedMaterial == null) { continue; } string str = bones.sharedMesh.name; string str1 = bones.sharedMaterial.name; if (!bones.gameObject.activeSelf) { bones.gameObject.SetActive(true); } for (int i = 0; i < (int)this.MeshReplacements.Length; i++) { if (this.MeshReplacements[i].Test(str)) { SkinnedMeshRenderer skinnedMeshRenderer = this.MeshReplacements[i].Replace; if (skinnedMeshRenderer != null) { bones.sharedMesh = skinnedMeshRenderer.sharedMesh; bones.rootBone = skinnedMeshRenderer.rootBone; bones.bones = this.MeshReplacements[i].GetBones(); } else { bones.gameObject.SetActive(false); } } } if (!playerModelHair.Materials.TryGetValue(bones, out replace)) { Debug.LogWarning(string.Concat("[HairSet.Process] Missing cached renderer materials in ", playerModelHair.name)); } else { Array.Copy(replace.original, replace.replacement, (int)replace.original.Length); for (int j = 0; j < (int)replace.original.Length; j++) { for (int k = 0; k < (int)this.MaterialReplacements.Length; k++) { if (this.MaterialReplacements[k].Test(replace.names[j])) { replace.replacement[j] = this.MaterialReplacements[k].Replace; } } } bones.sharedMaterials = replace.replacement; } if (dye == null || !bones.gameObject.activeSelf) { continue; } dye.Apply(dyeCollection, block); } Pool.FreeList <SkinnedMeshRenderer>(ref list); }
public void Process( PlayerModelHair playerModelHair, HairDyeCollection dyeCollection, HairDye dye, MaterialPropertyBlock block) { List <SkinnedMeshRenderer> list = (List <SkinnedMeshRenderer>)Pool.GetList <SkinnedMeshRenderer>(); ((Component)playerModelHair).get_gameObject().GetComponentsInChildren <SkinnedMeshRenderer>(true, (List <M0>)list); using (List <SkinnedMeshRenderer> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { SkinnedMeshRenderer current = enumerator.Current; if (!Object.op_Equality((Object)current.get_sharedMesh(), (Object)null) && !Object.op_Equality((Object)((Renderer)current).get_sharedMaterial(), (Object)null)) { string name = ((Object)current.get_sharedMesh()).get_name(); ((Object)((Renderer)current).get_sharedMaterial()).get_name(); if (!((Component)current).get_gameObject().get_activeSelf()) { ((Component)current).get_gameObject().SetActive(true); } for (int index = 0; index < this.MeshReplacements.Length; ++index) { if (this.MeshReplacements[index].Test(name)) { SkinnedMeshRenderer replace = this.MeshReplacements[index].Replace; if (Object.op_Equality((Object)replace, (Object)null)) { ((Component)current).get_gameObject().SetActive(false); } else { current.set_sharedMesh(replace.get_sharedMesh()); current.set_rootBone(replace.get_rootBone()); current.set_bones(this.MeshReplacements[index].GetBones()); } } } PlayerModelHair.RendererMaterials rendererMaterials; if (playerModelHair.Materials.TryGetValue((Renderer)current, out rendererMaterials)) { Array.Copy((Array)rendererMaterials.original, (Array)rendererMaterials.replacement, rendererMaterials.original.Length); for (int index1 = 0; index1 < rendererMaterials.original.Length; ++index1) { for (int index2 = 0; index2 < this.MaterialReplacements.Length; ++index2) { if (this.MaterialReplacements[index2].Test(rendererMaterials.names[index1])) { rendererMaterials.replacement[index1] = this.MaterialReplacements[index2].Replace; } } } ((Renderer)current).set_sharedMaterials(rendererMaterials.replacement); } else { Debug.LogWarning((object)("[HairSet.Process] Missing cached renderer materials in " + ((Object)playerModelHair).get_name())); } if (dye != null && ((Component)current).get_gameObject().get_activeSelf()) { dye.Apply(dyeCollection, block); } } } } // ISSUE: cast to a reference type Pool.FreeList <SkinnedMeshRenderer>((List <M0>&) ref list); }