Esempio n. 1
0
        public static void Initialize()
        {
            if (Active || isApplicationQuitting)
            {
                return;
            }

            var instances = FindObjectsOfType <NRInputModule>();

            if (instances.Length > 0)
            {
                m_Instance = instances[0];
                if (instances.Length > 1)
                {
                    NRDebugger.LogWarning("Multiple NRInputModule 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)
                {
                    NRDebugger.LogWarning("EventSystem not found or create fail!");
                    return;
                }

                m_Instance = eventSystem.gameObject.AddComponent <NRInputModule>();
                DontDestroyOnLoad(eventSystem.gameObject);
            }
        }