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.


Topics - Tiktaalik

Pages: [1]
1
NGUI 3 Support / Perform Anchor calculations immediately before Start()?
« on: October 21, 2014, 04:40:55 PM »
I have a situation where I want to have UILabel (WidgetA) with a child anchored to it (WidgetB) that will wrap around the UILabel. When I set a bunch of text to the UILabel, the label will expand for the text and I want to immediately have the child WidgetB update its anchors and expand to contain WidgetA. I want this to occur immediately so that I can immediately query the new size of WidgetB. How do I force these calculations Immediately?

As it stands to get this to work I can call

  1. WidgetA.text = value;
  2. //We must use "localSize" here as UILabels recalculate their text processing on when localSize is called.
  3. //Calling localSize will force this recalculation immediately.
  4. var size = WidgetA.localSize;
  5. WidgetB.UpdateAnchors();
  6. var sizeB = WidgetB.localSize; //<-- not going to be correct.
  7. ....
  8.  

However at this point sizeB will not be correct. Later on in the Start() I'll be able to fetch the size of WidgetB and it'll be correct.

So my core issue is that I'm not really clear on how Anchors work at the low level. Is there's some aspect of their functionality that requires on the objects being active or enabled and UpdateAnchors() doesn't get around this? Is there a way to force the calculations immediately even if I'm calling on objects prior to their Start()?


2
I'm trying to build an inset widget (let's call it InsetWidget) much like what is described on the UIRect documentation, but designed such that the inner widget is a UILabel that resizes its height based on the text. As the inset UILabel expands, the outer containing UIWidget should also expand.

I've been able to create this by having the UILabel not anchor its bottom, and having the containing UIWidget anchor its bottom to the bottom of the inset UILabel.

Unfortunately I'm getting very weird bugs where this InsetWidget's height is drifting slowly larger. I've also on re-running seen an issue where the height of the UILabel was going back and forth between a negative and positive value, causing the whole thing to wobble.

Is this a legitimate way to build this sort of Widget or will doing this always lead to problems?

