I´am porting a Standalone to iOS, at the moment I have problems with moving my code from GUI.Buttons to Touch.
I have a GameObject, with a guiTexture and a Script attached, that calls a function in another Script when the guiTexture is touched. If I touch the guiTexture the iOS App crashes, I´am not calling any fancy stuff in that other script it is just a Debug.Log.
#pragma strict
private var gui : GUITexture;
function Start()
{
gui = GetComponent( GUITexture );
}
function Update()
{
if(Input.touchCount > 0)
{
for(var i : int = 0; i < Input.touchCount; i++)
{
var touch : Touch = Input.GetTouch(i);
if(touch.phase == TouchPhase.Began && guiTexture.HitTest(touch.position))
{
var otherScript : TheOtherScript = gameObject.GetComponent(TheOtherScript);
otherScript.CallMyFunction();
Debug.Log("guiTexture Touched");
}
}
}
}
And here the Function in “TheOtherScript” Script:
function CallMyFunction()
{
Debug.Log("CallMyFunction executed");
}