From f6043c5fff1c064740f9b71cec115f6f8d966681 Mon Sep 17 00:00:00 2001 From: xpeng <1216772231@qq.com> Date: Sat, 4 Mar 2023 01:48:06 +0100 Subject: [PATCH] fix enviroment issue; fix config issue; --- .../Script/Configuration/EnviromentManager.cs | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/Assets/Script/Configuration/EnviromentManager.cs b/Assets/Script/Configuration/EnviromentManager.cs index 14b7319..c34e20c 100644 --- a/Assets/Script/Configuration/EnviromentManager.cs +++ b/Assets/Script/Configuration/EnviromentManager.cs @@ -8,40 +8,37 @@ using System.IO; public class EnviromentManager : MonoBehaviour { private TMP_Dropdown Dropdown; - public bool useEnvironment = true; + private bool useEnvironment = true; public Transform EnvironmentParent; public GameObject CurrentEnvironment; + public GameObject Cabinet; - private string currentEnvironmentName; private List enviromentFiles = new List(); void Start() { Dropdown = GetComponent(); AddEnviorments(); Dropdown.onValueChanged.AddListener((int value) => { - currentEnvironmentName = Dropdown.options[value].text; if (value == 0) useEnvironment = false; else { useEnvironment = true; - SetEnvironment(); + SetEnvironment(Dropdown.options[value].text); } Debug.Log("Value: " + value); }); Dropdown.onValueChanged?.Invoke(Dropdown.value); } - - void Update() + [ContextMenu("InvokeDropdown")] + void invokeDropdown() { - if (useEnvironment) - { - CurrentEnvironment.SetActive(true); - } - else - { - CurrentEnvironment.SetActive(false); - } + Dropdown.onValueChanged?.Invoke(Dropdown.value); + } + void Update() + { + if (!useEnvironment) + Destroy(CurrentEnvironment); } void AddEnviorments() @@ -55,13 +52,14 @@ public class EnviromentManager : MonoBehaviour Dropdown.options.Add(new TMP_Dropdown.OptionData(file.Name)); } } - void SetEnvironment() + void SetEnvironment(string enviromentName) { if (CurrentEnvironment != null) { Destroy(CurrentEnvironment); } - GameObject env = AssetBundleManager.Instance.LoadAsset("Enviroments", currentEnvironmentName); + GameObject env = AssetBundleManager.Instance.LoadAsset("Enviroments", enviromentName); CurrentEnvironment = Instantiate(env, EnvironmentParent); + } }