UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"change the cameras on mouse enter and exit"
public class ChangingCameras : MonoBehaviour{ public Camera mainCamera; public Camera sideCamera; private string textFromObject; void Start(){ mainCamera.enabled = true; sideCamera.enabled = false; } void OnMouseEnter(){ gameObject.GetComponent<TextMesh>().color = Color.red; } void OnMouseExit(){ gameObject.GetComponent<TextMesh>().color = Color.black; } void OnMouseUp(){ textFromObject = gameObject.GetComponent<TextMesh>().text; if(textFromObject == "Start Game" || textFromObject == "Back"){ mainCamera.enabled = !mainCamera.enabled; sideCamera.enabled = !sideCamera.enabled; } else if(textFromObject == "Quit"){ Application.Quit(); } } }