Why the screen is sliding using "Zoom2D" ?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
misaki_e
Posts: 20
Joined: Fri Apr 16, 2021 1:57 am

Why the screen is sliding using "Zoom2D" ?

Post by misaki_e »

Hello,

Sorry to bother you again, but I couldn’t find the same question in the log, so please ask about Zoom2D().

I tried to use Zoom2D(), but the screen slided and went out.
I uploaded the capture as limited access on Youtube, so please watch it as a reference.


I tried the three subject words : speaker / listener / original.
Then, it was not sliding when I use speaker or listener, but zooming was not working.
My main camera setting is here:
MainCamera.png
MainCamera.png (155.03 KiB) Viewed 656 times
Could you tell me what I should do?
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: Why the screen is sliding using "Zoom2D" ?

Post by Tony Li »

Hi,

Check the position of the Guide GameObject. Zoom2D will move the camera's X and Y coordinates to match Guide's X and Y coordinates.

Also investigate the 3 NullReferenceException errors in the Console window. They may be related.,
misaki_e
Posts: 20
Joined: Fri Apr 16, 2021 1:57 am

Re: Why the screen is sliding using "Zoom2D" ?

Post by misaki_e »

Thank you for your confirming, Tony.

I'm sorry the NullReferenceException errors confused you, but it seems completely not related.
Here is the video that I tried when there is no error.



I also tried with the example project.



Zoom2D() does not seems to be working... or, Zoom2D() can't zoom to Spine object?
I would appreciate it if you could give me some advice.
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: Why the screen is sliding using "Zoom2D" ?

Post by Tony Li »

Hi,

Zoom2D() moves the camera in the scene. The camera draws what is in the scene.

However, you're using a dialogue UI on a screen space canvas, which is the default canvas type. Unity draws screen space canvases on top of the scene, after the camera has drawn what is in the scene.

If you want to zoom to different characters, make them Spine GameObjects in the scene, not part of your dialogue UI canvas.
misaki_e
Posts: 20
Joined: Fri Apr 16, 2021 1:57 am

Re: Why the screen is sliding using "Zoom2D" ?

Post by misaki_e »

Umm, I think I didn’t put the Spine character on Canvas, because I confirmed the game screen was changed when I changed the Main Camera’s size like the following video:


Is there anything else I should check?
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: Why the screen is sliding using "Zoom2D" ?

Post by Tony Li »

The example scene uses characters on the Canvas, so Zoom2D will not affect them.

Your character is in world space in the scene, so that's good. We just need to understand why the camera is moving away from the character.

Does the scene have more than one GameObject named "Guide"?

What is the position of "Guide"? Inspect the GameObject, and please let me know the Transform > Position > X, Y values.

Keep an Inspector view on the camera when it starts to move like this:

zoom2Dissue.png
zoom2Dissue.png (192.08 KiB) Viewed 641 times

Does the camera's Transform > Position move to the same X, Y values as Guide?
misaki_e
Posts: 20
Joined: Fri Apr 16, 2021 1:57 am

Re: Why the screen is sliding using "Zoom2D" ?

Post by misaki_e »

Thank you for your answer, and I finally understand the cause!

Actually, the position of “Guide” was at X 333, Y 333, and the child object(Spine skeleton) was at X-333, Y-333, so the Main Camera moved away.
I’m sorry I didn’t notice it when you gave me the first advice.

It is working now:


Thank you so much!
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: Why the screen is sliding using "Zoom2D" ?

Post by Tony Li »

Great! Looks good!
Post Reply