예제 #1
0
        public static void Initialize()
        {
            if (Active || isApplicationQuitting)
            {
                return;
            }

            var instances = FindObjectsOfType <TXRInputModule>();

            if (instances.Length > 0)
            {
                m_Instance = instances[0];
                if (instances.Length > 1)
                {
                    Debug.LogWarning("Multiple TXRInputModule not supported!");
                }
            }

            if (!Active)
            {
                EventSystem eventSystem = EventSystem.current;
                if (eventSystem == null)
                {
                    eventSystem = FindObjectOfType <EventSystem>();
                }
                if (eventSystem == null)
                {
                    eventSystem = new GameObject("[EventSystem]").AddComponent <EventSystem>();
                }
                if (eventSystem == null)
                {
                    Debug.LogWarning("EventSystem not found or create fail!");
                    return;
                }

                m_Instance = eventSystem.gameObject.AddComponent <TXRInputModule>();
                DontDestroyOnLoad(eventSystem.gameObject);
            }
        }
 protected override void OnDisable()
 {
     //base.OnDisable();
     TXRInputModule.RemoveRaycaster(this);
 }
 // override OnEnable & OnDisable on purpose so that this BaseRaycaster won't be registered into RaycasterManager
 protected override void OnEnable()
 {
     //base.OnEnable();
     TXRInputModule.AddRaycaster(this);
 }