protected void Awake() { renderModelLoadedAction = SteamVR_Events.RenderModelLoadedAction(OnRenderModelLoaded); if (handPrefab != null) { handInstance = GameObject.Instantiate(handPrefab); handInstance.transform.parent = this.transform; handInstance.transform.localPosition = Vector3.zero; handInstance.transform.localRotation = Quaternion.identity; handInstance.transform.localScale = handPrefab.transform.localScale; handSkeleton = handInstance.GetComponent <SteamVR_Behaviour_Skeleton>(); handSkeleton.updatePose = false; handRenderers = handInstance.GetComponentsInChildren <Renderer>(); if (displayHandByDefault == false) { SetHandVisibility(false); } handAnimator = handInstance.GetComponentInChildren <Animator>(); } if (controllerPrefab != null) { controllerInstance = GameObject.Instantiate(controllerPrefab); controllerInstance.transform.parent = this.transform; controllerInstance.transform.localPosition = Vector3.zero; controllerInstance.transform.localRotation = Quaternion.identity; controllerInstance.transform.localScale = controllerPrefab.transform.localScale; controllerRenderModel = controllerInstance.GetComponent <SteamVR_RenderModel>(); } }
static GameObject InitController(GameObject go, int index) { Controller ctrl = go.GetComponent <Controller>(); if (ctrl == null) { ctrl = go.AddComponent <Controller>(); } ctrl.Initialize(index); if (controllers == null) { controllers = new Controller[2]; } controllers[index] = ctrl; if (newPosesAppliedAction == null) { newPosesAppliedAction = SteamVR_Events.NewPosesAppliedAction(OnNewPosesApplied); newPosesAppliedAction.enabled = true; } return(go); }
/// <summary> /// Start a calibration automatically on Awake(). /// </summary> void Awake() { posesAction = SteamVR_Events.NewPosesAction(OnNewPoses); module = GetComponent <ViveModule>() as ViveModule; if (!Valid) { Debug.Log("Holojam.Vive.ViveCalibrator: Build state not valid for calibration"); return; } if (!module.cameraRig) { Network.RemoteLogger.Log( "Calibration failed; ViveModule camera rig not assigned!" ); return; } // Cache the centroid position and rotation for future offset cachedPosition = module.cameraRig.transform.localPosition; cachedRotation = module.cameraRig.transform.localRotation; StartCoroutine(WaitToCalibrate()); }
void Awake() { UpdateTargets(); inputFocusAction = SteamVR_Events.InputFocusAction(OnInputFocus); deviceConnectedAction = SteamVR_Events.DeviceConnectedAction(OnDeviceConnected); trackedDeviceRoleChangedAction = SteamVR_Events.SystemAction(EVREventType.VREvent_TrackedDeviceRoleChanged, OnTrackedDeviceRoleChanged); }
//------------------------------------------------- void Awake() { _instance = this; chaperoneInfoInitializedAction = ChaperoneInfo.InitializedAction(OnChaperoneInfoInitialized); pointerLineRenderer = GetComponentInChildren <LineRenderer>(); teleportPointerObject = pointerLineRenderer.gameObject; int tintColorID = Shader.PropertyToID("_TintColor"); fullTintAlpha = pointVisibleMaterial.GetColor(tintColorID).a; teleportArc = GetComponent <TeleportArc>(); teleportArc.traceLayerMask = traceLayerMask; loopingAudioMaxVolume = loopingAudioSource.volume; playAreaPreviewCorner.SetActive(false); playAreaPreviewSide.SetActive(false); float invalidReticleStartingScale = invalidReticleTransform.localScale.x; invalidReticleMinScale *= invalidReticleStartingScale; invalidReticleMaxScale *= invalidReticleStartingScale; }
private void Awake() { deviceConnectedAction = SteamVR_Events.DeviceConnectedAction(OnDeviceConnected); hideRenderModelsAction = SteamVR_Events.HideRenderModelsAction(OnHideRenderModels); modelSkinSettingsHaveChangedAction = SteamVR_Events.SystemAction(EVREventType.VREvent_ModelSkinSettingsHaveChanged, OnModelSkinSettingsHaveChanged); }
//------------------------------------------------- void Awake() { camera = GameObject.FindGameObjectWithTag("MainCamera"); cameraScript = camera.GetComponent <PostProcess>(); cameraPostProcessMaterial = cameraScript.material; //cameraPostProcessMaterial.SetFloat("_VRadius", 0.0f); //cameraPostProcessMaterial.SetFloat("_VSoft", 0.0f); _instance = this; chaperoneInfoInitializedAction = ChaperoneInfo.InitializedAction(OnChaperoneInfoInitialized); pointerLineRenderer = GetComponentInChildren <LineRenderer>(); teleportPointerObject = pointerLineRenderer.gameObject; int tintColorID = Shader.PropertyToID("_TintColor"); fullTintAlpha = pointVisibleMaterial.GetColor(tintColorID).a; teleportArc = GetComponent <TeleportArc>(); teleportArc.traceLayerMask = traceLayerMask; loopingAudioMaxVolume = loopingAudioSource.volume; playAreaPreviewCorner.SetActive(false); playAreaPreviewSide.SetActive(false); float invalidReticleStartingScale = invalidReticleTransform.localScale.x; invalidReticleMinScale *= invalidReticleStartingScale; invalidReticleMaxScale *= invalidReticleStartingScale; }
protected void Awake() { renderModelLoadedAction = SteamVR_Events.RenderModelLoadedAction(OnRenderModelLoaded); InitializeHand(); InitializeController(); }
void Start() { newPoses = SteamVR_Events.NewPosesAction(OnNewPoses); newPoses.enabled = true; RegisterExistingPads(); HideGameObjectFromZED(); }
/// <summary> /// Initializes references to Reference Manager and Laser Sight, sets this /// GameObject to the player ship reference in Reference Manager. /// </summary> private void Awake() { reference = FindObjectOfType <ReferenceManager>(); newPosesAppliedAction = SteamVR_Events.NewPosesAppliedAction(OnNewPosesApplied); if (reference == null) { Debug.LogError(GetType().Name + " - Could not find Reference Manager!"); } else { reference.playerShip = gameObject; reference.playerShipSource = source; reference.tooltips.ShipGrabbed(); SetWeapon((int)reference.gameSettings.selectedWeapon); if (reference.shipPickup) { reference.shipPickup.SetActive(false); } if (reference.powerUpStatus) { reference.powerUpStatus.BeginTracking(reference, hand); } if (reference.gameSettings.selectedGameMode == GameSettings.GameMode.SoloNormal) { if (reference.waveManager != null) { reference.waveManager.Run(); } else { Debug.LogError(GetType().Name + " - Reference.WaveManager is null. Cannot call Run()."); } } else { if (reference.countdown) { reference.countdown.SetActive(true); } else { Debug.LogError( GetType().Name + " - Reference.Countdown is null. Cannot enable."); } } StartCoroutine(IntroAudio()); reference.tooltips.SpawnProtectShip(); } }
// Constructor: Attach callback function to Vive Tracker data UpdateFoveFromViveTracker() { newPosesAction = SteamVR_Events.NewPosesAction(onNewPose); deviceConnectedAction = SteamVR_Events.DeviceConnectedAction(onNewDeviceConnection); lastDriftCorrectionTimeMs = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; FoveViveToWorldSpace = Quaternion.Euler(0.0f, 0.0f, 0.0f); rotateSetupDegree = 0; isHeadsetCalibrated = false; }
void Awake() { if (Instance == null) { Instance = this; } newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); }
//------------------------------------------------- //被VRTK抓取事件处理函数替代 //private void OnAttachedToHand(Hand attachedHand) //{ // hand = attachedHand; //} //------------------------------------------------- void Awake() { longBowAni = GetComponent <Animator>(); longBowAni.speed = 0; bowCollider = GetComponent <SphereCollider>(); newPosesAppliedAction = SteamVR_Events.NewPosesAppliedAction(OnNewPosesApplied); GetComponent <VRTK_InteractableObject>().InteractableObjectGrabbed += VRTKLongBow_InteractableObjectGrabbed; GetComponent <VRTK_InteractableObject>().InteractableObjectUngrabbed += VRTKLongBow_InteractableObjectUngrabbed; }
public static void SubscribeToNewPoses() { if (newPosesAction == null) { newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); } newPosesAction.enabled = true; }
//------------------------------------------------- void Awake() { renderModelLoadedAction = SteamVR_Events.RenderModelLoadedAction(OnRenderModelLoaded); #if UNITY_URP colorID = Shader.PropertyToID("_BaseColor"); #else colorID = Shader.PropertyToID("_Color"); #endif }
void Awake() { newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); HmdMatrix44_t mat = new HmdMatrix44_t(); /**************************************/ /* * -0.102501 0.19387 0.975658 0.690977 * 0.00933648 0.980968 -0.193944 0.545085 * -0.994689 -0.0107702 -0.10236 -0.111363 * 0 0 0 1 */ /* * mat.m0 = -0.102501f; * mat.m1 = 0.19387f; * mat.m2 = 0.975658f; * mat.m3 = 0.690977f; * mat.m4 = 0.00933648f; * mat.m5 = 0.980968f; * mat.m6 = -0.193944f; * mat.m7 = 0.545085f; * mat.m8 = -0.994689f; * mat.m9 = -0.0107702f; * mat.m10 = -0.10236f; * mat.m11 = -0.111363f; * mat.m12 = 0; * mat.m13 = 0; * mat.m14 = 0; * mat.m15 = 1; */ mat.m0 = -0.102501f; mat.m4 = 0.19387f; mat.m8 = 0.975658f; mat.m12 = 0.690977f; mat.m1 = 0.00933648f; mat.m5 = 0.980968f; mat.m9 = -0.193944f; mat.m13 = 0.545085f; mat.m2 = -0.994689f; mat.m6 = -0.0107702f; mat.m10 = -0.10236f; mat.m14 = -0.111363f; mat.m3 = 0; mat.m7 = 0; mat.m11 = 0; mat.m15 = 1; /**************************************/ BMatInv = new SteamVR_Utils.RigidTransform(mat); BMatInv.Inverse(); }
void OnEnable() { var render = SteamVR_Render.instance; if (render == null) { enabled = false; return; } newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); newPosesAction.enabled = true; }
private void OnEnable() { #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif keyboardCharInputAction = SteamVR_Events.SystemAction(EVREventType.VREvent_KeyboardCharInput, OnKeyboard); keyboardCharInputAction.enabled = true; keyboardClosedAction = SteamVR_Events.SystemAction(EVREventType.VREvent_KeyboardClosed, OnKeyboardClosed); keyboardClosedAction.enabled = true; }
//------------------------------------------------- void Awake() { inputFocusAction = SteamVR_Events.InputFocusAction(OnInputFocus); if (hoverSphereTransform == null) { hoverSphereTransform = this.transform; } applicationLostFocusObject = new GameObject("_application_lost_focus"); applicationLostFocusObject.transform.parent = transform; applicationLostFocusObject.SetActive(false); }
private void OnDisable() { #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif keyboardCharInputAction.enabled = false; keyboardCharInputAction = null; keyboardClosedAction.enabled = false; keyboardClosedAction = null; }
void Awake() { newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); headCamera = GameObject.Find(cameraName); headTracking = GameObject.Find(headTrackingName); var error = EVRSettingsError.None; if (OpenVR.Settings.GetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_ForceFadeOnBadTracking_Bool, ref error)) { OpenVR.Settings.SetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_ForceFadeOnBadTracking_Bool, false, ref error); OpenVR.Settings.Sync(true, ref error); } }
/// <summary> /// Initialized all the components /// </summary> void Start() { newPoses = SteamVR_Events.NewPosesAction(OnNewPoses); newPoses.enabled = true; RegisterExistingPads(); HideGameObjectFromZED(); if (UnityEngine.XR.XRDevice.model.Contains("Oculus")) { model = HMD.OCULUS; } else { model = HMD.STEAMVR; } }
/// <summary> /// Initializes, and caches the position/rotation of the centroid. /// </summary> void Awake() { posesAction = SteamVR_Events.NewPosesAction(OnNewPoses); module = GetComponent <ViveModule>() as ViveModule; if (!module.cameraRig) { Debug.Log("Holojam.Vive.ViveCalibrator: ViveModule camera rig not assigned!"); return; } cachedPosition = module.cameraRig.transform.localPosition; cachedRotation = module.cameraRig.transform.localRotation; calibratedPosition = cachedPosition; calibratedRotation = cachedRotation; Tools.InfoPanel.SetString("calibrator", "Calibrator: waiting"); }
protected virtual void Awake() { InitializeHandHelper(); inputFocusAction = SteamVR_Events.InputFocusAction(OnInputFocus); if (hoverSphereTransform == null) { hoverSphereTransform = this.transform; } applicationLostFocusObject = new GameObject("_application_lost_focus"); applicationLostFocusObject.transform.parent = transform; applicationLostFocusObject.SetActive(false); if (trackedObject == null) { trackedObject = this.gameObject.GetComponent <SteamVR_Behaviour_Pose>(); } trackedObject.onTransformUpdated.AddListener(OnTransformUpdated); }
void Awake() { mInputFocusAction = SteamVR_Events.InputFocusAction(OnInputFocus); }
TrackedObject() { newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); }
//------------------------------------------------- private void Awake() { newPosesAppliedAction = SteamVR_Events.NewPosesAppliedAction(OnNewPosesApplied); }
SteamVR_ControllerManager() { inputFocusAction = SteamVR_Events.InputFocusAction(OnInputFocus); deviceConnectedAction = SteamVR_Events.DeviceConnectedAction(OnDeviceConnected); trackedDeviceRoleChangedAction = SteamVR_Events.SystemAction(EVREventType.VREvent_TrackedDeviceRoleChanged, OnTrackedDeviceRoleChanged); }
//------------------------------------------------- void Awake() { renderModelLoadedAction = SteamVR_Events.RenderModelLoadedAction(OnRenderModelLoaded); }
//------------------------------------------------- private void Awake() { renderModelLoadedAction = SteamVR_Events.RenderModelLoadedAction(OnRenderModelLoaded); colorID = Shader.PropertyToID("_Color"); }