- Home /
OnGui Texture raycast problem
Hi, i dont know if this is the right place to post my doubt! sorry if its not, and sorry for my english (spanish is my first language)
Im very new to unity, i want to place an image on the center of the screen only if a gameobject with the tag that i want is in the center of the screen. hope you understand... here is what i have now!
public float X; public float Y; public Texture mano; bool puedeagarrarorchilito;
// Use this for initialization void Start () { puedeagarrarorchilito = false; }
// Update is called once per frame void Update () { RaycastHit hit;
if (Physics.Raycast (transform.position, transform.forward, out hit, 20f)) { if (hit.collider.gameObject.tag == "Agarrables") { puedeagarrarorchilito = true; Debug.Log ("tocandofruta"); } else { puedeagarrarorchilito = false; } }
} void OnGUI () { float Xcoord = X Screen.width; float Ycoord = Y Screen.height; if (puedeagarrarorchilito) {
GUI.DrawTexture (new Rect (75, 99, Xcoord, Ycoord), mano); } }
i get the debuglog right! but no image on screen any ideas? thanks
Your answer
Follow this Question
Related Questions
Change crosshair text when hitting a trigger 0 Answers
How to render part of an object 2 Answers
RaycastHit textureCoords return Vector2.zero on iOS only despite proper setup 2 Answers
Getting texture coordinates from raycast2D 0 Answers
Raycast on sprite in 3D space, how to find texture coordinates 0 Answers