- Home /
I have problem when i want to using button instead keyboard in iOS
Hi every one I have to try this code of keyboard I need to using GUI Button instead of keyboard See my code ,I already try to use but doesn't work any more Pls help me. Cheers!
private var axisH: float = 0; private var axisV: float = 0;
function InputGetAxis(axis: String): float {
var v = Input.GetAxis(axis);
if (Mathf.Abs(v) > 0.005) return v;
if (axis=="Horizontal") return axisH;
if (axis=="Vertical") return axisV;
}
function OnGUI(){
axisV = axisH = 0;
if (GUI.RepeatButton(Rect(50, 10, 40, 40), "W")) axisV = 1;
if (GUI.RepeatButton(Rect(50, 90, 40, 40), "S")) axisV = -1;
if (GUI.RepeatButton(Rect(10, 50, 40, 40), "A")) axisH = -1;
if (GUI.RepeatButton(Rect(90, 50, 40, 40), "D")) axisH = 1;
}
Comment
Answer by mohanrao164 · Sep 02, 2011 at 05:59 AM
function OnGUI()
{
if(GUI.RepeatButton(Rect(50,10,40,40),"W"))
{
transform.Translate(Vector3.forward*Time.deltaTime*100);
}
if(GUI.RepeatButton(Rect(50,90,40,40),"S"))
{
transform.Translate(Vector3.back*Time.deltaTime*100);
}
if(GUI.RepeatButton(Rect(10,50,40,40),"A"))
{
transform.Translate(Vector3.left*Time.deltaTime*100);
}
if(GUI.RepeatButton(Rect(90,50,40,40),"D"))
{
transform.Translate(Vector3.right*Time.deltaTime*100);
}
}
Your answer
Follow this Question
Related Questions
How can i find to Cool Main menu for iOS 1 Answer
I want to have FPS iOS tutorials. 0 Answers
swing to hit a target 1 Answer
iPhone GUI buttons problem 1 Answer
Error linker IOS / Unity - XcODE 2 Answers