fix enviroment issue; fix config issue;
This commit is contained in:
parent
778785a337
commit
f6043c5fff
@ -8,40 +8,37 @@ using System.IO;
|
|||||||
public class EnviromentManager : MonoBehaviour
|
public class EnviromentManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
private TMP_Dropdown Dropdown;
|
private TMP_Dropdown Dropdown;
|
||||||
public bool useEnvironment = true;
|
private bool useEnvironment = true;
|
||||||
public Transform EnvironmentParent;
|
public Transform EnvironmentParent;
|
||||||
public GameObject CurrentEnvironment;
|
public GameObject CurrentEnvironment;
|
||||||
|
public GameObject Cabinet;
|
||||||
|
|
||||||
private string currentEnvironmentName;
|
|
||||||
private List<FileInfo> enviromentFiles = new List<FileInfo>();
|
private List<FileInfo> enviromentFiles = new List<FileInfo>();
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
Dropdown = GetComponent<TMP_Dropdown>();
|
Dropdown = GetComponent<TMP_Dropdown>();
|
||||||
AddEnviorments();
|
AddEnviorments();
|
||||||
Dropdown.onValueChanged.AddListener((int value) => {
|
Dropdown.onValueChanged.AddListener((int value) => {
|
||||||
currentEnvironmentName = Dropdown.options[value].text;
|
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
useEnvironment = false;
|
useEnvironment = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
useEnvironment = true;
|
useEnvironment = true;
|
||||||
SetEnvironment();
|
SetEnvironment(Dropdown.options[value].text);
|
||||||
}
|
}
|
||||||
Debug.Log("Value: " + value);
|
Debug.Log("Value: " + value);
|
||||||
});
|
});
|
||||||
Dropdown.onValueChanged?.Invoke(Dropdown.value);
|
Dropdown.onValueChanged?.Invoke(Dropdown.value);
|
||||||
}
|
}
|
||||||
|
[ContextMenu("InvokeDropdown")]
|
||||||
void Update()
|
void invokeDropdown()
|
||||||
{
|
{
|
||||||
if (useEnvironment)
|
Dropdown.onValueChanged?.Invoke(Dropdown.value);
|
||||||
{
|
}
|
||||||
CurrentEnvironment.SetActive(true);
|
void Update()
|
||||||
}
|
{
|
||||||
else
|
if (!useEnvironment)
|
||||||
{
|
Destroy(CurrentEnvironment);
|
||||||
CurrentEnvironment.SetActive(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddEnviorments()
|
void AddEnviorments()
|
||||||
@ -55,13 +52,14 @@ public class EnviromentManager : MonoBehaviour
|
|||||||
Dropdown.options.Add(new TMP_Dropdown.OptionData(file.Name));
|
Dropdown.options.Add(new TMP_Dropdown.OptionData(file.Name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SetEnvironment()
|
void SetEnvironment(string enviromentName)
|
||||||
{
|
{
|
||||||
if (CurrentEnvironment != null)
|
if (CurrentEnvironment != null)
|
||||||
{
|
{
|
||||||
Destroy(CurrentEnvironment);
|
Destroy(CurrentEnvironment);
|
||||||
}
|
}
|
||||||
GameObject env = AssetBundleManager.Instance.LoadAsset<GameObject>("Enviroments", currentEnvironmentName);
|
GameObject env = AssetBundleManager.Instance.LoadAsset<GameObject>("Enviroments", enviromentName);
|
||||||
CurrentEnvironment = Instantiate(env, EnvironmentParent);
|
CurrentEnvironment = Instantiate(env, EnvironmentParent);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user