public void RemoveTouch(Touch t) { if (touchCount > 0) { touchCount--; } }
Joint addJoint(Rigidbody attachTo, GameObject go, Vector3 hitPoint, Touch t) { Joint j = (Joint)go.GetComponent <Joint>(); // Initial position of the joint is the centre of the body we pickup or the hook if (hook != null) { go.transform.position = hook.transform.position; } else { go.transform.position = hitPoint; } // Deal with centre of mass if (attachToCenterOfMass) { Vector3 anchor = go.transform.InverseTransformPoint(attachTo.worldCenterOfMass); j.anchor = anchor; } else { j.anchor = Vector3.zero; } initJoint(j, attachTo); joints.Add(t.fingerId, j); return(j); }
void addTouch(Touch t) { RaycastHit h = new RaycastHit(); bool hasHit = (Physics.Raycast(getRay(t), out h, 100f, GetLayerMask(hitOnlyLayers))); addTouchIcon(h.point, t, hasHit); }
void startTrace(RaycastHit h, Touch t, bool hasHit) { Vector3? start = hasHit ? (Vector3?)h.point : null; TouchTrace tr = new TouchTrace(Time.time, start); liveTraces.Add(t.fingerId, tr); }
void removeTouchIcon(Touch t) { GameObject go = touchIcons[t.fingerId]; touchIcons.Remove(t.fingerId); Destroy(go); }
void updateTouchIcon(Vector3 hitPoint, Touch t, bool visible) { GameObject go = touchIcons[t.fingerId]; go.transform.position = hitPoint; go.renderer.enabled = visible; }
void removeDragger(Touch t) { GameObject go = draggers[t.fingerId]; draggers.Remove(t.fingerId); Destroy(go); }
Ray getRay(Touch t) { Vector3 touchPoint = new Vector3(t.position.x, t.position.y, 0f); Ray targetRay = targetCam.ScreenPointToRay(touchPoint); return(targetRay); }
void Update() { if (frameTouches.Length > 0 && frameTouches[0].phase == TouchPhase.Ended) { frameTouches = new Touch[0]; } Vector2 pos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); if (Input.GetMouseButtonDown(0) && touchCount == 0) { // New touch Touch t = new Touch(0, pos, Vector2.zero, 0f, 0, TouchPhase.Began); frameTouches = new Touch[1] { t }; touchCount = 1; } else if (Input.GetMouseButtonUp(0)) { // Removed touch Vector2 deltaPos = frameTouches[0].position - pos; Touch t = new Touch(0, pos, deltaPos, 0f, 0, TouchPhase.Ended); frameTouches[0] = t; touchCount = 0; } else if (Input.GetMouseButton(0)) { Vector2 deltaPos = frameTouches[0].position - pos; TouchPhase phase = deltaPos == Vector2.zero ? TouchPhase.Stationary : TouchPhase.Moved; Touch t = new Touch(0, pos, deltaPos, 0f, 0, phase); frameTouches[0] = t; } }
public override void RemoveTouch(Touch t) { base.RemoveTouch(t); if (Tolerances.TriggerOnTouchDown) return; // Not most recent touch? if (curTouch.fingerId != t.fingerId) return; if (Tolerances.CheckHeldTime && Time.time - TimeAdded > Tolerances.MaxHeldTime) return; if (Tolerances.CheckMovementThreshold) { // Over the movement threshold? Vector2 curTouchPos = new Vector2( t.position.x / (float)screenWidth, t.position.y / (float)screenHeight); if (Vector2.Distance(curTouchPos, originalPos) > Tolerances.MaximumPosChange) return; } // Check if the touch still hits the same collider RaycastHit h = new RaycastHit(); if(Tolerances.CheckHitsSameCollider && !HitsOrigCollider(t, out h)) return; DoClick(h); ClearCurTouch(); }
void removeTouch(Touch t) { RaycastHit h = new RaycastHit(); bool hasHit = (Physics.Raycast(getRay(t), out h, Mathf.Infinity, LayerHelper.GetLayerMask(hitOnlyLayers))); endTrace(h, t, hasHit); }
void Update() { if (frameTouches.Length > 0 && frameTouches[0].phase == TouchPhase.Ended) frameTouches = new Touch[0]; Vector2 pos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); if (Input.GetMouseButtonDown(0) && touchCount == 0) { // New touch Touch t = new Touch(0, pos, Vector2.zero, 0f, 0, TouchPhase.Began); frameTouches = new Touch[1] { t }; touchCount = 1; } else if (Input.GetMouseButtonUp(0)) { // Removed touch Vector2 deltaPos = frameTouches[0].position - pos; Touch t = new Touch(0, pos, deltaPos, 0f, 0, TouchPhase.Ended); frameTouches[0] = t; touchCount = 0; } else if (Input.GetMouseButton(0)) { Vector2 deltaPos = frameTouches[0].position - pos; TouchPhase phase = deltaPos == Vector2.zero ? TouchPhase.Stationary : TouchPhase.Moved; Touch t = new Touch(0, pos, deltaPos, 0f, 0, phase); frameTouches[0] = t; } }
public void UpdateTouch(Touch t) { if (!touches.ContainsKey(t.fingerId)) { return; } touches[t.fingerId] = t; }
public void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { // Create the object we want in the touch position GameObject go = createInstance(hit.point, hitOn); // If object has a collider, relink internally if (DoRecast && go.collider != null) linker.AddTouch(t, hitOn, go.collider); }
public override void AddTouch (Touch t, RaycastHit hit, Camera hitOn) { base.AddTouch(t, hit, hitOn); TimeAdded = Time.time; if (Tolerances.TriggerOnTouchDown) DoClick(hit); }
public override void RemoveTouch(Touch t) { base.RemoveTouch(t); if(curTouch.fingerId == t.fingerId) { CancelHeld(); } }
public override void RemoveTouch(Touch t) { base.RemoveTouch(t); if (curTouch.fingerId == t.fingerId) { CancelHeld(); } }
protected bool HitsOrigCollider(Touch inTouch, out RaycastHit outHit) { if (origCollider == null) { outHit = new RaycastHit(); return(false); } return(origCollider.Raycast(getRay(inTouch), out outHit, Mathf.Infinity)); }
GameObject addTouchIcon(Vector3 hitPoint, Touch t, bool visible) { GameObject go = (GameObject)Instantiate(TouchIcon); go.transform.position = new Vector3(hitPoint.x, hitPoint.y, hitPoint.z); go.renderer.enabled = visible; touchIcons.Add(t.fingerId, go); return(go); }
void updateTouchIcon(Touch t) { if (!touchIcons.ContainsKey(t.fingerId)) { return; } GUITexture go = touchIcons[t.fingerId]; setTouchIconPos(go, t.position); }
GUITexture addTouchIcon(Touch t) { GameObject touchIcon = (GameObject)Instantiate(GUITouchIcon); GUITexture texture = touchIcon.GetComponent <GUITexture>(); setTouchIconPos(texture, t.position); touchIcons.Add(t.fingerId, texture); return(texture); }
public void RemoveTouch(Touch t) { if (!enabled) { return; } removeJoint(t.fingerId); removeDragger(t); }
void updateDragger(Vector3 hitPoint, Touch t, bool visible) { GameObject go = draggers[t.fingerId]; go.transform.position = hitPoint; if (go.renderer != null) { go.renderer.enabled = visible && showDraggers; } }
public void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { // Create the object we want in the touch position GameObject go = createInstance(hit.point, hitOn); // If object has a collider, relink internally if (DoRecast && go.collider != null) { linker.AddTouch(t, hitOn, go.collider); } }
public override void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { base.AddTouch(t, hit, hitOn); TimeAdded = Time.time; if (Tolerances.TriggerOnTouchDown) { DoClick(hit); } }
void updateTouch(Touch t) { RaycastHit h = new RaycastHit(); bool hasHit = (Physics.Raycast(getRay(t), out h, Mathf.Infinity, LayerHelper.GetLayerMask(hitOnlyLayers))); if (!hasHit) { return; } updateTrace(h, t); }
void updateTrace(RaycastHit h, Touch t) { if (!liveTraces.ContainsKey(t.fingerId)) { return; } TouchTrace tr = liveTraces[t.fingerId]; tr.positions.Add(h.point); }
public override void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { base.AddTouch(t, hit, hitOn); if(curTouch.fingerId == t.fingerId) { if (TouchStartMessege != string.Empty) BroadcastTouchMessage(TouchStartMessege, hit); heldTimer.StartCountdown(HoldTime); } }
void removeTouchIcon(Touch t) { if (!touchIcons.ContainsKey(t.fingerId)) { return; } GUITexture go = touchIcons[t.fingerId]; touchIcons.Remove(t.fingerId); Destroy(go.gameObject); }
public void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { if (!enabled) { return; } targetCamera = hitOn; GameObject go = addDragger(hit.point, t, true); Rigidbody bod = attachToParent ? transform.parent.rigidbody : rigidbody; addJoint(bod, go, hit.point, t); }
public void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { if (enabled) { if (touches.Count == 0) { notifyObject.SendMessage(EventOnTouchDown, SendMessageOptions.DontRequireReceiver); } } targetCamera = hitOn; touches.Add(t.fingerId, t); touchesChanged = true; }
GameObject addDragger(Vector3 hitPoint, Touch t, bool visible) { GameObject go = (GameObject)Instantiate(dragger); go.transform.position = hitPoint; if (go.renderer != null) { go.renderer.enabled = visible && showDraggers; } draggers.Add(t.fingerId, go); return(go); }
public override void UpdateTouch(Touch t) { base.UpdateTouch(t); if(curTouch.fingerId != t.fingerId || !touchSet) return; if(heldTimer.RemainingTime > 0.0f) return; RaycastHit h = new RaycastHit(); if(collider != null && !HitsOrigCollider(t, out h)) return; BroadcastTouchMessage(HeldMessage, h); EndHeld(); }
public override void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { base.AddTouch(t, hit, hitOn); if (curTouch.fingerId == t.fingerId) { if (TouchStartMessege != string.Empty) { BroadcastTouchMessage(TouchStartMessege, hit); } heldTimer.StartCountdown(HoldTime); } }
public void RemoveTouch(Touch t) { touches.Remove(t.fingerId); touchesChanged = true; if (!enabled) { return; } if (touches.Count == 0) { notifyObject.SendMessage(EventOnTouchUp, SendMessageOptions.DontRequireReceiver); } }
public virtual void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { targetCam = hitOn; // This will always keep the most recent touch AssignCurTouch(t); screenWidth = hitOn.pixelWidth; screenHeight = hitOn.pixelHeight; originalPos = new Vector2( t.position.x / (float)screenWidth, t.position.y / (float)screenHeight); origCollider = hit.collider; }
public virtual void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { targetCam = hitOn; // This will always keep the most recent touch AssignCurTouch(t); screenWidth = hitOn.pixelWidth; screenHeight = hitOn.pixelHeight; originalPos = new Vector2( t.position.x / (float)screenWidth, t.position.y / (float)screenHeight); origCollider = hit.collider; }
public override void RemoveTouch(Touch t) { base.RemoveTouch(t); if (Tolerances.TriggerOnTouchDown) { return; } // Not most recent touch? if (curTouch.fingerId != t.fingerId) { return; } if (Tolerances.CheckHeldTime && Time.time - TimeAdded > Tolerances.MaxHeldTime) { return; } if (Tolerances.CheckMovementThreshold) { // Over the movement threshold? Vector2 curTouchPos = new Vector2( t.position.x / (float)screenWidth, t.position.y / (float)screenHeight); if (Vector2.Distance(curTouchPos, originalPos) > Tolerances.MaximumPosChange) { return; } } // Check if the touch still hits the same collider RaycastHit h = new RaycastHit(); if (Tolerances.CheckHitsSameCollider && !HitsOrigCollider(t, out h)) { return; } DoClick(h); ClearCurTouch(); }
Joint addJoint(Rigidbody attachTo, GameObject go, Vector3 hitPoint, Touch t) { Joint j = (Joint)go.GetComponent<Joint>(); // Initial position of the joint is the centre of the body we pickup or the hook if (hook != null) { go.transform.position = hook.transform.position; } else { go.transform.position = hitPoint; } // Deal with centre of mass if (attachToCenterOfMass) { Vector3 anchor = go.transform.InverseTransformPoint(attachTo.worldCenterOfMass); j.anchor = anchor; } else { j.anchor = Vector3.zero; } initJoint(j, attachTo); joints.Add(t.fingerId, j); return j; }
public void RemoveTouch(Touch t) { if (touchCount > 0) touchCount--; }
public void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { if (!enabled) return; targetCamera = hitOn; GameObject go = addDragger(hit.point, t, true); Rigidbody bod = attachToParent ? transform.parent.rigidbody : rigidbody; addJoint(bod, go, hit.point, t); }
public void RemoveTouch(Touch t) { if (!enabled) return; removeJoint(t.fingerId); removeDragger(t); }
public void RemoveTouch(Touch t) { touchCount--; }
public void UpdateTouch(Touch t) { if (!enabled) return; Ray touchRay = getRay(t); // Raycast against the hit layers to get new position based on touch position RaycastHit h = new RaycastHit(); bool hasHit = (Physics.Raycast(touchRay, out h, Mathf.Infinity, LayerHelper.GetLayerMask(hitOnlyLayers))); if (!hasHit) return; Vector3 cPos = h.point.UpTowards(targetCamera.transform.position, upDir, liftBy); // Check if we are within bounds (if defined) if (DragBounds != null) { // Raycast from the target position to the centre of the bounds, if we hit it, we are outside it. Vector3 diffDir = (DragBounds.transform.position - cPos).normalized; RaycastHit colH; hasHit = DragBounds.Raycast(new Ray(cPos, diffDir), out colH, Vector3.Distance(cPos, DragBounds.transform.position)); // If we hit the bounds, set the position to where we hit on the bounds if (hasHit) cPos = colH.point; } // Move the dragger to the new position updateDragger(cPos, t, hasHit); }
protected void AssignCurTouch(Touch inTouch) { curTouch = inTouch; touchSet = true; }
protected void ClearCurTouch() { curTouch = new Touch(); touchSet = false; }
public void UpdateTouch(Touch t) { if (!touches.ContainsKey(t.fingerId)) return; touches[t.fingerId] = t; }
void updateDragger(Vector3 hitPoint, Touch t, bool visible) { GameObject go = draggers[t.fingerId]; go.transform.position = hitPoint; if (go.renderer != null) go.renderer.enabled = visible && showDraggers; }
GameObject addDragger(Vector3 hitPoint, Touch t, bool visible) { GameObject go = (GameObject)Instantiate(dragger); go.transform.position = hitPoint; if (go.renderer != null) go.renderer.enabled = visible && showDraggers; draggers.Add(t.fingerId, go); return go; }
Ray getRay(Touch t) { Vector3 touchPoint = new Vector3(t.position.x, t.position.y, 0f); Ray targetRay = targetCam.ScreenPointToRay(touchPoint); return targetRay; }
protected bool HitsOrigCollider(Touch inTouch, out RaycastHit outHit) { if (origCollider == null) { outHit = new RaycastHit(); return false; } return origCollider.Raycast(getRay(inTouch), out outHit, Mathf.Infinity); }
public virtual void RemoveTouch(Touch t) { }
public void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { targetCamera = hitOn; touches.Add(t.fingerId, t); touchesChanged = true; }
public void RemoveTouch(Touch t) { touches.Remove(t.fingerId); touchesChanged = true; }
public void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { if (enabled) { if (touches.Count == 0) { notifyObject.SendMessage(EventOnTouchDown, SendMessageOptions.DontRequireReceiver); } } targetCamera = hitOn; touches.Add(t.fingerId, t); touchesChanged = true; }
void removeDragger(Touch t) { GameObject go = draggers[t.fingerId]; draggers.Remove(t.fingerId); Destroy(go); }
public void AddTouch(Touch t, RaycastHit hit, Camera hitOn) { touchCount++; }
public void RemoveTouch(Touch t) { touches.Remove(t.fingerId); touchesChanged = true; if (!enabled) return; if (touches.Count == 0) { notifyObject.SendMessage(EventOnTouchUp, SendMessageOptions.DontRequireReceiver); } }
public void UpdateTouch(Touch t) { }
public virtual void UpdateTouch(Touch t) { }