2D Toolkit Forum

2D Toolkit => Support => Topic started by: kag359six on July 03, 2013, 01:31:45 am

Title: Zooming in while maintaining UI position?
Post by: kag359six on July 03, 2013, 01:31:45 am
I'm having trouble with the GUI system in Toolkit2D. Say I have a text mesh for score keeping in game, how can I get stuff like buttons, menu's etc. to keep the same screen position when the camera zooms in and out? Is it possible?
Title: Re: Zooming in while maintaining UI position?
Post by: unikronsoftware on July 03, 2013, 10:01:56 am
Use the anchor to keep things anchored to a specific screen position. If you're using a normal camera, and not a tk2dCamera, you can use the new anchor system from tk2d 2.1 - a preview is available from here in the private support forum: http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1987.0.html
Title: Re: Zooming in while maintaining UI position?
Post by: kag359six on July 03, 2013, 04:43:36 pm
When I go to the link it tells me "The topic or board you are looking for appears to be either missing or off limits to you."
Title: Re: Zooming in while maintaining UI position?
Post by: unikronsoftware on July 03, 2013, 04:58:23 pm
Its in the private support forum. You'll need to register your 2D Toolkit as described here to get access: http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,34.0.html
Title: Re: Zooming in while maintaining UI position?
Post by: kag359six on July 10, 2013, 07:10:40 pm
When I import the anchor package, it seems that the two editor scripts crash Unity just like it did for profanicus. For me, however, it crashes when I import either the tk2dCameraEditor.cs OR the tk2dCameraAnchorEditor.cs. I have no clue what the issue is.
Title: Re: Zooming in while maintaining UI position?
Post by: kag359six on July 10, 2013, 07:18:51 pm
In fact, Unity is practically unusable now. Every time I try searching for the files to delete it Unity crashes. My tabs are all out of place as well. What in the world happened?
Title: Re: Zooming in while maintaining UI position?
Post by: unikronsoftware on July 10, 2013, 07:47:21 pm
Unity does occasionally go mad sometimes when importing new packages. Try this - shut down unity, delete the offending files in explorer / finder, restart Unity, shut down (important) and restart it again - import the package again and let it import the missing files.
Title: Re: Zooming in while maintaining UI position?
Post by: profanicus on July 11, 2013, 12:04:25 am
When I import the anchor package, it seems that the two editor scripts crash Unity just like it did for profanicus. For me, however, it crashes when I import either the tk2dCameraEditor.cs OR the tk2dCameraAnchorEditor.cs. I have no clue what the issue is.

Yep this happened for me with the anchor package, and again with the 2.1 beta as well. After it crashes, manually deleting the camera editor files in explorer and re-importing worked for me.
Title: Re: Zooming in while maintaining UI position?
Post by: kag359six on July 11, 2013, 02:02:08 am
I THINK it works... but the tk2dCameraAnchor script bugs out like crazy on a normal orthographic camera. It automatically places the positioning of an item 80 units behind its original position before adding the script, and it also won't let me increase the Z position value of the sprite text. It only decreases no matter the direction I scroll.
Title: Re: Zooming in while maintaining UI position?
Post by: profanicus on July 11, 2013, 02:14:17 am
Make sure the anchor is the child of the ui camera. Ideally make the anchor through the Create menu rather than adding component, as tk2d then forces you to stick it on a camera.
Title: Re: Zooming in while maintaining UI position?
Post by: kag359six on July 11, 2013, 07:11:55 pm
Why does the text mesh (which I'm assuming is suppose to be a child of the anchor) resize when I zoom in with the camera by changing the orthographic size?
Title: Re: Zooming in while maintaining UI position?
Post by: unikronsoftware on July 11, 2013, 10:55:32 pm
Changing the orthographic size changes what the camera sees. The text mesh remains the same size, the camera sees more = Looks like the text mesh is changing size. If you want to zoom in, set up a second UI camera separately so you don't mess about with the UI. Check sample 6 to see how you can use 2 cameras.
Title: Re: Zooming in while maintaining UI position?
Post by: kag359six on July 13, 2013, 02:34:14 am
Were can I find sample 6?
Title: Re: Zooming in while maintaining UI position?
Post by: midasmax on July 13, 2013, 02:44:23 am
Sample 6 is probably in TK2DROOT/tk2d_demo
Title: Re: Zooming in while maintaining UI position?
Post by: kag359six on July 13, 2013, 03:23:02 am
Oh my apologies I was looking for it on the forum  :P duh.