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