Files

41 lines
1.3 KiB
C#

using UnityEngine;
using UnityEngine.EventSystems;
namespace RedHotRoast
{
public class EngineEventSystem : MonoBehaviour
{
public static EngineEventSystem Instance { get; private set; }
[HideInInspector] public GameObject eventObj;
[HideInInspector] public EventSystem eventSystem;
[HideInInspector] public StandaloneInputModule inputModule;
private void Awake()
{
Instance = this;
DontDestroyOnLoad(gameObject);
Init();
}
private void OnDestroy()
{
Instance = null;
}
private void Init()
{
LoadKit.Instance.LoadGameObjectAndClone("Prefab", "EngineEventSystem", eventObj1 =>
{
eventObj = eventObj1;
eventObj.transform.SetParent(transform, false);
eventSystem = eventObj.GetComponent<EventSystem>();
inputModule = eventObj.GetComponent<StandaloneInputModule>();
AppObjConst.EngineEventSystemGo = Instance.eventObj.transform.parent.gameObject;
AppObjConst.EngineEventSystemGo.name = AppObjConst.EngineEventSystemGoName;
UIManager.Instance.SetEventSystemGo(eventObj);
});
}
}
}