Unity Community |

@ArenMook, will you consider to add this fix ?UIAtlas.cs
Code:
public class Sprite { public float borderScale = 1;
UISlicedSprite.cs
Code:
//Vector2 tl = new Vector2(borderLeft / 2 / sz.x, borderTop / 2 / sz.y); //Vector2 br = new Vector2(borderRight / 2 / sz.x, borderBottom / 2 / sz.y);
And then, in Altas Inspector, set borderScale = 0.5 in UI-hd and borderScale = 1 in UI-sd.
It solved my problem, but property name ( borderScale ) is not good at all.
@ArenMook, will you consider to add this fix ?UIAtlas.cs
Code:
public class Sprite { public float borderScale = 1;
UISlicedSprite.cs
Code:
//Vector2 tl = new Vector2(borderLeft / 2 / sz.x, borderTop / 2 / sz.y); //Vector2 br = new Vector2(borderRight / 2 / sz.x, borderBottom / 2 / sz.y);
And then, in Altas Inspector, set borderScale = 0.5 in UI-hd and borderScale = 1 in UI-sd.
It solved my problem, but property name ( borderScale ) is not good at all.
Ideally the border scale parameter would need to be specified on the atlas rather than on the sprite. It's also not the best solution... I'm thinking of having some sort of a parameter on the UIRoot that would address this instead, but I haven't quite figured out the best way just yet. I'm letting it sit at the back of my mind while I'm working on other things.
NGUI Resources: Documentation | Forum | Release Notes
Want to get notified when NGUI gets updated? Subscribe to this thread.
Can anyone advise me on how to stop sprites from automatically scaling when I press play?
I am trying to use NGUI for simple in-game sprites(as well as UI) rather than integrate a second additional 2d solution. I want the sprites to approximate real-world sizes rather than pixel sizes, so I'd like the size of the sprite in the game view to be consistent with how I set it up in the scene view.
I tried adding my sprite underneath a Panel (no UI Root or Camera) and setting all transform scales manually, but I when I press play it jumps up to "pixel perfect" size. I want it to stay the size I make it in the scene view.
Additionally, I read that moving the sprite widget itself causes an expensive mesh rebuild; is this also the case if I give the widget a parent gameobject and move that instead?
cheers.
Moving the parent is not as expensive, but still much more expensive than moving a panel. Sprites shouldn't resize to pixel-perfect coordinates on Play, and as far as I can tell they don't. I use a stretched UISprite for a background in more than one example (for example, UISprite - Backdrop in Example 2). Hitting Play doesn't resize it. I don't think they ever did... what version of NGUI do you have?
NGUI Resources: Documentation | Forum | Release Notes
Want to get notified when NGUI gets updated? Subscribe to this thread.
It is version 1.83.
I guess I must be doing it wrong - the Sprite was set to 128 scale in XY when NGUI created it, and if I change that it gets set back to 128 when I press play. Changing the parent gameobject works though, so I think I am not supposed to be scaling the sprite Widget directly?
I am looking to have hundreds of sprites (bullets, simple animated units) moving individually so I think a panel for each one is not ideal. At the moment my prototype is just using mesh quads and lots of drawcalls.
The only reason it would snap back to its original size would be if you had a UISpriteAnimation script attached. Is that the case?
NGUI Resources: Documentation | Forum | Release Notes
Want to get notified when NGUI gets updated? Subscribe to this thread.
Ah yes I do![]()
Is there anything I can do to that animation script to stop that behaviour?
Or do you think it is not worth me trying to use NGUI for this kind of thing performance-wise, since I am moving quite a lot of sprites around? All I am really trying to do is leverage the existing atlas and sprite tools so I don't have to do it all manually myself by mapping quads.
ex2D is only $15 at the moment, I could just get that for the in-game stuff; I just wanted to avoid another atlas/sprite system if possible and thought I'd try NGUI first since I already use it for UI.
Do you need the sprite to be animated like that? If you want something simple like changing a color or growing in size, tweens are a better way to go here. If you need something more complex, then you can use an image button. UISpriteAnimation is mainly for playing out animations of many sprites (for example sparkle effects over a button). You can still scale it by scaling the parent. Anything more complicated, such as skeletal animation for a character, and I suggest creating it in a modelling package.
NGUI Resources: Documentation | Forum | Release Notes
Want to get notified when NGUI gets updated? Subscribe to this thread.
Hello, I have just purchased this UI Tool and it is very impressive.
I have been going through some of the basic documentation, but I have not found anything dealing with including building NGUI's entities into an existing project, using existing camera's, etc..
Is there any specific documentation on this?
Thanks
------------------------------
Edit: For anyone else, this is explained in some previous posts ( a little outdated, given the Widget Tools though ) :
http://forum.unity3d.com/threads/114...l=1#post767654
Last edited by Rook3D; 03-20-2012 at 10:01 PM.
How would I go about detecting when UIDragObject (or Camera) is released from dragging?
It's pretty much exactly the same. You will use the Create UI tool to create your UI, making sure that the game's camera doesn't see the UI layer, and that the UI camera only sees the UI layer. You then have an option to create a UI right there, or create it in another scene and just save it as a prefab that will be bright into the main game.
I personally just use the former approach. My UI is generally created off to the side somewhere (or above the rest of the game, with the Y of 1000 or so). So when working there I just switch the camera to ortho, navigate to the UI, and modify what I need.
NGUI Resources: Documentation | Forum | Release Notes
Want to get notified when NGUI gets updated? Subscribe to this thread.
NGUI Resources: Documentation | Forum | Release Notes
Want to get notified when NGUI gets updated? Subscribe to this thread.
I see. Thanks.
Last few revisions, since I haven't updated the thread in a while...
1.85:
- NEW: Added Example 12: Better Scroll View.
- NEW: Added a script that can be used to efficiently drag the contents of the panel: UIDragPanelContents.
- NEW: Added a function replacement for SetActiveRecursively (NGUITools.SetActive), since the former has rare odd issues.
1.84:
- FIX: Changed the way the font data is stored, resulting in potentially better loading performance on mobile devices.
- FIX: UIPanel.Start() should now find cameras faster.
- FIX: UIPanel will no longer use the clipping softness value unless soft clipping is actually used.
- FIX: The way click / drag was handled has been changed a bit. It should now be easier to click buttons on retina screens.
- FIX: Rebuilding an atlas was not updating fonts correctly.
- FIX: Couple of tweaks to UIAtlas and UIFont's replacement feature.
1.83:
- NEW: Added a simple script that can save the state of the checkbox (or a group of checkboxes) to player prefs.
- FIX: A variety of minor tweaks.
![]()
NGUI Resources: Documentation | Forum | Release Notes
Want to get notified when NGUI gets updated? Subscribe to this thread.
Hi,
What is special about UIDragPanelContents?
Instead of moving the widgets, it moves the panel (which is very efficient) and adjusts the clipping rect in the opposite direction, thus creating the effect of moving the contents, when in fact they lie still. Since the contents lie still, the buffers don't get rebuilt, which results in much better performance when scrolling through a long list on mobile devices.
NGUI Resources: Documentation | Forum | Release Notes
Want to get notified when NGUI gets updated? Subscribe to this thread.
Can this be used with UIGrid?
Sign-up and win: http://divemastergame.com
UIGrid can be a child of the panel, sure. That's how example 12 is set up. I just took example 7 and changed it to use the new script instead.
NGUI Resources: Documentation | Forum | Release Notes
Want to get notified when NGUI gets updated? Subscribe to this thread.