Hello Guest

Author Topic: Zooming in while maintaining UI position?  (Read 10169 times)

kag359six

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Zooming in while maintaining UI position?
« 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #1 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

kag359six

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #2 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."

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #3 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

kag359six

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #4 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.

kag359six

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #5 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #6 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.

profanicus

  • 2D Toolkit
  • Full Member
  • *
  • Posts: 167
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #7 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.

kag359six

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #8 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.

profanicus

  • 2D Toolkit
  • Full Member
  • *
  • Posts: 167
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #9 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.

kag359six

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #10 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #11 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.

kag359six

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #12 on: July 13, 2013, 02:34:14 am »
Were can I find sample 6?

midasmax

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #13 on: July 13, 2013, 02:44:23 am »
Sample 6 is probably in TK2DROOT/tk2d_demo

kag359six

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Zooming in while maintaining UI position?
« Reply #14 on: July 13, 2013, 03:23:02 am »
Oh my apologies I was looking for it on the forum  :P duh.