I’m trying to change the environment lighting source in game from a hdri to a color.
I figured this was the “ambientMode” but i have no idea how i change it.
Ideally i want a dropdown menu on a gameobject to drive the dropdown menu in the lighting panel.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using UnityEngine;
using System.Collections;
public class TestScript : MonoBehaviour {
public enum EnvLightSource { Skybox, Trilight, Flat, Custom }
public EnvLightSource lSource;
public string test;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
test = lSource.ToString();
/// RenderSettings.ambientMode = ??? what here
}
}
hi;
i think u need this code :
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox;
also u can change it from Windoes > Lightning
Figured it out myself, probably not the most beautiful solution:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using UnityEngine;
using System.Collections;
public class ExampleScript : MonoBehaviour {
public enum EnvLightSource { Skybox, Trilight, Flat }
public EnvLightSource lSource;
void Update () {
if (lSource == EnvLightSource.Skybox)
{
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox;
}else if (lSource == EnvLightSource.Flat)
{
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Flat;
}else if (lSource == EnvLightSource.Trilight)
{
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Trilight;
}
}
}