Beispiel #1
0
 private Vector3 TouchToScreen(TouchData touch, ScreenData screen)
 {
     return(new Vector3(
                2 * (touch.pageX - (screen.width / 2)) / screen.width,
                0,
                -5 * (touch.pageY - screen.height) / screen.height));
 }
Beispiel #2
0
        public virtual void TouchInput(ControlData controlData)
        {
            string touchType = controlData.type;

            TouchData[] touches = controlData.touches;
            ScreenData  screen  = controlData.screen;

            // touchType will be touchstart, touchend, touchcancel, or touchmove
            switch (touchType)
            {
            case "touchstart":
                break;

            case "touchmove":
                break;

            case "touchend":
                break;

            case "touchcancel":
                break;
            }
            // update the lastTouches
            lastTouches = touches;
        }
Beispiel #3
0
        // activate reticles at all the touchpoints
        private void TouchStart(ControlData controlData)
        {
            TouchData[] touches = controlData.touches;
            ScreenData  screen  = controlData.screen;

            // deactivate the reticles
            foreach (GameObject retic in reticles)
            {
                retic.SetActive(false);
            }

            // If there's an item indicated, move the indicated to selected status
            if (indicated != null)
            {
                selected = indicated;
                Debug.Log("selected indicated: " + indicated.gameObject.name);
                if (hinge)
                {
                    hinge.transform.position = hit.point;
                    hinge.connectedBody      = selected.gameObject.GetComponent <Rigidbody>();
                }
            }

            foreach (TouchData touch in touches)
            {
                int touchIndex = Int32.Parse(touch.identifier);
                if (touchIndex < reticles.Length)
                {
                    // Activate the reticle
                    reticles[touchIndex].SetActive(true);

                    // Move the reticle to the indicated relative touch location
                    reticles[touchIndex].transform.localPosition = TouchToScreen(touch, screen);
                }
            }
        }