//------------------------------------------------------------------------------------------------------------------ // Interaction Listeners //------------------------------------------------------------------------------------------------------------------ protected virtual void OnPointerSet(object sender, CreationPointerEventArgs e) { if (!isHolding && isTouching && (e.targetObject == null || !e.targetObject.CompareTag("created"))) { interactTouch.ForceStopTouching(); return; } if (e.targetObject != null) { if (!isHolding && !isTouching && e.targetObject.CompareTag("created")) { interactTouch.ForceTouch(e.targetObject); } } }
// Update is called once per frame protected override void Update() { base.Update(); if (!isOn) { return; } RaycastHit hit; Ray gazeRay = new Ray(transform.position, transform.forward); bool hasRayHit = Physics.Raycast(gazeRay, out hit, maxLength, ~layersToIgnore); CreationPointerEventArgs eventArgs = new CreationPointerEventArgs(); if (hasRayHit && hit.distance < maxLength) { SetPointerTransform(hit.distance); eventArgs.targetObject = hit.transform.gameObject; eventArgs.target = hit.transform; eventArgs.distance = hit.distance; pointerContactDistance = hit.distance; pointerContactTarget = hit.transform; destinationPosition = pointerTip.transform.position; base.PointerIn(); } else { SetPointerTransform(maxLength); eventArgs.distance = maxLength; base.PointerOut(); pointerContactDistance = 0f; pointerContactTarget = null; destinationPosition = Vector3.zero; } eventArgs.position = pointerTip.transform.position; eventArgs.controllerIndex = (uint)controller.GetComponent <SteamVR_TrackedObject>().index; CreationPointerSet(this, eventArgs); }
protected virtual void DoLeftPointerOff(object sender, CreationPointerEventArgs e) { ClearLeftDestination(); }
protected virtual void DoLeftPointerSet(object sender, CreationPointerEventArgs e) { leftDestination = e.position; leftTarget = e.targetObject; }
protected virtual void DoRightPointerSet(object sender, CreationPointerEventArgs e) { rightDestination = e.position; rightTarget = e.targetObject; }