Author Topic: NGUI 3.0.9f7 multiplatform app  (Read 21318 times)

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: NGUI 3.0.8f7 multiplatform app
« Reply #15 on: January 14, 2014, 11:33:41 AM »
You can't tween anchored objects directly, as anchors position the object each frame just as tweening does. What you can do is create a container and apply anchors to that, and then position tweened objects inside.

Like you, I'm having to put in a lot of trial and error to work out how to use NGUI, particularly to combine it with scripting. A lot of what I'd like to do is extremely easy to do with scripting (get display measurements and place accordingly) but combining that with the functionality and flexibility of NGUI is tricky. There could definitely be a lot better educational materials; the existing tutes and examples cover a small set of basics and don't look at many of the real-world uses. We could do with some lengthy walkthroughs looking at real-world examples. At least the support here is very quick and useful.

The choice of going with NGUI 2.7 means losing access to support and features. If that'll work for you from past experience, it's a valid choice. Spending time learning the new system can either be seen as a nuisance as it slows down your current project, or an investment as it'll make future projects faster and better to implement. I see learning NGUI as a bit of both in equal measure at the moment. ;)

I'm also hopeful there'll be some parallels with Unity's DNFUI whenever it appears, and we should get lots of tutorials and training as an official Unity feature. Although 2D training has been limited, so there'll still be a substantial time to learn from DNFUI release to fluent use.

Thx for the reply Shifty Geezer,

It's not that I don't want to learn the new NGUI, it's just that I think it's not possible what I want to do with my panels. The example I posted above is build like this:
Panel
-HeaderObj (Empty GameObject)
--HeaderSprite
--HeaderLabel
--HelpButton
--BackButton
-StartDate (Empty GameObject)
--Background (With UIButton attached) (UISprite)
--StartDateLabel (UILabel)
--DateLabel (changed with picker) (UILabel)
--Dotted line (UISprite)
-EndDate (Empty GameObject)
--Background (With UIButton attached) (UISprite)
--EndDateLabel (UILabel)
--DateLabel (changed with picker) (UILabel)
--Dotted line (UISprite)
-Time (Empty GameObject)
--Background (With UIButton attached) (UISprite)
--TimeLabel (UILabel)
--Time (changed with picker) (UILabel)
-Repeating (Empty GameObject)
--Background (With UIButton attached) (UISprite)
--RepeatLabel (UILabel)
--Repeat (changed with picker)
--dotted line
-Notifications
--Checkbox
--Label
-Save Button
--Background (with UIButton attached) (UISprite)
--SaveLabel (UILabel)

I want this whole panel tweenable and use anchoring so that the sprites look good on other resolutions. All the sprites are build with 9 slicing so sprite stretching shouldn't be a problem. Can you give me some tips on how to achieve this?
 

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: NGUI 3.0.8f7 multiplatform app
« Reply #16 on: January 16, 2014, 04:33:47 AM »
bump

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 3.0.8f7 multiplatform app
« Reply #17 on: January 16, 2014, 11:59:12 PM »
So what's the question exactly? You want to make things pixel perfect, have them be anchored, and have them be tweenable? That's fine. The only thing to know is that you can't put tweens on anchored objects. You need to put them on children of anchored objects instead.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: NGUI 3.0.8f7 multiplatform app
« Reply #18 on: January 17, 2014, 04:00:39 AM »
So what's the question exactly? You want to make things pixel perfect, have them be anchored, and have them be tweenable? That's fine. The only thing to know is that you can't put tweens on anchored objects. You need to put them on children of anchored objects instead.

Hi ArenMook had a nice vacation?

The question is, how to do this with the example panel I gave a few posts back. What I do now is tween out the whole panel of the screen and tween in the new panel. So the old panel is not visible on the screen anymore. I want to know how to do that in the example I posted with all the objects and how they are anchored. It seems to me that if I need to tween all the objects in the panel, it will cost a lot of performance. I don't know if it makes a difference but i'm using HOTween.

EDIT:
Maybe it's nice to make a tutorial for this? I think i'm not the only one having this problem?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 3.0.8f7 multiplatform app
« Reply #19 on: January 17, 2014, 11:09:24 PM »
I've gone ahead and made it possible to tween anchored objects using TweenPosition, so you will be able to move anchored objects. This includes both anchored panels and anchored widgets. Does this make it easier?

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
Re: NGUI 3.0.8f7 multiplatform app
« Reply #20 on: January 18, 2014, 12:33:50 PM »
That is going to make using anchored objects that bit simpler. Thanks!

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: NGUI 3.0.8f7 multiplatform app
« Reply #21 on: January 19, 2014, 11:11:31 AM »
I've gone ahead and made it possible to tween anchored objects using TweenPosition, so you will be able to move anchored objects. This includes both anchored panels and anchored widgets. Does this make it easier?

That's great! Does it also work for children of panels? like:
HeaderObj (Just empty GameObject for grouping items)
-Sprite01 anchored
-Label (anchored)


