Exemple #1
0
        static VRModule()
        {
            SetDefaultInitGameObjectGetter(GetDefaultInitGameObject);

            s_defaultState = new DeviceState(INVALID_DEVICE_INDEX);
            s_simulator    = new SimulatorVRModule();
        }
Exemple #2
0
        static VRModule()
        {
            SetDefaultInitGameObjectGetter(GetDefaultInitGameObject);

            s_defaultState            = new DeviceState(INVALID_DEVICE_INDEX);
            s_simulator               = new SimulatorVRModule();
            s_deviceSerialNumberTable = new Dictionary <string, uint>(16);
        }
        protected override void OnSingletonBehaviourInitialized()
        {
            if (m_dontDestroyOnLoad && transform.parent == null && Application.isPlaying)
            {
                DontDestroyOnLoad(gameObject);
            }

            SetDefaultInitGameObjectGetter(GetDefaultInitGameObject);

            s_defaultState            = new DeviceState(INVALID_DEVICE_INDEX);
            s_simulator               = new SimulatorVRModule();
            s_deviceSerialNumberTable = new Dictionary <string, uint>(16);

            m_activatedModule     = VRModuleActiveEnum.Uninitialized;
            m_activatedModuleBase = null;

            try
            {
                var modules        = new List <ModuleBase>();
                var modulesOrdered = new List <ModuleBase>();
                foreach (var type in Assembly.GetAssembly(typeof(ModuleBase)).GetTypes().Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(ModuleBase))))
                {
                    var inst  = type == typeof(SimulatorVRModule) ? s_simulator : (ModuleBase)Activator.CreateInstance(type);
                    var index = inst.moduleIndex;

                    if (index < 0)
                    {
                        Debug.LogWarning("Invalid module index, module will not be activated! module name=" + type.Name + " index=" + index);
                    }
                    else if (index < modules.Count && modules[index] != null)
                    {
                        Debug.LogWarning("Duplicated module index, module will not be activated! module name=" + type.Name + " index=" + index);
                    }
                    else
                    {
                        while (index >= modules.Count)
                        {
                            modules.Add(null);
                        }
                        modules[index] = inst;
                    }

                    var order = inst.moduleOrder;

                    if (order < 0)
                    {
                        Debug.LogWarning("Invalid module order, module will not be activated! module name=" + type.Name + " order=" + order);
                    }
                    else if (order < modulesOrdered.Count && modulesOrdered[order] != null)
                    {
                        Debug.LogWarning("Duplicated module order, module will not be activated! module name=" + type.Name + " order=" + order);
                    }
                    else
                    {
                        while (order >= modulesOrdered.Count)
                        {
                            modulesOrdered.Add(null);
                        }
                        modulesOrdered[order] = inst;
                    }
                }
                m_modules        = modules.ToArray();
                m_modulesOrdered = modulesOrdered.ToArray();
            }
            catch (Exception e)
            {
                m_modules        = new ModuleBase[] { new DefaultModule() };
                m_modulesOrdered = new ModuleBase[] { new DefaultModule() };
                Debug.LogError(e);
            }
        }