Search code examples
unity-game-enginetextures

How to set maps (apart from albedo, normal and metallic) at runtime in Unity?


I'm trying to dynamically set textures for my game object. It works like this:

        var skin = _skinTable[index] as Hashtable;
        var renderer = CurrentShip.GetComponentInChildren<Renderer>();

        renderer.material.SetTexture("_MainTex", skin["albedo"] as Texture);
        renderer.material.SetTexture("_BumpMap", skin["normal"] as Texture);
        renderer.material.SetTexture("_MetallicGlossMap", skin["metallic"] as Texture);

Where can I find names (first argument of SetTexture) for other maps, like Height, Occlusion etc? (I'm talking about Standard Shader)


Solution

  • You can get the available map channels if you select your shader in the inspector

    enter image description here

    For a full standard shader you can check the source https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/DefaultResourcesExtra/Standard.shader