Add Custom Enviroment Option (Need to fix Lighting issue))

This commit is contained in:
xpeng
2022-12-05 23:15:03 +01:00
parent 6992599d72
commit d8e8fa4ddb
39 changed files with 1895 additions and 175 deletions
@@ -23,27 +23,29 @@ public class SkyboxSwitcher : MonoBehaviour
private TMP_Dropdown Dropdown;
void Start()
{
{
Dropdown = GetComponent<TMP_Dropdown>(); // get the dropdown component
skyboxes.Insert(0, RenderSettings.skybox); // add ubiquitous default skybox (should be current)
// check StreamingAssets folder for additional skybox textures
skyboxPath = Path.Combine(Application.streamingAssetsPath, "SkyboxTextures");
StartCoroutine(AddSkyboxes());
Dropdown = GetComponent<TMP_Dropdown>();
Dropdown.onValueChanged.AddListener((int value) => {
if (value == 0)
Dropdown.value = ConfigManager.config.Skybox; // set the dropdown to the current skybox index
Dropdown.onValueChanged.AddListener((int value) => { // add listener to dropdown
if (value == 0) // if the first option is selected, disable the room
{
Room.SetActive(true);
}
else
else // otherwise, enable the room and set the skybox
{
Room.SetActive(false);
currentSkyboxIndex = Dropdown.value;
SetSkybox();
}
});
Dropdown.onValueChanged?.Invoke(Dropdown.value);
Dropdown.onValueChanged?.Invoke(Dropdown.value); // invoke the listener to set the skybox on startup
}
IEnumerator AddSkyboxes()
@@ -76,7 +78,7 @@ public class SkyboxSwitcher : MonoBehaviour
skyboxMat.SetTexture("_MainTex", texture);
skyboxes.Add(skyboxMat);
Dropdown.options.Add(new TMP_Dropdown.OptionData(file.Name));
Dropdown.options.Add(new TMP_Dropdown.OptionData(file.Name)); // add the skybox option to the dropdown
}
}
}