Example #1
0
    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 set_rootBone(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            SkinnedMeshRenderer skinnedMeshRenderer = (SkinnedMeshRenderer)obj;
            Transform           rootBone            = (Transform)ToLua.CheckUnityObject(L, 2, typeof(Transform));
            skinnedMeshRenderer.set_rootBone(rootBone);
            result = 0;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.get_Message() : "attempt to index rootBone on a nil value");
        }
        return(result);
    }
Example #3
0
    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);
    }
Example #4
0
    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);
    }