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 - artfabrique

Pages: 1 2 [3] 4
31
I followed your instructions with your scene, and everything works as expected. The only thing I changed is I pixel-perfected your 2nd label. It had a position of 115.5 or something like that. It should have used integer values (ie: 115).

Clicking the randomize button changes the text, making the labels adjust right away. The 2nd label's right and bottom sides are left not anchored, meaning they stay exactly where they were.

Looking at your video I spotted the difference however. You set the 2nd label to also Resize Freely, which is not how it is in your example, and you didn't mention it in the steps either.

The problem occurs because of a combination of centered pivot and anchoring. Change the pivot to top-left, and the problem goes away. Reason for it is simple: when you enter text in a label, its dimensions can become uneven: ie: non-dividable by two. Centered pivot requires dimensions to be dividable by two, otherwise you get floating point values.

I've found another strange behaviour: the UILabel (pivot: top-left, text align: left, ResizeFreely, anchor: advanced-left-top to another UILabel with ResizeFreely) width will be wrong after i set a new text even if a call ProcessText() & ResetAndUpdateAnchors();
The right corners(top & bottom) will stay on prev positions while left corners will update and width will be incorrect.

Here is an example little bit tuned sources:
https://dl.dropbox.com/s/a3xr30fd9ht518j/NGUIAnchorsUILabel_Pack2.rar?dl=0

32
The problem occurs because of a combination of centered pivot and anchoring. Change the pivot to top-left, and the problem goes away. Reason for it is simple: when you enter text in a label, its dimensions can become uneven: ie: non-dividable by two. Centered pivot requires dimensions to be dividable by two, otherwise you get floating point values.
But what if i want a center alignment in a text field? If i switch center-pivot of the white bold uilabel to the top-left i loose center text aligment.
I think the solution is to ceil widths, heights and coordinanates of UILabel on each text change and anchor recalculation.

33
I'll have a look at this tomorrow, but for now it would be really helpful to know the steps to reproduce the issue in a project with just NGUI present rather than a whole project to look at.
I've zipped just a test project sources without any other extensions. Very clean and tidy. But i've excluded NGUI package of course as you've asked (we use licensed version)
Steps:
1) Create Bitmap Font 1 with NGUI FontMaker size 20
2) Create Bitmap Font 2 with NGUI FontMaker size 24
3) Create UILabel1
4) Create UILabel2
5) Set UILabel 2 font, font size - 20, effect outline with black and 175 alpha, align left, pivot center-center
6) Set UILabel 1 font, font size - 24, effect outline with black and 175 alpha, spacing x -1, align center, pivot center-center
7) Set UILabel 2 anchors to Advanced
8 ) Drop UILabel 1 to top and left anchor fields.
9) Move UILabel 2 a little bit with keyboard arrows and mouse. (strange anchors behaviour could be seen even here - numbers not always get updated)
10) Now just set random text to both text fields at runtime

34
Hi!
I've found 2 very annoying bugs. NGUI 3.7.5

1) UILabel with ResizeFreely wraps/drops last character to a new line.
2) It takes up to 10 frames to for native NGUI anchoring system to reposition UILabel (ResizeFreely, align left) with advanced anchoring (top,left) to another UILabel (ResizeFreely, align center).

This bugs do not allow to calculate bounds of multiple widgets so we could wrap them with background sprite + this flickering is visually unattractive.

Here is a video-demo:
https://www.dropbox.com/s/m2ma4k5cdbmz62y/NGUIAnchorUILabel.wmv?dl=0

Here is sources (without NGUI & UnityVS)
https://dl.dropbox.com/s/61l0oukpuwxq1o7/NGUIAnchorsUILabel_Pack.zip

35
NGUI 3 Support / Re: 9-Sliced sprite as a mask for texture
« on: October 16, 2014, 11:26:39 AM »
B: Use the approach practically every single game with heavy effects on UI elements does: post processing through shaders. Create a shader and a component following the Image Effect pattern in Unity that will overlay your UI camera with scrolling texture masked using alpha of UI camera output.
Could you please explain a little bit more on this method?

36
NGUI 3 Support / Re: 9-Sliced sprite as a mask for texture
« on: October 16, 2014, 06:31:31 AM »
Now, for the tiled texture overlay, yeah, that's not possible using exclusively existing UI elements.
May be there is a "C" way: write a 9-slice pixel shader that will take 4 coords: top,bottom,left,right OR even take rects (x,y,w,h) for each of 9 pieces and will combine these atlas areas in one single scalable sprite?

37
NGUI 3 Support / 9-Sliced sprite as a mask for texture
« on: October 16, 2014, 06:02:09 AM »
Hi there!
Is it possible to use one 9-sliced sprite as a mask for texture2d?
Here is a sceenshot:

The idea is to have different button shapes and colors in a game but we are very limited in our UI atlas in terms of memory (huge number of windows popups etc)

