- Home /
how to access a screen(separate obj in my app).
HI All, I am about to develop a calculator. for that my artist given me a calculator object. All buttons are separate objs and screen also.should I use GUI text for it., If so let me know the process of displaying a value when we hit any button. Thanks firstly to the person who is gonna send me Ans.
Comment
Answer by strachpr01 · May 18, 2013 at 09:46 PM
i think you would be better with a 3D text so you can place it in the position of the screen. For the buttons i would suggest using Physics.Raycast so you can get what object the user hits ad use that in your programming. More info on this can be found here :- http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html for example
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100))
{
if(hit.gameObject.name == "button 1")
{
Debug.Log("Hit button 1");
}
}