/* public bool getTouch() * { * if (Input.touchCount > 0) * { * Touch touch = Input.GetTouch(0); * if (touch.phase == TouchPhase.Began) * { * Vector2 pos = Camera.main.ScreenToWorldPoint(touch.position); * RaycastHit2D hit = Physics2D.Raycast(pos, Vector2.zero, 0f); * * if (hit.collider != null) * { * inputNum[index] = hit.collider.name[hit.collider.name.Length - 1] - '0'; * return true; * } * } * } * return false; * } */ public bool getTouch() { bool toReturn = false; int count = Input.touchCount; for (int i = 0; i < count; i++) { Touch touch = Input.GetTouch(i); if (touch.phase == TouchPhase.Began) { Vector2 pos = Camera.main.ScreenToWorldPoint(touch.position /*Input.mousePosition */); RaycastHit2D hit = Physics2D.Raycast(pos, Vector2.zero, 0f); if (hit.collider != null) { target = hit.collider.GetComponent <InputCollider>(); int selectedCollider = target.name[target.name.Length - 1] - '0'; fadeCoroutine[selectedCollider - 1] = target.StartCoroutine(target.fade(fadeCoroutine[selectedCollider - 1])); if (i == 0) { if (index < inputNum.Length) { inputNum[index] = selectedCollider; toReturn = true; } } } } } return(toReturn); }
// Use this for initialization void Start() { inputInfo = GetInputType(); spriteSelector = new InputSpriteSelector( gameObject.GetComponent <SpriteRenderer>(), Resources.LoadAll <Sprite>("debug_circles")); inputCollider = new InputCollider(collisionRadius, collisionMask); inputAnchorPoint = new Vector2(); grabPullBehaviour = new GrabPullBehaviour(); objectAnchor = new Vector2(); }