/// <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> internal static void ApplyMetallicShader(string materialName, string textureName, GameObject gameObject, AssetBundle assetBundle, float glossiness) { var shader = Shader.Find("MarmosetUBER"); Renderer[] renderers = gameObject.GetComponentsInChildren <Renderer>(true); foreach (Renderer renderer in renderers) { foreach (Material material in renderer.materials) { if (material.name.StartsWith(materialName, StringComparison.OrdinalIgnoreCase)) { material.shader = shader; material.EnableKeyword("_METALLICGLOSSMAP"); material.SetColor("_Color", Color.white); material.SetTexture("_Metallic", MaterialHelpers.FindTexture2D(textureName, assetBundle)); material.SetFloat("_Glossiness", glossiness); } } } }
/// <summary> /// Change the color of the body of the gameobject /// </summary> /// <param name="matNameColor">The material to change</param> /// <param name="color">The color to change to</param> /// <param name="gameObject">The game object to apply the change too.</param> internal static void ChangeBodyColor(string matNameColor, Color color, GameObject gameObject) { MaterialHelpers.ChangeMaterialColor(matNameColor, gameObject, color); }