I guess that now you are creating 9-sclice scalable sprites using UVs and geomenty, and there is no way to get a bitmap snapshot of a final(already scaled) sprite so it could be used as a mask in a shader. But maybe there is a way to do 9-slicing via shader too?

38
NGUI 3 Support / Re: Has the hyperlinking been implemented yet?
« on: July 04, 2014, 05:48:33 AM »
Hyperlinks, yes. Emoji, only with bitmap fonts.
Great! Where i can find full documentation for UILabel or how to create clickable/tappable words?

39
NGUI 3 Support / Has the hyperlinking been implemented yet?
« on: July 03, 2014, 08:53:58 AM »
Hi there!
Just quick question - has the hyperlinking been implemented yet? We are doing in-game chat with entities linking, emoji, attachments etc.

40
Hi there!
Sprites inside Prefab instances continue to share same depths while copy-pasting them in Editor. This is 3D UI.


Tried to switch Render Q to Explicit with no effect.

41
If you want the height to be resized but width to be anchored, then use Advanced anchor type and only set the left and right anchors. Leave the label's overflow at "resize height". You don't need to have all 4 set.
ITS WORKING!!! Thank you. I think this was the pretty basic question with this new Anchor system but solution not obvious )

42
NGUI 3 Support / Re: Is it possible to make widget fit it's content?
« on: February 04, 2014, 04:24:53 AM »
There is no silver bullet for something highly custom like that.

Your best bet is to simply position the widgets yourself based on your own logic in a custom script written just for that purpose.
Sure! Any way i've bought latest NGUI and pretty happy with it.
But what about NGUIMath.Calculate.. which returns Bounds.size?
Now i'm thinking of this scene structure:
- Container1 (widget) (this is main window)
--- Container2 Game Object (Anchor to Container1 TopLeft corner)
------ Title (UILabel) (Anchor to Container2 left to center it vertically)
------ Description (UILabel) (Anchor to Title)
------ Icon (Sprite) (Anchor to Title)
------ Other content elems..
--- Background (Sprite) (Anchor to Container1 left top right bottom)

I'm trying to get Container2 dimensions by:
  1. Bounds bounds = NGUIMath.CalculateRelativeWidgetBounds(transform, transform.FindChild("Container2").transform);
Then i just resize the Container1 by:
  1. GetComponent<UIWidget>().width = bounds.size.x + myCustomPadding;
  2. GetComponent<UIWidget>().height = bounds.size.y + myCustomPadding;
  3.  

Am i on a right route or there is some gotchas?
For example old UIAnchor will not update automatically to center content. How can i trigger this recalculation from outside? I have RunOnlyOnce checkbox checked.

43
Hi there!
Is there any way to have my UILabel stretched horizontally (by setting left and right anchors) and have overflow "Resize Height"?
I've tried to use old UIAnchor an UIStretch but it doesn't suits me:
I simply have a table with widgets in each cell and i UILabel inside each widget centered vertically. At some point of time i resize all widgets and call UITable.Reposition() BUT! all UILabels do not update their positions after it's container height changed (old UIAnchor :( )
That's why i decided to switch to new Anchor system and bought a fresh version of NGUI  :P
And i just don't get how to make it work with UILabels+new Achors+ResiseHeight.
Can somebody please help?
P.S.
Also i've noticed that the new Anchor system is very powerful, BUT!! PLEASEPLEASE! make 1 small checkbox: "forbid stretching". And for example after i check it — 2 out of 4 Anchors become disabled (based on which pivot positioning i've previously selected). It will ease up the UI creation process very much because now it's simply impossible to enter coordinates by hand because you have to modify all 4 numbers OR every time switch to Advanced and point 2 of 4 Anchors to widget itself,where you have to input widget dimensions again. This take so much time and cost of error is very high in terms of production timeline.

44
NGUI 3 Support / Re: Is it possible to make widget fit it's content?
« on: February 02, 2014, 07:43:43 PM »
Any thoughts on this case?
I'll try to write some loop where i'll recursively ask each of children their left-top-right-bottom coordinates (still don't know which space to use) and then find max&min to use as left-top-right-bottom.
I've found this method:
  1. NGUIMath.CalculateRelativeWidgetBounds
But i'm not sure how it works and which units it use and in which coordinates space?

45
NGUI 3 Support / Re: Is it possible to make widget fit it's content?
« on: February 01, 2014, 07:42:31 PM »
Sure! I've tried this approach but after i ran into other problem  :)
What if my content looks like this and i'll have let's say 9 types of content layout?
How do i know which widget is the most right,left,top and bottom?
This is layout for quest messages and other special message templates and it will be modified/added over time(months) because it's basically part of the game core content. And i'd love to have possibility to update only this parts without updating my window manager.

Pages: 1 2 [3] 4