- Home /
TouchInput doesn't not exist in current content
Hi! I wrote basic mobile code here: using UnityEngine; using System.Collections;
public class TouchManager : MonoBehaviour {
public static bool guiTouch = false;
public void TouchInput(GUITexture texture)
{
if (texture.HitTest(Input.GetTouch(0).position))
{
switch (Input.GetTouch(0).phase)
{
case TouchPhase.Began:
SendMessage ("OnFirstTouchBegan");
guiTouch = true;
break;
case TouchPhase.Stationary:
SendMessage ("OnFirstTouchStayed");
guiTouch = true;
break;
case TouchPhase.Moved:
SendMessage ("OnFirstTouchMoved");
guiTouch = true;
break;
case TouchPhase.Ended:
SendMessage ("OnFirstTouchEnded");
guiTouch = false;
break;
}
}
if (texture.HitTest(Input.GetTouch(1).position))
{
switch (Input.GetTouch(1).phase)
{
case TouchPhase.Began:
SendMessage ("OnSecondTouchBegan");
break;
case TouchPhase.Stationary:
SendMessage ("OnSecondTouchStayed");
break;
case TouchPhase.Moved:
SendMessage ("OnSecondTouchMoved");
break;
case TouchPhase.Ended:
SendMessage ("OnSecondTouchEnded");
break;
}
}
}
}
and this code using UnityEngine; using System.Collections;
public class ButtonMovement : MonoBehaviour {
public enum type{LeftButton, RightButtonm, JumpButon};
public type buttonType;
public GameObject playerObject = null;
public GUITexture buttonTexture = null;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
TouchInput (buttonTexture);
}
}
I second code to 3 buttons in unity... But why i'm having error wih TouchInput in second code it says: "Assets/Scripts/ButtonMovement.cs(18,17): error CS0103: The name `TouchInput' does not exist in the current context" It seems like i can't access to new function in first script but why? I watched tutorial on youtube and for him it works? I hope you understand me :P
Comment