private void Start() { try { trainee = RuntimeConfigurator.Configuration.Trainee.GameObject.transform; canvas = GetComponentInChildren <Canvas>(); canvas.worldCamera = Camera.main; canvas.enabled = CourseRunner.Current != null; } catch (Exception exception) { Debug.LogError($"{exception.GetType().Name} while initializing {GetType().Name}.\n{exception.StackTrace}", gameObject); } Vector3 position = trainee.position + (trainee.forward * appearanceDistance); Quaternion rotation = new Quaternion(0.0f, trainee.rotation.y, 0.0f, trainee.rotation.w); position.y = 1f; transform.SetPositionAndRotation(position, rotation); dropdownsList.AddRange(GetComponentsInChildren <TMP_Dropdown>()); #if ENABLE_INPUT_SYSTEM && XRIT_0_10_OR_NEWER UnityEngine.InputSystem.UI.InputSystemUIInputModule inputSystem = FindObjectOfType <UnityEngine.InputSystem.UI.InputSystemUIInputModule>(); if (inputSystem) { Destroy(inputSystem); } #endif OnValidate(); }
protected virtual void Update() { if (EventSystem.current == null) { return; } #if ENABLE_INPUT_SYSTEM if (inputSystemUIInputModule == null) { inputSystemUIInputModule = FindObjectOfType <UnityEngine.InputSystem.UI.InputSystemUIInputModule>(); } if (writer != null && writer.IsWriting) { if (inputSystemUIInputModule.submit.action.triggered || (cancelEnabled && inputSystemUIInputModule.cancel.action.triggered)) { SetNextLineFlag(); } } #else if (currentStandaloneInputModule == null) { currentStandaloneInputModule = EventSystem.current.GetComponent <StandaloneInputModule>(); } if (writer != null && writer.IsWriting) { if (Input.GetButtonDown(currentStandaloneInputModule.submitButton) || (cancelEnabled && Input.GetButton(currentStandaloneInputModule.cancelButton))) { SetNextLineFlag(); } } #endif switch (clickMode) { case ClickMode.Disabled: break; case ClickMode.ClickAnywhere: #if ENABLE_INPUT_SYSTEM if ((UnityEngine.InputSystem.Mouse.current?.leftButton.wasPressedThisFrame ?? false) || (UnityEngine.InputSystem.Touchscreen.current?.primaryTouch?.press.wasPressedThisFrame ?? false)) #else if (Input.GetMouseButtonDown(0)) #endif { SetNextLineFlag(); } break; case ClickMode.ClickOnDialog: if (dialogClickedFlag) { SetNextLineFlag(); dialogClickedFlag = false; } break; } if (ignoreClickTimer > 0f) { ignoreClickTimer = Mathf.Max(ignoreClickTimer - Time.deltaTime, 0f); } if (ignoreMenuClicks) { // Ignore input events if a Menu is being displayed if (MenuDialog.ActiveMenuDialog != null && MenuDialog.ActiveMenuDialog.IsActive() && MenuDialog.ActiveMenuDialog.DisplayedOptionsCount > 0) { dialogClickedFlag = false; nextLineInputFlag = false; } } // Tell any listeners to move to the next line if (nextLineInputFlag) { var inputListeners = gameObject.GetComponentsInChildren <IDialogInputListener>(); for (int i = 0; i < inputListeners.Length; i++) { var inputListener = inputListeners[i]; inputListener.OnNextLineEvent(); } nextLineInputFlag = false; } }