Author Topic: UISlider.fullSize gone :(  (Read 17909 times)

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
UISlider.fullSize gone :(
« on: December 01, 2013, 11:10:21 PM »
Hey there!

With the latest version of NGUI it seems that `fullSize` has been removed. What is the alternative since I still require this in my scripts?

Cheers

kurozael

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #1 on: December 02, 2013, 05:00:12 AM »
Hi mate,

ArenMook has a habit of changing variable names and not letting anyone know about it. The var you're looking for is now UISlider.startingForegroundSize.

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #2 on: December 02, 2013, 05:43:29 AM »
Hi kurozael

I am unable to find a field/property called "startingForegroundSize" inside the UISlider class (and the compiler doesn't like it either).

Any ideas?

Cheers

kurozael

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #3 on: December 02, 2013, 06:49:43 AM »
startingForegroundSize is actually a member of UIProgressBar which UISlider now inherits from. I did have a problem where after upgrading MonoDevelop didn't like this either, but after opening UISlider and UIProgressBar in MonoDevelop it seemed to accept it. Very odd, though.

Good luck!

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #4 on: December 02, 2013, 07:37:54 AM »
Guna need the luck :P

I have just imported the latest NGUI into a blank project and can confirm that neither UIProgressBar nor UISlider expose "startingForegroundSize". I also searched all of the NGUI source files for that name and it didn't pop up in the results.

Are you using the latest version of NGUI?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #5 on: December 02, 2013, 08:48:23 AM »
The latest version doesn't need this anymore, so the property has been removed. You can resize your slider freely and it will "just work". Use the widget's width and height if you need to get/set it.

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #6 on: December 02, 2013, 06:27:36 PM »
Unfortunately it doesn't seem to "just work" with the setup which I have. I have the following setup which works perfectly with the previous version of NGUI for all screen resolutions:

  1. Level Progress [ UISlider(Foreground=Meter Full) ]
  2. |--- Background [ UISprite, UIStretch(Horizontal, Container=None) ]
  3.          |--- Frame [ UISprite, UIStretch(Horizontal, Container=Background) ]
  4. |--- Meter Full [ UISprite, UIAnchor(Container=Background) ]
  5. |--- Label [ UILabel, UIAnchor(Container=Background) ]
  6.  

With the above the background and label elements work fine, but the foreground does not properly fill the slider area. So previously I stuck the following inside "Update" which resolved the problem:

  1. Vector2 fullSize = progressLevelProgress.fullSize;
  2. if (fullSize.x != progressBackground.width) {
  3.     var foregroundSprite = progressLevelProgress.foreground.GetComponent<UISprite>();
  4.     fullSize.x = progressBackground.localSize.x - 25;
  5.     fullSize.y = foregroundSprite.localSize.y;
  6.  
  7.     progressLevelProgress.fullSize = fullSize;
  8. }
  9.  

But naturally this no longer works :'(

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #7 on: December 03, 2013, 10:18:09 AM »
I'm not quite clear why the container for the background sprite is set to none. This makes it stretch to screen's dimensions, which seems wrong to me.

There is a new layout system coming in the next release (it's available to Pro users already) which deprecates anchors and stretch scripts altogether. It's a hell of a lot more powerful and fairly intuitive. I'll make a video about it in a bit. I'm guessing what you are trying to do is going to be much easier then.

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #8 on: December 03, 2013, 10:22:56 AM »
You are correct, the background spans the width of the screen which is the intended behaviour. I would love to show you some screenshots but I can't show them in public because its part of a client project.

For the time being can I just revert to the previous version of the slider control whilst still using the remainder of the latest NGUI update?

Do you have an eta for the next release? will it be before Xmas?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #9 on: December 03, 2013, 10:24:45 AM »
Pro users already have it. Seeing as I haven't changed anything in regards to backwards compatibility, I'll likely ship it by this weekend.

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #10 on: December 03, 2013, 10:56:36 AM »
Fantastic! I will look forward to this.

Will I need to replace all instances of UIStretch with the new layout mechanism? or can they live happily together?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #11 on: December 03, 2013, 06:06:20 PM »
The legacy way of doing things using anchors and stretch scripts will still be there, however the new system is completely different (it's a part of each widget). You can upgrade to the new system at your own pace.

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #12 on: December 07, 2013, 08:10:09 AM »
Wow, well done on the new layout system! it is a vast improvement and resolves this issue!

When selecting an anchor for the first time it feels like it would be handy if it automatically initialised the game object to the first parent that is a widget. Would be a huge time saver!

Thanks :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #13 on: December 07, 2013, 03:13:10 PM »
Good idea.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider.fullSize gone :(
« Reply #14 on: December 07, 2013, 03:17:46 PM »
Update: I've done that. Next update will have this functionality. You can also make the change locally by opening up UIRectEditor.DrawFinalProperties and adding the following after line 122, inside the "if (mAnchorType == AnchorType.None && type != AnchorType.None)" section:
  1.                                 if (mTarget0 == null && mTarget1 == null && mTarget2 == null && mTarget3 == null)
  2.                                 {
  3.                                         UIRect rect = target as UIRect;
  4.                                         UIRect parent = NGUITools.FindInParents<UIRect>(rect.cachedTransform.parent);
  5.                                        
  6.                                         if (parent != null)
  7.                                         {
  8.                                                 mTarget0 = parent.cachedTransform;
  9.                                                 mTarget1 = parent.cachedTransform;
  10.                                                 mTarget2 = parent.cachedTransform;
  11.                                                 mTarget3 = parent.cachedTransform;
  12.                                         }
  13.                                 }