Files
2026-02-21 16:45:37 +08:00

40 lines
813 B
C#

using UnityEngine;
using UnityEngine.EventSystems;
namespace UnityStandardAssets.CrossPlatformInput
{
[ExecuteInEditMode]
public class MobileControlRig : MonoBehaviour
{
private void OnEnable()
{
CheckEnableControlRig();
}
private void Start()
{
EventSystem eventSystem = Object.FindObjectOfType<EventSystem>();
if (eventSystem == null)
{
GameObject gameObject = new GameObject("EventSystem");
gameObject.AddComponent<EventSystem>();
gameObject.AddComponent<StandaloneInputModule>();
gameObject.AddComponent<TouchInputModule>();
}
}
private void CheckEnableControlRig()
{
EnableControlRig(false);
}
private void EnableControlRig(bool enabled)
{
foreach (Transform item in base.transform)
{
item.gameObject.SetActive(enabled);
}
}
}
}