コード例 #1
0
        public static void ApplyPrecursorShader(string materialName, string normalMap, string metalicmap, GameObject gameObject, AssetBundle assetBundle, float glossiness)
        {
            var shader = Shader.Find("UWE/Marmoset/IonCrystal");

            Renderer[] renderers = gameObject.GetComponentsInChildren <Renderer>(true);

            foreach (Renderer renderer in renderers)
            {
                foreach (Material material in renderer.materials)
                {
                    if (material.name.StartsWith(materialName))
                    {
                        material.shader = shader;
                        material.EnableKeyword("_NORMALMAP");

                        material.EnableKeyword("_METALLICGLOSSMAP");

                        material.SetTexture("_BumpMap", FindTexture2D(normalMap, assetBundle));

                        material.SetColor("_BorderColor", new Color(0.14f, 0.55f, 0.43f));

                        material.SetColor("_Color", new Color(0.33f, 0.83f, 0.17f));

                        material.SetColor("_DetailsColor", new Color(0.42f, 0.85f, 0.26f));

                        material.SetTexture("_MarmoSpecEnum", MaterialHelpers.FindTexture2D(metalicmap, assetBundle));

                        material.SetFloat("_Glossiness", glossiness);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Applies the properties for the MarmosetUBER shader that has a metallic texture.
        /// </summary>
        /// <param name="materialName">The name of the material to look for on the object.</param>
        /// <param name="textureName">The name of the texture to look for in the assetBundle.</param>
        /// <param name="gameObject">The game object to process.</param>
        /// <param name="assetBundle">The assetBundle to search in.</param>
        /// <param name="glossiness">The amount of gloss to apply to the metallic material.</param>
        public static void ApplyMetallicShader(string materialName, string textureName, GameObject gameObject, AssetBundle assetBundle, float glossiness)
        {
            var shader = Shader.Find("MarmosetUBER");

            Renderer[] renderers = gameObject.GetComponentsInChildren <Renderer>();
            foreach (Renderer renderer in renderers)
            {
                foreach (Material material in renderer.materials)
                {
                    if (material.name.StartsWith(materialName))
                    {
                        material.shader = shader;

                        material.EnableKeyword("_METALLICGLOSSMAP");
                        material.SetColor("_Color", Color.white);
                        material.SetTexture("_Metallic", MaterialHelpers.FindTexture2D(textureName, assetBundle));
                        material.SetFloat("_Glossiness", glossiness);
                    }
                }
            }
        }