- Home /
Touch Control Android Java
Hello I having a Problem With my android Game :
I want to make a fire button and it was with my script but wen i am walk or Look (mobile touch controls asset-pack) then i can't press the button. can you help me?
I'm programing with java
script:
#pragma strict
var Target : Transform;
var slider : float;
var buttonTexture : Texture;
function OnGUI () {
if (GUI.Button(Rect(650,220,100,100),buttonTexture)){
Target.SendMessage("PlayerAttack");
Debug.Log("HitGUIButtomGotaHit");
}
}
What's the problem? The script you've posted looks fine. $$anonymous$$aybe the problem is somewhere else? $$anonymous$$ore detail would be helpful.
If you're looking for general advice about designing a mobile UI, you might look up some tutorials or try the forums.
I don't now wher the problem is and i don't have any errors but it dose not work
I tried it with a raycast to and aded a game object with meshcollider befor my camera but that works also jus with the first finger
script
#pragma strict var ray : Ray; var hit : RaycastHit; var Target : Transform; function Update () { if(Input.Get$$anonymous$$ouseButtonDown(0)){ ray = Camera.main.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(ray,hit)){ if(hit.transform.name == "Fire_Button") Target.Send$$anonymous$$essage("PlayerAttack"); Debug.Log("HitButtomGotaHit"); } } }
Your answer
Follow this Question
Related Questions
Unity buttons touchscreen woes 0 Answers
[C#] Xbox D'Pad to cycle through GUI.Buttons? 2 Answers
AndoidTouchControllJavaRaycast 0 Answers