public static SkinnedMeshRendererCache.RigInfo Get( SkinnedMeshRenderer renderer) { SkinnedMeshRendererCache.RigInfo rigInfo; if (!SkinnedMeshRendererCache.dictionary.TryGetValue(renderer.get_sharedMesh(), out rigInfo)) { rigInfo = new SkinnedMeshRendererCache.RigInfo(); Transform rootBone = renderer.get_rootBone(); Transform[] bones = renderer.get_bones(); if (Object.op_Equality((Object)rootBone, (Object)null)) { Debug.LogWarning((object)("Renderer without a valid root bone: " + ((Object)renderer).get_name() + " " + ((Object)renderer.get_sharedMesh()).get_name()), (Object)((Component)renderer).get_gameObject()); return(rigInfo); } ((Component)renderer).get_transform().set_position(Vector3.get_zero()); ((Component)renderer).get_transform().set_rotation(Quaternion.get_identity()); ((Component)renderer).get_transform().set_localScale(Vector3.get_one()); rigInfo.root = ((Object)rootBone).get_name(); rigInfo.rootHash = rigInfo.root.GetHashCode(); rigInfo.bones = ((IEnumerable <Transform>)bones).Select <Transform, string>((Func <Transform, string>)(x => ((Object)x).get_name())).ToArray <string>(); rigInfo.boneHashes = ((IEnumerable <string>)rigInfo.bones).Select <string, int>((Func <string, int>)(x => x.GetHashCode())).ToArray <int>(); rigInfo.transforms = ((IEnumerable <Transform>)bones).Select <Transform, Matrix4x4>((Func <Transform, Matrix4x4>)(x => ((Component)x).get_transform().get_localToWorldMatrix())).ToArray <Matrix4x4>(); rigInfo.rootTransform = ((Component)renderer.get_rootBone()).get_transform().get_localToWorldMatrix(); SkinnedMeshRendererCache.dictionary.Add(renderer.get_sharedMesh(), rigInfo); } return(rigInfo); }
public static Transform FindRig(this SkinnedMeshRenderer renderer) { Transform parent = ((Component)renderer).get_transform().get_parent(); Transform transform = renderer.get_rootBone(); while (Object.op_Inequality((Object)transform, (Object)null) && Object.op_Inequality((Object)transform.get_parent(), (Object)null) && Object.op_Inequality((Object)transform.get_parent(), (Object)parent)) { transform = transform.get_parent(); } return(transform); }
private void AssignedWeightsAndSetBoundsLoop(Transform t, Bounds bounds, Transform rootBone = null) { SkinnedMeshRenderer component1 = (SkinnedMeshRenderer)((Component)t).GetComponent <SkinnedMeshRenderer>(); if (Object.op_Implicit((Object)component1)) { int length = component1.get_bones().Length; Transform[] transformArray = new Transform[length]; GameObject gameObject = (GameObject)null; for (int index = 0; index < length; ++index) { if (this.dictBone.TryGetValue(((Object)component1.get_bones()[index]).get_name(), out gameObject)) { transformArray[index] = gameObject.get_transform(); } } component1.set_bones(transformArray); component1.set_localBounds(bounds); Cloth component2 = (Cloth)((Component)component1).get_gameObject().GetComponent <Cloth>(); if (Object.op_Implicit((Object)rootBone) && Object.op_Equality((Object)null, (Object)component2)) { component1.set_rootBone(rootBone); } else if (Object.op_Implicit((Object)component1.get_rootBone()) && this.dictBone.TryGetValue(((Object)component1.get_rootBone()).get_name(), out gameObject)) { component1.set_rootBone(gameObject.get_transform()); } } IEnumerator enumerator = ((Component)t).get_gameObject().get_transform().GetEnumerator(); try { while (enumerator.MoveNext()) { this.AssignedWeightsAndSetBoundsLoop((Transform)enumerator.Current, bounds, rootBone); } } finally { if (enumerator is IDisposable disposable) { disposable.Dispose(); } } }
private static int get_rootBone(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); SkinnedMeshRenderer skinnedMeshRenderer = (SkinnedMeshRenderer)obj; Transform rootBone = skinnedMeshRenderer.get_rootBone(); ToLua.Push(L, rootBone); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.get_Message() : "attempt to index rootBone on a nil value"); } return(result); }
public void Process(GameObject obj, float Seed) { List <SkinnedMeshRenderer> list = (List <SkinnedMeshRenderer>)Pool.GetList <SkinnedMeshRenderer>(); obj.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 name1 = ((Object)current.get_sharedMesh()).get_name(); string name2 = ((Object)((Renderer)current).get_sharedMaterial()).get_name(); for (int index = 0; index < this.MeshReplacements.Length; ++index) { if (this.MeshReplacements[index].Test(name1)) { SkinnedMeshRenderer skinnedMeshRenderer = this.MeshReplacements[index].Get(Seed); current.set_sharedMesh(skinnedMeshRenderer.get_sharedMesh()); current.set_rootBone(skinnedMeshRenderer.get_rootBone()); current.set_bones(skinnedMeshRenderer.get_bones()); } } for (int index = 0; index < this.MaterialReplacements.Length; ++index) { if (this.MaterialReplacements[index].Test(name2)) { ((Renderer)current).set_sharedMaterial(this.MaterialReplacements[index].Get(Seed)); } } } } } // ISSUE: cast to a reference type Pool.FreeList <SkinnedMeshRenderer>((List <M0>&) 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); }