(As well these widgets are being added to a UITable if that means anything. I haven't yet tested how this runs outside of that situation)

Running NGUI 3.5.5

3
NGUI 3 Support / Sometimes widgets don't render after legacy animation.
« on: August 21, 2014, 01:12:39 PM »
Preamble: I have a fix for this problem but I wanted to make a post about it to find out more about how NGUI works and to provide a solution in case anyone else ever comes across this same issue.

I found a weird problem when running our game on old slow iPhones (3GS and 4). In situations where we activate an UIPanel and then perform a legacy animation on it, we arrive at a situation where the widgets on the panel aren't visible, but when you click on the space where they should be, they blink into existence. It is like they are actually there, but they have not been drawn. If you zoom out however, you can see that the widgets are actually remaining in their original, pre-animation positions. Very odd. Since we didn't see the animation play, we suspect what is happening is that the activation of the Panel and all its widgets is taking so long that the animation is actually completed before the widgets were active. Somehow after this the widgets are in some weird state that I don't fully understand.

I thought I'd be able to fix this by forcing a UIPanel.Refresh(), but that didn't work. I was able to fix it however with this following code:

 
  1. foreach(var w in m_uiPanel.widgets){
  2.     w.MarkAsChanged();
  3. }
  4.  
  5. m_uiPanel.Refresh();
  6.  

In this thread you mentioned that

Quote
Panel's Refresh() will refresh the draw calls, but only of the widgets that have been registered with the panel. MarkAsChanged registers the widget with the panel.

Are the widgets being unregistered somehow? Or is it that some other code that is supposed to mark widgets as changed never runs in this case? I'm not really sure why I have to manually mark all the widgets as changed.


4
I'm currently tracking down a pause in our game that I believe is due to Font.CacheFontForText. To solve this problem I need to get a better feel for how our use of fonts in screens at that moment is affecting the game's performance.

I want to test whether disabling certain NGUI UILabel options (ie. shrink text, shadow) will have enough of an impact to solve the issue or whether it's irrelevant.

Is there a way in Unity to see a snapshot at runtime of what memory Unity has allocated for Fonts in particular? What would be the best way to approach debugging this problem?

5
I am able to build a table in a vertically aligned scrollview but I don't really understand why I have to do what I have to do to make it work. As well the method I'm using doesn't work with the new anchor system. All of this makes me think I'm doing this incorrectly and so I thought I'd post to make sure there isn't some proper correct method that I've somehow missed.

I have constructed an ultra basic scene hierarchy as such:
  1. UIRoot (UIPanel)
  2. -->Camera
  3. --> --->(UIPanel)(UIScrollView)(UITable)
  4. --> --> -->(TableCell)
  5. --> --> -->(TableCell)
  6. --> --> -->(TableCell)
  7.  

If I align my scrollview panel at 0,0,0 with the following options:
  1. UIPanel with ScrollView, UITable
  2. Transform
  3. P: 0, 0, 0
  4.  
  5. Clipping:
  6. Offset: 0, 0
  7. Center: 0, 0
  8. Size: 300, 300
  9. Anchors:none
  10.  
  11. Cells
  12. Transform
  13. P: 0,0,0
  14. UIWidget Pivot: Centre, Centre
  15.  
  16.  

It looks like the following:


When I run the game I get this:



Doh! it's not aligned right! It appears as if the top corner of my cell is placed at the centre point of the clipping.

Here are my steps to fix:
- Change the Panel Clipping "center" variables such that the location is at the same position as the centre of the Panel. (in this case -150, 150)
- Change the transform of the Panel such that the clipping area appears where you want it.

  1. UIPanel with ScrollView, UITable
  2. Transform: -150, 150
  3. Clipping:
  4. Center: 150, -150
  5. Size: 300,300
  6. Anchors: None
  7.  
  8. No change to Cell.
  9.  

So now I have:


and when I run I get the correct looking results:



Essentially my problem is that I have no idea what I just did or why I had to do it. This seems like a random hack and I don't know what I've just done.

Furthermore if at this point I try to use the new anchoring system to parent this scrollview panel to some other panel then this will be broken immediately as the anchoring system modifies the position of the scrollview panel.

What is the correct way to build the screen that I've shown in the final image?

6
I'm looking at the implications of upgrading our project from 3.0.1 to the latest version. I upgraded and noticed that all our text was super small. I believe this is because previously we had one UIFont size and were scaling the UILabels (ie. 0.5, 0.25) to get smaller text, but now NGUI has a separate font size field and so these two notions are making things doubly small. It seems like setting the scale to 1 makes things the right size. Would this be correct? At this place in the project I'm a bit hesitant to make this change, because setting the UILabels scale to 1 fixes the text size but changes the label box size. That might create a lot of knock on work. Are there any downsides to the current approach of scaling text via scaling UILabel?

I'm a bit confused by the new UILabel Inspector. There's a drop down saying "NGUI" and one for "Unity" but I haven't found anywhere in the documentation or release notes that explains what this is about. If I select Unity I have the option to directly input typefaces, but if I select NGUI I can drop in a UIFont prefab. In either I still have the option to set font size. Are these both making use of dynamic fonts? What's the concept here?

One thing I'd like to know more about is UIFont.pixelSize. I've read in a number of places on the forum that the correct approach for retina devices should be to have a UIFont with pixelSize to 0.5f. Is the idea to create this, save as a prefab and use with the "NGUI" setting? In this situation can I just use one UIFont prefab, and set text dynamically?

Anything else I should be aware of with regard to fonts with this upgrade?

7
Hi,

I'm trying to dynamically create a bunch of items and add them to a UITable. I'm seeing an issue right now where my items are correctly added, but they're stacked on top of each other and in the wrong position. After I've added my items I tell the table repositionNow = true so that in the late update it'll reposition, but it's not having any effect. After the fact if I select the UITable in the editor and manually select repositionNow then everything repositions as expected.

Does instantiating a prefab and adding it to the table take so long that I have to wait beyond the LateUpdate? What may be some things I could be doing wrong or in the wrong order that could cause this not to work?

I have the following bit of code being called. The Table object is a UITable.

  1. foreach (var inventoryWidgetData in inventoryData.InventoryWidgetDataCollection)
  2.                 {
  3.                        GameObject item = NGUITools.AddChild(Table.gameObject, ItemPrefab);
  4.                         NGUITools.AddWidgetCollider(item);
  5.                         item.AddComponent<UIDragPanelContents>();
  6.  
  7.                         InventoryWidget w = item as InventoryWidget;
  8.                         if (w != null)
  9.                         {
  10.                                 w.Populate(inventoryWidgetData);
  11.                         }
  12.                 }
  13. Table.repositionNow = true;
  14.  

8
I'm successfully populating a table with several items but when I try to scroll down all of the items blink off at once instead of being clipped.

I've tried to follow the steps from the FAQ (http://www.tasharen.com/forum/index.php?topic=6.msg11833#msg11833) but I'm not having any success.

I'm getting this error: "Clipped panels must have uniform scale, or clipping won't work properly" but I feel like the scale of the clipped panel is 1/1/1 and that should be fine. There's a "Auto-Fix" button that appears to do nothing.

I'm also unsure about the Unlit/Transparent Colored atlas step. I've set my "UIAtlas" shader to be Unlit/Transparent Colored" but I notice in the draw call listing that there are various Unlit/Transparent Colored draws and also UIAtlas draws. I'm not sure what this is supposed to indicate and if this is expected. I've linked an image.



9
NGUI 3 Support / Understanding BoxCollider Depth
« on: October 03, 2013, 01:33:46 PM »
I have an issue where I have a panel with two buttons on it and I'm getting really inconsistent button selection ability.

From my understanding the Z Depth of the BoxCollider should be increasingly negative for objects that are "on top" and clickable. I'm running into issues where even when I force edit the Z of the BoxCollider of the buttons to be more negative than the panel behind the buttons, when I run the game these button boxCollider values are somehow overridden to some other (less negative) value and the buttons remain unclickable. I'm at the point where I don't know how to proceed because I don't understand what sort of things are happening behind the scenes and how this system is supposed to work.

How can I fix this?
What actions may inadvertently "break" the default BoxCollider setup and how does one fix it?
What is the best workflow for creating panels and buttons and having BoxCollider depth work as expected?
Am I correct in believing that widget depth has absolutely nothing to do with BoxCollider depth?

For reference my hierarchy looks like:

UIPanel (has boxCollider)
-->View (background sprite)
-->--> Button (has boxCollider)
-->--> Button (has boxCollider)

Running 3.0.1

10
Hello. I'm very new to NGUI and I'm trying to figure out how best I should best organize my UI elements in a panel using anchors. I want to anchor everything offset from the top left side and I've been following Example 1 in NGUI Free 2.0.7c.

My current setup is as follows:

UI Root
--> Camera
-->--> Panel
-->-->--> Anchor
-->-->-->-->UITable
-->-->-->-->-->Label

The odd thing I've noticed is that I can organize everything such that it makes sense in the editor, but when I run my project, the transform of the UITable is overridden and changes from 0,0,0 to 19.33334, -270, 0 and is part way down the screen. The Label is top left aligned with a transform of 0, -10, 0.

Poking around I've noticed that the transform values of my Camera, Panel, Anchor all seem to occasionally get modified when move a bunch of things around and then I run the game. I'm wondering what is going on here, how these values change, and what am I supposed to do? Is there a best practice of moving certain things in an order? I'd guess that the size of my Panel should be the size of the screen I want? What about the size of every other element such as the Anchor?

Pages: [1]