예제 #1
0
        public virtual async UniTask InitializeServiceAsync()
        {
            foreach (var binding in Configuration.Bindings)
            {
                var sampler = new InputSampler(Configuration, binding, null);
                samplersMap[binding.Name] = sampler;
            }

            gameObject = Engine.CreateObject(nameof(InputManager));

            if (Configuration.SpawnEventSystem)
            {
                if (ObjectUtils.IsValid(Configuration.CustomEventSystem))
                {
                    Engine.Instantiate(Configuration.CustomEventSystem).transform.SetParent(gameObject.transform, false);
                }
                else
                {
                    gameObject.AddComponent <EventSystem>();
                }
            }

            if (Configuration.SpawnInputModule)
            {
                if (ObjectUtils.IsValid(Configuration.CustomInputModule))
                {
                    Engine.Instantiate(Configuration.CustomInputModule).transform.SetParent(gameObject.transform, false);
                }
                else
                {
                    #if ENABLE_INPUT_SYSTEM && INPUT_SYSTEM_AVAILABLE
                    var inputModule = gameObject.AddComponent <UnityEngine.InputSystem.UI.InputSystemUIInputModule>();
                    #else
                    var inputModule = gameObject.AddComponent <StandaloneInputModule>();
                    #endif
                    await AsyncUtils.WaitEndOfFrame;
                    inputModule.enabled = false; // Otherwise it stops processing UI events when using new input system.
                    inputModule.enabled = true;
                }
            }

            SampleInputAsync(sampleCTS.Token).Forget();
        }
예제 #2
0
        public Task InitializeServiceAsync()
        {
            foreach (var binding in config.Bindings)
            {
                var sampler = new InputSampler(binding, null, config.TouchContinueCooldown);
                samplersMap[binding.Name] = sampler;
            }

            gameObject = Engine.CreateObject("InputManager");

            if (config.SpawnEventSystem)
            {
                if (ObjectUtils.IsValid(config.CustomEventSystem))
                {
                    Engine.Instantiate(config.CustomEventSystem).transform.SetParent(gameObject.transform, false);
                }
                else
                {
                    gameObject.AddComponent <EventSystem>();
                }
            }


            if (config.SpawnInputModule)
            {
                if (ObjectUtils.IsValid(config.CustomInputModule))
                {
                    Engine.Instantiate(config.CustomInputModule).transform.SetParent(gameObject.transform, false);
                }
                else
                {
                    gameObject.AddComponent <StandaloneInputModule>();
                }
            }

            engineBehaviour.OnBehaviourUpdate += SampleInput;

            return(Task.CompletedTask);
        }
예제 #3
0
 public CameraLookController(CameraManager cameraManager, InputSampler xSampler, InputSampler ySampler)
 {
     this.cameraManager = cameraManager;
     this.xSampler      = xSampler;
     this.ySampler      = ySampler;
 }