Changing GraphicsTier rendering settings via script (not at runtime)?

Hi,

I use different Graphics when doing a lightmap bake. Is there a way I can change the GraphicsTier settings (e.g. render mode from forward to deferred for tier3) via an editor script (not at runtime)? I’ve looked at: Unity - Scripting API: GraphicsTier but it doesn’t say anything about changing the individual tier variables. Right now I am changing the settings manually, but I do lightmap bakes many times during the day, so I was hoping to automate it.

Thanks!

EDIT Ah, so I found Unity - Scripting API: TierSettings. Now to find an example using it via script.

If what you want to do isn’t possible in a script you could just setup and save various different ‘ProjectSettings\GraphicSettings.asset’ files and then write a small editor script to copy over the one you wanted before the light baking starts.

e.g. Copy ‘ProjectSettings\GraphicSettings_HardShadows.asset’ ‘ProjectSettings\GraphicSettings.asset’

Hi, sorry I missed your reply. That would have been a good back up idea!

I ended up finding out how to do it via script. Here is a template example script in case anyone is looking for something similar in the future:

using UnityEditor;
using UnityEditor.Rendering;
using UnityEngine;
using UnityEngine.Rendering;

namespace Example.Scripts.Editor
{
    public class SetLightmapBakingSettings : MonoBehaviour
    {
        [MenuItem("Window/Set Lightmap Baking Settings (For Tier 3)")]
        static void SetLightmapBakingGraphicsAndQualitySettings()
        {
            var tier3Settings = EditorGraphicsSettings.GetTierSettings(BuildTargetGroup.Android, GraphicsTier.Tier3);
            tier3Settings.renderingPath = RenderingPath.DeferredShading;
            EditorGraphicsSettings.SetTierSettings(BuildTargetGroup.Android, GraphicsTier.Tier3, tier3Settings);

            Debug.Log("Set Quality/Graphics settings for lightmap baking.");
        }

        [MenuItem("Window/Set Runtime Game Settings (For Tier 3)")]
        static void SetRuntimeGameGraphicsAndQualitySettings()
        {
            var tier3Settings = EditorGraphicsSettings.GetTierSettings(BuildTargetGroup.Android, GraphicsTier.Tier3);
            tier3Settings.renderingPath = RenderingPath.Forward;
            EditorGraphicsSettings.SetTierSettings(BuildTargetGroup.Android, GraphicsTier.Tier3, tier3Settings);

            Debug.Log("Set Quality/Graphics settings for game runtime.");
        }
    }
}
2 Likes