EDIT:
Anchoring all items to a panel and then tweening the panel doesn't work. The panel tweens to for instance -1000 but the sprites stay on the same place. Anchoring all items to themselves (which doesn't really solve the multiplatform solution) does work.
Also I noticed that I can't anchored panels anymore. Is that something new?
« Last Edit: January 19, 2014, 11:30:14 AM by Tripwire »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 3.0.9f1 multiplatform app
« Reply #22 on: January 20, 2014, 12:44:40 AM »
Quote
Anchoring all items to a panel and then tweening the panel doesn't work.
Why not? I just did a quick test:
1. New scene.
2. Added a sprite.
3. Created a scroll view.
4. Anchored the sprite to the scroll view.
5. Anchored scroll view to top left.
6. Added a TweenPosition to the scroll view.
7. Hit Play, the scroll view tweens, sprite stays anchored.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: NGUI 3.0.9f1 multiplatform app
« Reply #23 on: January 20, 2014, 03:13:08 AM »
Why not? I just did a quick test:
1. New scene.
2. Added a sprite.
3. Created a scroll view.
4. Anchored the sprite to the scroll view.
5. Anchored scroll view to top left.
6. Added a TweenPosition to the scroll view.
7. Hit Play, the scroll view tweens, sprite stays anchored.

So it should work, but it seems a bit buggy.
1. Added a new panel to the scene
2. Added a sprite
3. Added a label as a child of the sprite
4. Attached a collider and a UIButton to the sprite
5. Anchored the sprite to the panel (unified)
6. Created a script and added it to OnClick:
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class TestCaseManager : MonoBehaviour {
  5.  
  6.         public GameObject panel;
  7.  
  8.         public void TweenTest()
  9.         {
  10.                 TweenPosition.Begin(panel, 1f, new Vector3(-640,0,0));
  11.         }
  12. }
  13.  

First time running this it worked. I Added a background sprite to the panel and anchored it to the panel. When I started the scene, pressed the button the panel tweened a few pixels to the left. Result is that the panel is at -640, but the anchored objects are at 640 so they seem to reset themselves to the correct position.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: NGUI 3.0.9f1 multiplatform app
« Reply #24 on: January 21, 2014, 07:08:37 AM »
I just thought of something which might work here. Would it be possible to disable the anchoring just before the tweening happends? Or does that screw up the sprites too much?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 3.0.9f1 multiplatform app
« Reply #25 on: January 22, 2014, 05:29:33 AM »
Sure, go for it. Anchors simply update the dimensions.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: NGUI 3.0.9f1 multiplatform app
« Reply #26 on: January 22, 2014, 03:37:07 PM »
Works :) but only for screens that are on a panel which is at position 0,0,0 . How can I anchor screens to a panel which is for example on x: 645?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 3.0.9f4 multiplatform app
« Reply #27 on: January 23, 2014, 06:38:45 AM »
I don't quite understand what you mean. What does panel's position have to do with it? Panel's rect has little to do with position. Clip Rect is what defines the panel's rectangle. Transform position and clip rect's position are generally opposites so they tend to cancel each other out.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: NGUI 3.0.9f4 multiplatform app
« Reply #28 on: January 27, 2014, 04:23:29 AM »
I don't quite understand what you mean. What does panel's position have to do with it? Panel's rect has little to do with position. Clip Rect is what defines the panel's rectangle. Transform position and clip rect's position are generally opposites so they tend to cancel each other out.

Hi ArenMook,

Sorry for the late reply was a bit busy. Since i'm anchoring everything to the panel, and since i'm tweening the whole panel (with all the child objects) the panel's position is quite a huge deal. So what I meant is, that when I anchor an object which is a child of a panel, and that panel's position is for instance 640. The anchoring still goes to X = 0 position of the screen and not of the panel i'm anchoring too. So the result of anchoring an object which is offscreen (x = 640):




This results in the 2nd screen is not correct positioned when tweened in.

Also i've just updated to the latest version of NGUI, i've tried setting the panel to Alpha clip, and now I can use TweenPosition to tween the panel out with all the child objects anchored to the panel so that's nice :).

EDIT:
I also noticed that when I set an anchor on the panel it sets the alpha clip size to:
757.3334 x 1136 instead of 640x1136. on iPhone 4/s whereas on iPhone 5 (which is the main target) the alpha clip is set to 640x1136 which is correct.
« Last Edit: January 27, 2014, 09:15:43 AM by Tripwire »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 3.0.9f4 multiplatform app
« Reply #29 on: January 27, 2014, 12:30:13 PM »
I recommend you fix that warning you see on your UIPanel about two panels sharing the same depth value.

It's best to tween to a point that you know is off-screen on both devices. Scroll views (clipped panels) move by adjusting their position and adjusting the clipping region's offset by the inverse of the position adjustment. If you want more predictable results, make the panel be anchored to a widget, and tween the widget.