56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.Tracing;
|
|
using UnityEngine;
|
|
|
|
public class TestSceneManager : MonoBehaviour
|
|
{
|
|
public GameObject testObj;
|
|
void Start()
|
|
{
|
|
Bootstrap.Instance.eventCenter.AddEventListener(Enum_EventType.TestEvent1, TestFunc1);
|
|
Bootstrap.Instance.eventCenter.AddEventListener<int>(Enum_EventType.TestEvent2, TestFunc2);
|
|
Bootstrap.Instance.eventCenter.AddEventListener<string>(Enum_EventType.TestEvent3, TestFunc3);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (Input.GetKeyDown("v"))
|
|
{
|
|
Bootstrap.Instance.uiManager.ShowPanel<UI_LoadingPanel>(E_UI_Layer.System, (panel) =>
|
|
{
|
|
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.UpdateProgress, 1f);
|
|
Bootstrap.Instance.scenesManager.LoadSceneAsyn("TestScene1", () =>
|
|
{
|
|
Debug.Log("加载TestScene1 场景成功");
|
|
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.UpdateProgress, 5f);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
public void TestFunc1()
|
|
{
|
|
testObj.GetComponent<MeshRenderer>().material.color = new Color(Random.Range(1, 255f) / 255f, Random.Range(1, 255f) / 255f, Random.Range(1, 255f) / 255f, 1f);
|
|
}
|
|
public void TestFunc2(int idnex)
|
|
{
|
|
Debug.Log($"TestFunc2++{idnex}");
|
|
}
|
|
public void TestFunc3(string info)
|
|
{
|
|
Debug.Log($"TestFunc3++{info}");
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
Debug.Log("跳转场景或者关闭脚本要移除监听");
|
|
if (Bootstrap.Instance != null)
|
|
{
|
|
Bootstrap.Instance.eventCenter.RemoveEventListener(Enum_EventType.TestEvent1, TestFunc1);
|
|
Bootstrap.Instance.eventCenter.RemoveEventListener<int>(Enum_EventType.TestEvent2, TestFunc2);
|
|
Bootstrap.Instance.eventCenter.RemoveEventListener<string>(Enum_EventType.TestEvent3, TestFunc3);
|
|
}
|
|
}
|
|
|
|
}
|