// Callback when the examined object changes private void OnExaminableChanged(GameObject examinable) { if (examinable != null) { // If it's over something, get all the assosciated data and update the UI. IExaminable[] examinables = examinable.GetComponents <IExaminable>(); UpdateExamine(examinables); } else { // If it's over nothing, get rid of the Examine UI. examineUi.ClearData(false); } }
/// This function retrieves the current object from the selector. Because /// this object is only available once the rendering has been completed, it /// must be called inside a coroutine. private IEnumerator UpdateUserInterface() { // Wait until the off-screen rendering occurs in OnPostRender(). yield return(new WaitForEndOfFrame()); // Retrieve the object the mouse is over. GameObject hitObject = selector.GetCurrentExaminable(); if (hitObject != null) { // If it's over something, get all the assosciated data and update the UI. IExaminable[] examinables = hitObject.GetComponents <IExaminable>(); UpdateExamine(examinables); } else { // If it's over nothing, get rid of the Examine UI. examineUi.ClearData(); } }