x


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;

}

more ▼

asked Sep 02 '11 at 02:43 AM

panorama gravatar image

panorama
1 9 12 12

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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);
    }
}
more ▼

answered Sep 02 '11 at 05:59 AM

mohanrao164 gravatar image

mohanrao164
146 3 3 5

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3747
x3694
x3340
x2000
x1967

asked: Sep 02 '11 at 02:43 AM

Seen: 573 times

Last Updated: Sep 02 '11 at 05:59 AM