Пример #1
0
        public void Uninitialize()
        {
            if (!m_IsInitialized)
            {
                return;
            }

            m_DeviceManager  = null;
            m_ProfileManager = null;

            NativeInputSystem.onDeviceDiscovered -= CreateNativeInputDevice;

            m_IsInitialized = false;
        }
Пример #2
0
        internal static void Reset()
        {
            // Grab the manager for native devices as we want those to survive the reset.
            NativeInputDeviceManager oldNativeDeviceManager = null;

            if (s_Input != null)
            {
                oldNativeDeviceManager = s_Input.nativeDeviceManager;
            }

            // Also, we want all profiles to survive the reset.
            InputDeviceProfileManager oldProfileManager = null;

            if (s_Input != null)
            {
                oldProfileManager = s_Input.profileManager;
            }

            // And we want no native events still going to the old native event manager.
            if (s_Input != null)
            {
                s_Input.nativeEventManager.Uninitialize();
            }

            // Create blank input system state.
            s_Input           = ScriptableObject.CreateInstance <InputSystemManager>();
            s_Input.hideFlags = HideFlags.HideAndDontSave;

            // Hand existing profiles over to the new profile manager. We can't simply replace
            // the profile manager with the old one because InputSystemManager has already wired
            // up state using the new profile manager.
            if (oldProfileManager != null)
            {
                s_Input.profileManager.StealProfilesFrom(oldProfileManager);
            }

            // Recreate native devices, if we had them before.
            if (oldNativeDeviceManager != null)
            {
                s_Input.nativeDeviceManager.RecreateNativeDevicesFrom(oldNativeDeviceManager);
                oldNativeDeviceManager.Uninitialize();
            }
        }
Пример #3
0
        public void Initialize(InputDeviceManager deviceManager, InputDeviceProfileManager profileManager)
        {
            if (m_IsInitialized)
            {
                return;
            }

            m_DeviceManager  = deviceManager;
            m_ProfileManager = profileManager;

            // Rebuild any devices that still retain device records through serialization, even though we lost the device reference
            List <NativeDeviceRecord> nativeDeviceRecords = new List <NativeDeviceRecord>(m_NativeDevices);

            m_NativeDevices.Clear();
            for (var i = 0; i < nativeDeviceRecords.Count; i++)
            {
                CreateNativeInputDevice(nativeDeviceRecords[i].deviceInfo);
            }

            // Hook into notifications for when the native runtime discovers new devices.
            NativeInputSystem.onDeviceDiscovered += CreateNativeInputDevice;

            m_IsInitialized = true;
        }
Пример #4
0
 // When resetting the input system, we pass on profiles from the old profile manager
 // to the new one.
 internal void StealProfilesFrom(InputDeviceProfileManager manager)
 {
     m_Profiles         = manager.m_Profiles;
     manager.m_Profiles = null;
 }