Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Unisip

Pages: [1] 2
1
NGUI 3 Support / Justified text coming in v3.1 ??
« on: January 30, 2014, 01:18:25 PM »
A friend of mine working at the NSA recently hacked ArenMook's computer and says that justified text is coming in build 3.1!
Is that true???  ;-)

2
NGUI 3 Support / Re: Justify Alignment for Text
« on: January 15, 2014, 05:12:15 AM »
+1 for text justification
I read in the thread that it is planned, and I'm eager to have it integrated, as I'll need it very soon :)

3
NGUI 3 Support / Re: Missed mouse input events: a quick fix for NGUI
« on: October 08, 2013, 06:45:23 AM »
I agree that my solution only accounts for mouse inputs. It's just a quick fix to at least patch that problem with GetMouseButtonDown/GetMouseButtonUp. Better than nothing, until we get a proper fix on Unity side...

4
NGUI 3 Support / Missed mouse input events: a quick fix for NGUI
« on: October 07, 2013, 12:31:13 PM »
Hey,

I've noticed that when framerate temporarily drops, Unity's Input class sometimes misses mouse events, resulting in NGUI buttons feeling unresponsive, even totally ignoring clicks.
Basically, what happens is that you might get an Input.GetMouseButtonUp without an Input.GetMouseButtonDown occurring before it. An NGUI button won't received the Clicked event if Input.GetMouseButtonDown was skipped by Unity.
This is not an NGUI bug, but there's a very simple way to fix this in NGUI, but changing a few lines in UICamera.

Here is what you need to change in UICamera.cs:

instead of this (from line 832 in NGUI 2.7)

                // Process all 3 mouse buttons as individual touches
      if (useMouse)
      {
         for (int i = 0; i < 3; ++i)
         {
            bool pressed = Input.GetMouseButtonDown(i);
            bool unpressed = Input.GetMouseButtonUp(i);
                                ...

Use this:
                // Process all 3 mouse buttons as individual touches
      if (useMouse)
      {
         for (int i = 0; i < 3; ++i)
         {
                              bool pressed = false, unpressed = false;

                              if (Input.GetMouseButtonDown(i) && Input.GetMouseButtonUp(i))
                              {
                                     //press unpress in same frame
                                     pressed = true;
                                     unpressed = true;
                                     mouseDown = false;
                              }
                              else
                                  if (Input.GetMouseButton(i) != mouseDown[ i ])
                              {
                                    pressed = Input.GetMouseButton(i);
                                    unpressed = !Input.GetMouseButton(i);
                                    mouseDown = pressed;
                               }
                               ...

You will also need to declare as the MouseDown array as a global private field somewhere in the class, like this:
private bool[] mouseDown = new bool[3];

Hope this helps.

BTW, Michael, if you read this and if you feel this modification makes sense, it would be great to have it integrated in a coming release of NGUI. And while we're at it, it would be even better if this problem was fixed in Unity's Input class and/or the so much anticipated new UI system. :)

Tks



5
You are pointing to a real issue --> depth sorting management with multiple materials in a package that tries to reduce drawcalls.
The best solution I found was to Increase the number of panels i am using, and to tweak their gameobjects z value to sort them. This usually works reasonably well:
- you get two dawcall per panel, provided that you use one atlas for images and one for font
- on each panel, you will be ok as long as you can live with text in frnt of every other elements
- with a decent z distance between each panel, you get proper sorting, as far as i could tell

It's not ideal, but i haven't found a better solution.
I sincerely hope the unity upcoming GUI solution solves this problem.

6
NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 11, 2013, 10:49:10 AM »
The unity dynamic font API doesn't let you remove unused characters, as far as i can tell. But it's not clear to me why you would want to do that clean up work anyway, is it for video memory usage reasons?

7
NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 10, 2013, 10:07:09 AM »
Ok I *think* I might have something that makes more sense.
No more magic number, it relies on the font import size (which unfortunately can't be accessed from code, it seems, so I set the value to a constant 16, since when you import a font, its size is set to 16.
zh4ox, can you test this and tell me what you think?

8
NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 10, 2013, 09:17:10 AM »
@zh4ox, it sort of works, but I'm not really into magic numbers. I'd rather have an explanation of how that Y value is supposed to work. I guess I'll post on the Unity forums to see if someone figured it out

9
NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 10, 2013, 06:41:31 AM »
Why would you want to do that?
As far as I can tell, you can't. Unity manages the font and clears it up only when needed.

10
NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 10, 2013, 04:45:43 AM »
Cool, I'll try this out too!

11
NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 10, 2013, 04:07:59 AM »
yeah there's this weird thing with vertical offsets. Frankly I haven't bothered too much about it since I was testing with smaller fonts like 12 to 18px, but I agree that this is problematic.
I'll try to have another look at this issue too. It seems we don't fully understand the values that the CharacterInfo class gives us for positioning fonts. In fact it might make sens to try to figure that out even outside of the NGUI context

12
NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 10, 2013, 03:04:31 AM »
Hi all,

With permission from ArenMook, I'm releasing this code that adds support for Unity 4 dynamic fonts in NGUI.
This code is provided "as is", it hasn't been fully tested on all platforms, and there might be bugs. Feel free to modify it as needed, and to integrate it in your own products, as long as you have an NGUI source licence.

Please look at the readme file for help.

@wsicarlos: what I found in my tests was the following:
- when you add new chars to the font texture, if the texture has to be rebuilt (to change its size), it will only be rebuilt with those new chars. All older chars are removed, and the texturerebuilt callbacks are invoked. On callback, you can have other gameobjects displaying text (UILabels, but also text meshes if needed) request their characters to be added to the font texture again. Any object that doesn't request its characters again takes the risk of not finding them in the texture anymore. Anyway, see my code for it, a diff with the original NGUI version will point you to the changes I made.

@zh4ox: you can see in my code how height is handled. The multiline text is displayed properly. The only thing that is not working well in my code yet is the pivot vertical alignment. I'm not sure where the problem is, but I'll try to figure it out too when I have more time (busy finishing another project right now).

Any feedback appreciated...

13
NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 09, 2013, 12:11:35 PM »
@zh4ox
Mmm, I'm not sure I am following you on this one. Why would you have to change any settings in the font asset, like the size? In my implementation, I never had to worry about this, neither did I have to bother much about text placement, it's all handled by the CharacterInfo class in Unity.

14
NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 09, 2013, 03:38:12 AM »
The Unity APIs do all the work for you.
Basically, there is a delegate that alerts you when the font texture has to be rebuilt from scratch (that is, when there is no more room for a new character). All you need to do is make sure that all your assets using the font get notified so they can take action.
In the case of UILabels, when a font texture is rebuilt, call 'MarkAsChanged' on every UILabel that uses the font does the job.

Again, for anyone programmer who wants to play around with that code, I'm happy to share it "as is".

15
NGUI 3 Support / Re: Dynamic font support for NGUI
« on: January 08, 2013, 02:22:52 PM »
Mmm, that's more work, actually, if you want to mix font sizes in the same UILabel --> additional code changes to recompute all things related to text alignment, etc... Not trivial

Pages: [1] 2