im totally a newbie for unity.
i have 2 function.
1)detect the object that i selected by mouse.
2)change the texture of the object which i selected by mouse.
when i play, two function work perfectly, but when i combine both function together the object from mouse detect function–>***Upadate()***cannot be call by OnGUI() function. how to call gameobject? please help. thanks.
coding something like
function OnGUI() {
if (GUI.RepeatButton(Rect(10,430,50,50),btnTexture1))
{ Debug.Log("Texture changed");
Update();
object.renderer.material=texture1;
lamp1.renderer.material=texture1;
}
}
function Update(){
if (Input.GetMouseButtonDown(0)){
var hit: RaycastHit;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, hit)){
point = hit.point;
object = hit.transform.gameObject;
}
}
else
if (Input.GetMouseButtonUp(0)){
duration = Time.time - startTime;
}
}