public void Run() { /*RaycastHit h; * bool hit = Physics.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Camera.main.transform.forward,out h);*/ if (run && Input.touchCount > index) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.GetTouch(index).position), Vector2.zero); foreach (Button b in buttons) { if (hit && hit.transform.gameObject == b.gameObject && CInput.TouchClick(index)) { b.isClicked = true; } else { b.isClicked = false; } if (hit && hit.transform.gameObject == b.gameObject && (Input.GetTouch(index).phase == TouchPhase.Stationary || Input.GetTouch(index).phase == TouchPhase.Moved) && b.clicked) { b.gameObject.GetComponent <SpriteRenderer>().sprite = b.clicked; } else if (b.gameObject) { b.gameObject.GetComponent <SpriteRenderer>().sprite = b.normal; } } foreach (HorizontalSlider hs in horizontalSliders) { hs.valuer.transform.localPosition = new Vector3(Mathf.Clamp(hs.valuer.transform.localPosition.x, hs.left.x, hs.right.x), 0, -0.01f); if (hit && /*h*/ hit.transform.gameObject == hs.valuer && Input.GetMouseButton(0)) { hs.drag = true; } if (Input.GetMouseButtonUp(0)) { hs.drag = false; } if (hs.drag) { hs.value = CalculateValue(hs.left, hs.right, hs.valuer.transform.localPosition); Vector2 position = Camera.main.ScreenToWorldPoint(Input.mousePosition); position.y = hs.valuer.transform.position.y; Vector3 tmp = hs.valuer.transform.localPosition; //tmp.x = position.x-hs.slider.transform.position.x; tmp.x += CInput.MouseSpeed().x *Time.deltaTime; valuerdelta = Input.mousePosition - valuerlastpos; valuerlastpos = Input.mousePosition; //tmp.y = position.y-hs.slider.transform.position.y; hs.valuer.transform.localPosition = tmp; //hs.valuer.transform.localPosition = new Vector3(hs.valuer.transform.localPosition.x, hs.valuer.transform.localPosition.y, -0.1f); Debug.Log(hs.value); hs.valuer.transform.localPosition = new Vector3(Mathf.Clamp(hs.valuer.transform.localPosition.x, hs.left.x, hs.right.x), 0, -0.01f); } } } else { foreach (Button b in buttons) { if (b.isClicked) { b.isClicked = false; } } } }