Reputation: 71
I'm trying to create a zoom in button, in my unity scene I saw this video, but the 'zoom cam' isn't working. https://www.youtube.com/watch?v=ACR-W9QZQwE&t=127s&ab_channel=DesignandDeploy Does anyone know how to do this?
Here is my code and 'lupa' is the button i want to click to do the zoom in
Upvotes: 1
Views: 271
Reputation: 1
Is there any other camera in the scene beside the 'zoom cam
', maybe the 'Main Camera
'?
If so, try to disable the other camera by adding the following line
GameObject.Find("Main Camera").GetComponent<Camera>().enabled = false;
in the script "ZoomIn" at line 17
Upvotes: 0
Reputation: 111
My guess is that OnMouseDown() isn't getting called. That function has a specific use case, as you can read in the docs. The script might not be attached to the correct collider, etc. If you want to trigger it from a button, you can - add it to the list of functions triggered by the button's OnClick() through the inspector. Tons of YouTube tutorials for that sort of thing.
Upvotes: 1