button - How to translate OnMouse events to Touch phases for Android? -
I am stuck for a very simple solution, translated into Unity 3D in Android with my script . I have a game object "cube" and a js script attached to rotation.
Also I'm getting a script "ClickButton.js" associated with a GUI.Testxture. Everything o.k. In the Unity Player, but I want to translate to using this script by touching on Android devices. The problem is that I can not do this, although I have read the Unity documentation.
Here is the code snippet:
// This script is attached to the GUI. Texture Texture2D; Var Hover Piece: Texture 2D; Function Update () {for (var i = 0; i & lt; Input.touchCount; ++ i) {if (Input.GetTouch (i) .phase == TouchPhase.Began) var = input. GetTouch (i); Rotate == doRotate (); }}} Function OnMouseEnter () {guiTexture.texture = hoverTextxture; } Function OnMouseExit () {guiTexture.texture = normalTextxture; } Function onMouseDown () {varRescriptToTate: Game Object [] = GameObject.Find Game ObjectWithTag ("Marker"); (Var doRotation: GameObject in runScriptRotate) {var scriptRT: doRotate = doRotation.GetComponent (doRotate); If the script (scriptRT) {// "Object" on the script "Object" cube "doRotate.doRotation ();}}}
on a script called" DoRotate " Is enough to edit, so that it can work on Android by touching it? Thank you in advance!
Why do not you just copy the contents of OnMouseDown ()
? Actually there is a touch of mouse down on Android devices, right?
if (Input.touchcount> 0) {if (Input.GetTouch (0) .phase == TouchPhase.Began) {var runScriptRotate: GameObject [] = GameObject.FindGameObjectsWithTag ("Marker"); (Var doRotation: GameObject in runScriptRotate) {var scriptRT: doRotate = doRotation.GetComponent (doRotate); if (scriptRT) {// "Object" on the script "Object" cube "doRotate.doRotation" on a script called "DoRotate" (); }}}}
Comments
Post a Comment