public virtual void OnColliderEventPressDown(ColliderButtonEventData eventData) { if (!IsValidGrabButton(eventData)) { return; } Grabber grabber; if (TryGetExistsGrabber(eventData, out grabber)) { return; } var currentFrame = Time.frameCount; ButtonProcessedState pState; if (m_buttonProcessedFrame.TryGetValue(eventData, out pState)) { // skip if button was just processed for release if (pState.processedFrame == currentFrame) { Debug.Assert(!pState.isGrabbing); return; } } if (!m_allowMultipleGrabbers) { ClearGrabbers(); } if (m_grabOnLastEntered && !eventData.eventCaster.lastEnteredCollider.transform.IsChildOf(transform)) { return; } if (AddGrabber(eventData)) { m_buttonProcessedFrame[eventData] = new ButtonProcessedState() { isGrabbing = true, processedFrame = currentFrame }; if (m_updateCoroutine.IsNullOrDone()) { LiteCoroutine.StartCoroutine(ref m_updateCoroutine, GrabUpdate(), false); if (moveByVelocity) { LiteCoroutine.StartCoroutine(ref m_physicsCoroutine, PhysicsGrabUpdate(), false); } } } }
public virtual void OnBeginDrag(PointerEventData eventData) { if (AddGrabber(eventData)) { if (m_updateCoroutine.IsNullOrDone()) { LiteCoroutine.StartCoroutine(ref m_updateCoroutine, DragUpdate(), false); if (moveByVelocity) { LiteCoroutine.StartCoroutine(ref m_physicsCoroutine, PhysicsGrabUpdate(), false); } } } }
private IEnumerator Start() { // Start coroutine using static function Debug.Log("### Start Coroutine with Static Function"); LiteCoroutine coroutineHandle1 = LiteCoroutine.StartCoroutine(PromptCoroutine()); yield return(coroutineHandle1); // Stop/Interrupt coroutine Debug.Log("### Stop Coroutine"); LiteCoroutine coroutineHandle2 = LiteCoroutine.StartCoroutine(PromptCoroutine()); yield return(NewWaitInstruction(2.5f)); coroutineHandle2.Stop(); yield return(coroutineHandle2); // IsNullOrDone works on null handle if (m_handle.IsNullOrDone()) { // Create & Assign new handle since m_handle is null Debug.Log("### Initiate Coroutine Handle and Start New Coroutine"); LiteCoroutine.StartCoroutine(ref m_handle, PromptCoroutine()); yield return(m_handle); // Reuse m_handle since m_handle is no null Debug.Log("### Reuse Coroutine Handle and Start New Coroutine"); LiteCoroutine.StartCoroutine(ref m_handle, PromptCoroutine()); // Stop & Restart using existing coroutine handle yield return(NewWaitInstruction(2.5f)); Debug.Log("### Stop and Restart Coroutine Using Existing Handle"); LiteCoroutine.StartCoroutine(ref m_handle, PromptCoroutine()); } // Manually wait for coroutine handle finished while (!m_handle.IsDone) { yield return(null); } Debug.Log("### Manually Wait for Coroutine Handle to be Finished"); }