Ejemplo n.º 1
0
            public SaberColourizer(Saber saber)
            {
                warm = saber.saberType == Saber.SaberType.SaberA;

                glowColors    = saber.GetComponentsInChildren <SetSaberGlowColor>();
                meshRenderers = new MeshRenderer[glowColors.Length];
                blocks        = new MaterialPropertyBlock[glowColors.Length];
                tintPairs     = new SetSaberGlowColor.PropertyTintColorPair[glowColors.Length][];
                for (int i = 0; i < glowColors.Length; i++)
                {
                    meshRenderers[i] = glowColors[i].GetField <MeshRenderer>("_meshRenderer");

                    blocks[i] = glowColors[i].GetField <MaterialPropertyBlock>("_materialPropertyBlock");
                    if (blocks[i] == null)
                    {
                        blocks[i] = new MaterialPropertyBlock();
                        glowColors[i].SetField("_materialPropertyBlock", blocks[i]);
                    }
                    tintPairs[i] = glowColors[i].GetField <SetSaberGlowColor.PropertyTintColorPair[]>("_propertyTintColorPairs");
                    meshRenderers[i].SetPropertyBlock(blocks[i], 0);
                }

                //Custom sabers??
                Renderer[] renderers = saber.GetComponentsInChildren <Renderer>();
                for (int i = 0; i < renderers.Length; i++)
                {
                    foreach (Material material in renderers[i].materials)
                    {
                        if ((material.HasProperty("_Glow") && material.GetFloat("_Glow") > 0f) || (material.HasProperty("_Bloom") && material.GetFloat("_Bloom") > 0f))
                        {
                            customMats.Add(material);
                        }
                    }
                }
            }