// Use this for initialization void Start() { this.inputHandler = GvrInputHandler.FindInputHandler(); if (!this.inputHandler) { Debug.LogError("Must have a GvrInputHandler in scene for GVR usage!"); } else { if (tapToPickup) { this.inputHandler.onTapRaw += TapPickup; } else { this.inputHandler.onHoldDownRaw += Pickup; this.inputHandler.onHoldUpRaw += Drop; } } this.playerCamera = Camera.main; this.parent = this.gameObject.transform.parent; // Create an EventTrigger component if one does not exist to intercept click events if (!this.gameObject.GetComponent <EventTrigger>()) { EventTrigger et = this.gameObject.AddComponent <EventTrigger>(); } }
// Use this for initialization void Start() { this.inputHandler = GvrInputHandler.FindInputHandler(); if (!this.inputHandler) { Debug.LogError("Must have a GvrInputHandler in scene for GVR usage!"); } else { this.inputHandler.onHoldDownRaw += StartRotating; this.inputHandler.onHoldUpRaw += StopRotating; } this.playerCamera = Camera.main; // Get the center offset of the models based on the model bounds GetCenterOffset(); // Create the plane that allows for rotation when looking off of the object Vector3 planeNormal = this.playerCamera.transform.position - this.gameObject.transform.TransformPoint(this.centerOffset); planeNormal.Normalize(); this.raycastSurface = new Plane(planeNormal, this.gameObject.transform.TransformPoint(this.centerOffset)); // Create an EventTrigger component if one does not exist to intercept click events if (!this.gameObject.GetComponent <EventTrigger>()) { EventTrigger et = this.gameObject.AddComponent <EventTrigger>(); } }
private bool GetInputHandler() { GameObject player = Camera.main.gameObject.transform.parent.gameObject; this.inputHandler = player.GetComponentInChildren <GvrInputHandler>(); return(this.inputHandler); }
private void Awake() { if (GvrInputHandler.handler) { Debug.Log("Warning! Multiple input handlers detected in scene, there should only be one!"); } else { GvrInputHandler.handler = this; } }
// Use this for initialization void Start() { this.inputHandler = GvrInputHandler.FindInputHandler(); if (!this.inputHandler) { Debug.LogError("Must have a GvrInputHandler in scene for GVR usage!"); } else { if (this.useRawInputs) { if (this.tapToMove) { this.inputHandler.onTapRaw += FlipMovement; } else { this.inputHandler.onHoldDownRaw += StartMovement; this.inputHandler.onHoldUpRaw += StopMovement; } } else { if (this.tapToMove) { this.inputHandler.onTap += FlipMovement; } else { this.inputHandler.onHoldDown += StartMovement; this.inputHandler.onHoldUp += StopMovement; } } } this.playerCamera = Camera.main; /*RaycastHit hit; * if (!Physics.Raycast(this.gameObject.transform.position, new Vector3(0, -1, 0), out hit)) * Physics.Raycast(this.gameObject.transform.position, new Vector3(0, 1, 0), out hit); */ NavMeshHit meshHit; bool validNavMeshLocation = NavMesh.SamplePosition( this.gameObject.transform.position, out meshHit, this.playerHeight, NavMesh.AllAreas); if (validNavMeshLocation) { this.gameObject.transform.position = new Vector3( this.gameObject.transform.position.x, meshHit.position.y + this.playerHeight, this.gameObject.transform.position.z); } else { this.gameObject.transform.position = new Vector3( this.gameObject.transform.position.x, this.gameObject.transform.position.y + this.playerHeight, this.gameObject.transform.position.z); } }