/// <summary> /// Initialize the default values. /// </summary> private void Awake() { m_ControlUI.SetActive(m_Active); var demoManager = GetComponent <DemoManager>(); m_Character = demoManager.Character; m_UnityInput = m_Character.GetComponent <UnityInput>(); m_ResumeButton.onClick.AddListener(Resume); #if UNITY_STANDALONE || UNITY_EDITOR m_QuitButton.onClick.AddListener(Quit); #else // The application can't quit on the target platform. m_QuitButton.gameObject.SetActive(false); // Center the Resume button. var rectTransform = m_ResumeButton.GetComponent <RectTransform>(); var position = rectTransform.localPosition; position.x = rectTransform.rect.width / 2; rectTransform.localPosition = position; #endif OnControllerConnected(m_UnityInput.ControllerConnected); EventHandler.RegisterEvent <bool>(m_Character, "OnInputControllerConnected", OnControllerConnected); EventHandler.RegisterEvent <bool>(m_Character, "OnCharacterEnterUIZone", OnEnterUIZone); }
/// <summary> /// Sends the academy parameters through the Communicator. /// Is used by the academy to send the AcademyParameters to the communicator. /// </summary> /// <returns>The External Initialization Parameters received.</returns> /// <param name="academyParameters">The Unity Initialization Paramters to be sent.</param> public UnityRLInitializationInput SendAcademyParameters( UnityRLInitializationOutput academyParameters) { UnityInput input; var initializationInput = new UnityInput(); try { initializationInput = m_communicator.Initialize( new UnityOutput { RlInitializationOutput = academyParameters }, out input); } catch { throw new UnityAgentsException( "The Communicator was unable to connect. Please make sure the External " + "process is ready to accept communication with Unity."); } var firstRlInput = input.RlInput; m_command = firstRlInput.Command; m_environmentParameters = firstRlInput.EnvironmentParameters; m_isTraining = firstRlInput.IsTraining; return(initializationInput.RlInitializationInput); }
void OnEnable() { if (isLoaded == true) { return; } rawController = ScriptableObject.CreateInstance <UnityInput>(); data = ScriptableObject.CreateInstance <KeyData>(); string playerConfig = JsonHelper.LoadSaveData("player.cfg"); if (playerConfig != "none") { data.LoadConfig(playerConfig); isLoaded = true; } else { data = Resources.Load <KeyData>("Devices/keyboard"); isLoaded = true; } }
public Scene(SceneManager manager, SpriteRenderer spriteRenderer) { sceneManager = manager; this.spriteRenderer = spriteRenderer; completed = false; permitUnloadResources = true; camera = Camera.main; input = new UnityInput(); }
public static void Init(UnityInput input) { events = new Dictionary <GameEventType, System.Action <Transform> >((int)GameEventType.Count); if (platformInput == null) { platformInput = input; } else { Debug.LogError("Platform input is already initialized!"); } }
public void PostConstruct(params object[] args) { _input = new UnityInput(); GameInput = new GameInputAdapter(_input.Game); UiInput = new UiInputAdapter(_input.UI); UiInput.SetEnabled(false); GameInput.SetEnabled(false); _gameEventManager.Subscribe(GameEvents.StateMachineEvents.Start, OnGameStateStart); _gameEventManager.Subscribe(GameEvents.StateMachineEvents.End, OnGameStateEnd); }
public void SetUp() { inputMock = Substitute.For <UnityInput>(); PreInstall(); Container.Bind <UnityInput>().FromInstance(inputMock); Container.Bind <PlayerInput>().FromNewComponentOnNewGameObject().AsSingle(); PostInstall(); playerInput = Container.Resolve <PlayerInput>(); }
// Use this for initialization void Start() { unityInput = GetComponent <UnityInput>(); locomotionHandler = GetComponent <UltimateCharacterLocomotionHandler>(); locomotion = GetComponent <UltimateCharacterLocomotion>(); characterIk = GetComponent <CharacterIK>(); animator = GetComponent <Animator>(); runtimeAnimationController = animator.runtimeAnimatorController; UpdateAvatar(); SetUmaReady(false); }
public void SetUp() { inputMock = Substitute.For <UnityInput>(); PreInstall(); Container.Bind <UnityInput>().FromInstance(inputMock); Container.Bind <InputRecognizer>().AsSingle(); Container.Bind <PlayerSpawner>().FromNewComponentOnNewGameObject().AsSingle(); PostInstall(); playerSpawner = Container.Resolve <PlayerSpawner>(); var playerPrefab = new GameObject("Prefab", typeof(PlayerInput)); playerSpawner.SetPlayerPrefab(playerPrefab); }
/// <summary> /// Initialize the communicator by sending the first UnityOutput and receiving the /// first UnityInput. The second UnityInput is stored in the unityInput argument. /// </summary> /// <returns>The first Unity Input.</returns> /// <param name="unityOutput">The first Unity Output.</param> /// <param name="unityInput">The second Unity input.</param> public UnityInput Initialize(UnityOutput unityOutput, out UnityInput unityInput) { m_isOpen = true; var channel = new Channel( "localhost:" + m_communicatorParameters.port, ChannelCredentials.Insecure); m_client = new UnityToExternal.UnityToExternalClient(channel); var result = m_client.Exchange(WrapMessage(unityOutput, 200)); unityInput = m_client.Exchange(WrapMessage(null, 200)).UnityInput; #if UNITY_EDITOR EditorApplication.playModeStateChanged += HandleOnPlayModeChanged; #endif return(result.UnityInput); }
/// <summary> /// Initialize the communicator by sending the first UnityOutput and receiving the /// first UnityInput. The second UnityInput is stored in the unityInput argument. /// </summary> /// <returns>The first Unity Input.</returns> /// <param name="unityOutput">The first Unity Output.</param> /// <param name="unityInput">The second Unity input.</param> public UnityInput Initialize(UnityOutput unityOutput, out UnityInput unityInput) { m_sender = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); m_sender.Connect("localhost", communicatorParameters.port); UnityMessage initializationInput = UnityMessage.Parser.ParseFrom(Receive()); Send(WrapMessage(unityOutput, 200).ToByteArray()); unityInput = UnityMessage.Parser.ParseFrom(Receive()).UnityInput; #if UNITY_EDITOR EditorApplication.playModeStateChanged += HandleOnPlayModeChanged; #endif return(initializationInput.UnityInput); }
public void Construct(UnityInput input) { this.input = input; }
public TouchSensor(UnityInput input) { this.input = input; }
public InputRecognizer(UnityInput unityInput) { this.unityInput = unityInput; }