public TouchEventManipulator(DeviceSimulator deviceSimulator)
        {
            activators.Add(new ManipulatorActivationFilter()
            {
                button = MouseButton.LeftMouse
            });
            var playerSettings     = PlayerSettings.GetSerializedObject();
            var activeInputHandler = playerSettings.FindProperty("activeInputHandler");

            // 0 -> Input Manager, 1 -> Input System, 2 -> Both
            if (activeInputHandler.intValue == 0 || activeInputHandler.intValue == 2)
            {
                m_InputManagerBackend = new InputManagerBackend();
            }

            m_DeviceSimulator = deviceSimulator;
        }
Exemple #2
0
        public PluginController(SimulatorState serializedState, DeviceSimulator deviceSimulator)
        {
            var nonInitializablePlugins = TypeCache.GetTypesWithAttribute <NotInitializePluginAttribute>();

            foreach (var type in TypeCache.GetTypesDerivedFrom <DeviceSimulatorPlugin>().Where(type => !type.IsAbstract && !nonInitializablePlugins.Contains(type)))
            {
                try
                {
                    var plugin = (DeviceSimulatorPlugin)Activator.CreateInstance(type);
                    plugin.deviceSimulator = deviceSimulator;
                    if (serializedState.plugins.TryGetValue(plugin.pluginId, out var serializedPlugin))
                    {
                        JsonUtility.FromJsonOverwrite(serializedPlugin, plugin);
                    }
                    try
                    {
                        plugin.OnCreate();
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                    }
                    try
                    {
                        plugin.resolvedTitle = plugin.title;
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                    }
                    plugins.Add(plugin);
                }
                catch (MissingMethodException)
                {
                    Debug.LogError($"Failed instantiating Device Simulator plug-in {type.Name}. It does not have a public default constructor.");
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }

            plugins.AddRange(RetrieveLegacyExtensions(serializedState, deviceSimulator));
            plugins.Sort(ComparePluginOrder);
        }
 public PluginController(SimulatorState serializedState, DeviceSimulator deviceSimulator)
 {
     foreach (var type in TypeCache.GetTypesDerivedFrom <DeviceSimulatorPlugin>().Where(type => !type.IsAbstract))
     {
         try
         {
             var plugin = (DeviceSimulatorPlugin)Activator.CreateInstance(type);
             plugin.deviceSimulator = deviceSimulator;
             if (serializedState.plugins.TryGetValue(plugin.GetType().ToString(), out var serializedPlugin))
             {
                 JsonUtility.FromJsonOverwrite(serializedPlugin, plugin);
             }
             try
             {
                 plugin.OnCreate();
             }
             catch (Exception e)
             {
                 Debug.LogException(e);
             }
             try
             {
                 plugin.resolvedTitle = plugin.title;
             }
             catch (Exception e)
             {
                 Debug.LogException(e);
             }
             plugins.Add(plugin);
         }
         catch (MissingMethodException)
         {
             Debug.LogError($"Failed instantiating Device Simulator plug-in {type.Name}. It does not have a public default constructor.");
         }
         catch (Exception e)
         {
             Debug.LogException(e);
         }
     }
     plugins.Sort(ComparePluginOrder);
 }
        public TouchEventManipulator(DeviceSimulator deviceSimulator)
        {
            activators.Add(new ManipulatorActivationFilter()
            {
                button = MouseButton.LeftMouse
            });

            var playerSettings = PlayerSettings.GetSerializedObject();

#if UNITY_2020_2_OR_NEWER
            var activeInputHandler   = playerSettings.FindProperty("activeInputHandler").intValue;
            var builtInSystemEnabled = activeInputHandler == 0 || activeInputHandler == 2;
#else
            var builtInSystemEnabled = !playerSettings.FindProperty("disableOldInputManagerSupport").boolValue;
#endif
            if (builtInSystemEnabled)
            {
                m_InputManagerBackend = new InputManagerBackend();
            }
            m_DeviceSimulator = deviceSimulator;
        }
Exemple #5
0
        private IEnumerable <DeviceSimulatorPlugin> RetrieveLegacyExtensions(SimulatorState serializedState, DeviceSimulator deviceSimulator)
        {
            var extensions       = new SimulatorExtensions().Extensions;
            var extensionPlugins = new List <DeviceSimulatorPlugin>();

            foreach (var extension in extensions)
            {
                var plugin = new DeviceSimulatorExtensionWrapperPlugin(extension);
                plugin.deviceSimulator = deviceSimulator;

                try
                {
                    if (serializedState.plugins.TryGetValue(plugin.pluginId, out var serializedPlugin))
                    {
                        JsonUtility.FromJsonOverwrite(serializedPlugin, extension);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError($"Failed deserializing Device Simulator extension {plugin.pluginId}. {e.GetType()}: {e.Message}");
                    Debug.LogException(e);
                }

                extensionPlugins.Add(plugin);
            }

            return(extensionPlugins);
        }