Hello forum. I’m stuck to a rather simple solution, with my script transcoded to Android. I’m having a gameObject “Cube”, and a script attached for rotation.
Also I’ m having a script “ClickButton” attached to a GUI.Texture. Everything works o.k. in Player, but I want to transcode this script to be used by touches in Android. Problem is I can’t do it, although I have read the Unity documentation.
Here is the code snippet:
//This script is attached on a GUI.Texture acting as a button
var normalTexture : Texture2D;
var hoverTexture : Texture2D;
function Update(){
for (var i = 0; i < Input.touchCount; ++i) {
if (Input.GetTouch(i).phase == TouchPhase.Began)
var rotate = Input.GetTouch(i);
rotate == doRotate();
}
}
function OnMouseEnter(){
guiTexture.texture = hoverTexture;
}
function OnMouseExit(){
guiTexture.texture = normalTexture;
}
function OnMouseDown(){
var runScriptRotate : GameObject[] = GameObject.FindGameObjectsWithTag("Marker");
for(var doRotation : GameObject in runScriptRotate)
{
var scriptRT : doRotate = doRotation.GetComponent(doRotate);
if(scriptRT)
{
// access the function "doRotation" on a script named "doRotate" on gameObject "Cube"
doRotate.doRotation();
}
}
}
Can someone, be kind enough to post an edit to my code script, to make it work on Android by touching? Thank you all in advance!