Author Topic: Widget.size  (Read 2818 times)

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Widget.size
« on: October 11, 2013, 01:48:53 PM »
I've just successfully converted my project from Ngui 2.7 to 3.02 and am now working on sprite scaling. Using 2.7, I was scaling a sprite on a billboard attached to a 3D gameobject using transform.scale. As the camera distance changed, the sprite size adjusted (via transform.scale) to retain the same footprint on the screen. All well and good.

Now with 3.0 I've started using Widget height and width. When I scale height and width the sprite does enlarge/shrink as a function of camera distance, down to 1,1. Unfortunately, the sprite is too large at 1,1 when I zoom up close. Of course I can't go lower in height and width, so I figured my sprite was just too large to start with, so I tried a much smaller one and it makes no difference at 1,1 when zoomed close. It is the same size relative to my objects up close as the larger sprite. I must admit I don't understand why.

I finally was able to get the image small enough when zoomed in by scaling the transform like I was doing in 2.7, although I thought that wasn't supposed to work anymore.

The bottom line of all this is I want to scale a sprite as a function of camera distance, thereby retaining the same 'visual footprint' on the screen. The problem is I can't go below 1,1 whereas with 2.7 using transform.scale I could. How would you accomplish this objective with 3.0? I'd prefer not to have to manipulate BOTH widget height/width AND transform.scale at the same time...
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Widget.size
« Reply #1 on: October 12, 2013, 09:15:32 AM »
Why can't you go below (1, 1)? You can scale the sprite freely. Scale only changes if you use MakePixelPerfect.

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Re: Widget.size
« Reply #2 on: October 12, 2013, 05:33:35 PM »
UISprite/Widget width and height are ints aren't they? I'm getting the feeling I'm missing something pretty simple here... :-\
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Widget.size
« Reply #3 on: October 13, 2013, 10:19:59 AM »
Transform.scale is a float. Width/height of a widget are ints. In your case you should scale the transform when scaling the sprite, not the width/height.

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Re: Widget.size
« Reply #4 on: October 13, 2013, 11:33:45 AM »
Yes, that is what I concluded also. I'm afraid I got confused listening to your comments on the video when talking about local scale. Also, transform's scale display in the inspector is 'greyed out' in 3.02, implying that one shouldn't use transform.scale..., or at least that is how I read it.

Thank you for your timely support as always.
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.