public void TouchUp(VRInput source) { if (OnTouchUp != null) { OnTouchUp(source); } }
public void TouchDown(VRInput source) { if (OnTouchDown != null) { OnTouchDown(source); } }
public void TriggerDown(VRInput source) { if (OnTriggerDown != null) { OnTriggerDown(source); } }
public void Click(VRInput source) { if (OnClick != null) { OnClick(source); } }
public void Down(VRInput source) { if (OnDown != null) { OnDown(source); } }
public void Up(VRInput source) { if (OnUp != null) { OnUp(source); } }
public void DoubleClick(VRInput source) { if (OnDoubleClick != null) { OnDoubleClick(source); } }
public void TriggerOver(VRInput source) { m_nTriggerCount++; if (OnTriggerOver != null) { OnTriggerOver(source); } }
public void TriggerOut(VRInput source) { m_nTriggerCount--; if (OnTriggerOut != null) { OnTriggerOut(source); } }
public void PointerOut(VRInput source) { m_nPointerCount--; if (OnPointerOut != null) { OnPointerOut(source); } }
public void TriggerUp(VRInput source) { if (OnTriggerUp != null) { OnTriggerUp(source); } TriggerOut(source); }
public void GazeOut(VRInput source) { m_nGazeCount--; if (OnGazeOut != null) { OnGazeOut(source); } }
public void PointerOver(VRInput source) { m_nPointerCount++; if (OnPointerOver != null) { OnPointerOver(source); } }
// The below functions are called by the VREyeRaycaster when the appropriate input is detected. // They in turn call the appropriate events should they have subscribers. public void GazeOver(VRInput source) { m_nGazeCount++; if (OnGazeOver != null) { OnGazeOver(source); } }
public void SetInput(VRInput input) { // Unlikely, but if we weren't null and are enabled // then unsubscribe and resubscribe later if (isActiveAndEnabled) { clearCallbacks(); } m_VrInput = input; if (m_VrInput != null) { transform.SetParent(m_VrInput.transform); } if (isActiveAndEnabled) { setCallbacks(); } }
// On trigger up, if we have a follow object and our input is its parent // (which is guaranteed, I think), then destroy the tracked object and unsubscribe private void Detach() { // Destroy tracked object if (m_InputFollow) { m_ActiveInput._onRelease(this); if (OnRelease != null) { OnRelease(this, m_ActiveInput); } Destroy(m_InputFollow.gameObject); m_InputFollow = null; } // Unsubscribe if we've assigned this (only assigned when we subscribe) if (m_ActiveInput) { m_ActiveInput.OnTriggerUp -= Detach; m_ActiveInput = null; } }
// On grab we create an object to follow at our position // but as a child of the input - when the input moves, // our tracked object moves with it and we respond private void Attach(VRInput input) { // Detach, just in case Detach(); // Create object to follow at our pull distance from the input m_InputFollow = new GameObject("GrabFollow").transform; Vector3 v3PullDist = PullDistance * input.transform.forward.normalized; m_InputFollow.transform.position = input.transform.position + v3PullDist; m_InputFollow.transform.parent = input.transform; // Subscribe to this input's OnTriggerUp and cache // it so that we can unsubscribe from OnTriggerUp m_ActiveInput = input; input.OnTriggerUp += Detach; input._onGrab(this); if (OnGrab != null) { OnGrab(this, input); } }