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

Pages: [1] 2
1
NGUI 3 Support / Re: Grid and Tables deactivating at runtime...
« on: March 10, 2015, 03:36:14 AM »
So I have a problem that might be related to this. In my hierarchy there are these elements:

-Panel
--Header (some sprites)
--Background
--Scrollbar
--ScrollView
---Table

The panel gets enabled/disabled (as it is just a part of the UI). The table has a certain amount of elements, which get activated/deactivated to show the elements I need, but when I do that, the table appears in the middle of the Scrollview instead of at the pivot point (which is set to TopLeft in inspector). As according to the docs on UIScrollView and UITable, I reposition the table after populating its contents and then I reposition the ScrollView:

  1. // activate/deactivate desired table elements...
  2. // and then sort the table and reposition the scrollview
  3. mTable.sorting = UITable.Sorting.Alphabetic;
  4. mTable.pivot = UIWidget.Pivot.TopLeft;
  5. mTable.Reposition();
  6. mTable.transform.GetComponentInParent<UIScrollView>().contentPivot = UIWidget.Pivot.TopLeft;
  7. mTable.transform.GetComponentInParent<UIScrollView>().ResetPosition();

Curiously enought, this only happens the first time the panel that contains the scrollview and the table is enabled. Once I disable the panel and reenable it, everything gets to its position.
I have tried all the combinations with populating the table, repositioning the table and resetting scrollview's position but it doesn't work as I think it should (which is setting the contents of the table to the top left and the table also to the top left of the scrollview). Am I doing something wrong with my code or am I expecting a different behaviour than the intended?

I have attached two images showing what I think I shoud get and another showing what happens.

Thanks

[EDIT Also tried getting the scrollview component using NGUITools:

  1. UIScrollView sv = NGUITools.FindInParents<UIScrollView>(mTable.gameObject);
  2. if (sv != null) {
  3.         sv.contentPivot = UIWidget.Pivot.TopLeft;
  4.         sv.ResetPosition();
  5. }

And I just debugged it and made sure it does go through that piece of code. Still nothing. Seems like calling either UITable.ResetPosition() or UIScrollView.ResetPosition() (or both) does nothing...

2
NGUI 3 Support / Re: UICamera Event occlusion
« on: November 18, 2014, 09:54:13 AM »
The reason I'm using a fallthrough object is because even if I attach a UICamera script to my world camera it doesn't get the onScroll event (I'm not sure why it doesn't get it because it gets the other events perfectly). So I set the fallthrough objecto to the world camera and if i scroll on a ui object then the UI gets the event, and if I scroll outside the UI then the world camera gets the onScroll event. If I click on a ui object with a collider, then the ui gets the event, and if I click outside the UI then the world camera gets the event. But If I click on a ui element that has no collider, then it is the world camera (i.e. the fallthrough object) that gets the event.
So in order to prevent this, I must attach a collider to the ui elements that have no collider, right? Sounds terrible (I would need to attach colliders to a lot of objects that don't get interaction with the user), maybe instead I need to figure out why the world camera doesn't get the onScroll event when it has the UICamera script on int.
Thanks.

3
NGUI 3 Support / Re: UICamera Event occlusion
« on: November 18, 2014, 03:31:45 AM »
What I'm currently doing in Windward is this:

1. UICamera's fallThrough is set to the UICamera's game object itself.
2. I use UICamera.onClick, UICamera.onPress, etc delegates, subscribing to them as needed. They work as long as fallThrough has been set to something.

This way I don't need colliders, and everything works as expected. Events go to their proper objects, as well as to my delegates.

I'm bumping this because I'm trying to achieve something similar and I can't get it done. Is there a way to make the fallthrough object ignore the events while the mouse is on a ui element that has no collider?

4
NGUI 3 Documentation / Re: UISlider
« on: November 13, 2014, 06:45:23 AM »
UIWidget (UISlider, collider)
- UISprite foreground
- UISprite background

That's the typical setup. You can use any widget for the foreground/background, not just a sprite. In Windward I used labels for example -- labels set to use dots as text (.............).

Ok, my setup was different:

UISprite background (UIslider, collider)
- UIWidget (compound background)
- UISprite foreground

I'll give it a try. Thanks for the response!  :D

5
NGUI 3 Documentation / Re: UISlider
« on: November 12, 2014, 05:10:30 AM »
Is it possible to create a slider using a widget instead of a sprite? I'm asking because I have a slider with "many children sprites inside the background" instead a just one background sprite. The idea is to hide the background sprite (the one with the UISlider script) and have the other compund sprite as a background.

I have tried a couple things but haven't been able to make it fully work. I have tried disabling the UISprite component (leaving the UISlider and the collider both enabled), but then I don't receive the drag functionality on the slider. Also setting the alpha of the background to 0 changes all the children sprites alpha to 0 too. I tried adding a widget and disabling the sprite, but I guess it only works with sprites.

6
NGUI 3 Support / Re: UILabel ResizeHeight: height property has wrong value
« on: November 06, 2014, 02:31:25 AM »
Table's cells are based on the content within them. If your widgets resize based on the content of the labels, you should use EnvelopContent. That script is capable of resizing a widget around multiple ones. That said, mixing such resizable content and tables may give unpredictable results (which one will execute first?) unless you control it (potentially manually). Although reading the rest of your description I am not sure what a table has to do with any of this, or why you're using it.

I don't advise mixing full anchors and resizable content. You are just asking for trouble. Instead, anchor only one corner (for example top-left). The right and bottom will be calculated based on the label's resized values. Just make sure that the label's pivot point matches (top left).

Thanks for the response, I'll try with the EnvelopContent or setting the top-left corner. The reason I'm using a table is because some of the rows of the table get enabled/disabled depending on the element the user has clicked on, so table rows get positioned by the table itself.
Again, thanks. I'll keep working on it.

7
NGUI 3 Support / Re: UILabel ResizeHeight: height property has wrong value
« on: November 05, 2014, 03:03:09 AM »
What is it you're trying to do, and what version of NGUI are you using?
I'm using v3.7.1.

What I'm doing is populating a table with rows instantiated at runtime (using Addchild function). Those rows have one sprite and 2 labels (name and type) and the content of the labels is read from a file. Since the width of the table is fixed, the labels must resize their height depending on the contents, therefore the widget that contains the row must change its size according to the size of the labels (plus a certain padding: 11px above upper label, 5px between upper and lower label and 11px below lower label). I can't set (or I think I can't set) the anchors of the widget relative to the labels because when the name label is just one line tall, then the icon on the left is higher than the sum of the two labels plus the padding (attached an image showing the two possible cases).

It works perfectly in all the cases but the one in the previous pictures, in which the value of label.height is equal to 2 lines tall but the label is displayed in 3 lines (and the size of the label equals 3 lines tall). As the size of the widget is set by code depending on the sum of the label.height of both labels (plus padding) and label.height returns a "wrong" value, the size of the widget is set wrong and the contents of the row overlaps the previous table row (picture of the previous post).

[edit] I'm trying to set the anchors of the widget to the icon or the labels depending on the size of the labels instead of setting the size of the widget by code. I'll post the results later.

8
NGUI 3 Support / Re: UILabel ResizeHeight: height property has wrong value
« on: November 03, 2014, 09:45:45 AM »
I'm bumping this because I have the very same problem. Here's my code (it goes inside a foreach that cycles through some children labels):

  1. labelName = child.GetComponent<UILabel>();
  2. if (labelName != null) {
  3.                 labelName.text = item.GetName();  // returns a string with the name of the current item
  4.                 labelName.ProcessText();
  5.                 // labelName.ResetAndUpdateAnchors();
  6.                 Debug.Log(labelName.processedText + ": " + labelName.height);
  7. }

So the Log shows the label text and a height of 32 (font size is 16). In the log, the processed text is displayed in 2 lines, but in the game view (and also the editor) the text is displayed in 3 lines and shows a size of 48 (which is logical, since it's 3 lines of 16 size font).
I tried the simple example of a new empty scene and it works correctly, so any idea of what may have I done wrong? I set the bottom anchor of the label a few lines later, can it be the reason?

  1. // If the label takes more than one line, reposition it related to the type label ("name label" is above "type label")
  2. if (labelName.height > 16) {
  3. // the widget is the one that contains the two labels
  4.         labelName.bottomAnchor.Set(widget.transform, (16.0f + labelType.height) / widget.height, 0.0f);
  5.         labelName.ResetAndUpdateAnchors();
  6.         labelType.topAnchor.Set(widget.transform, (11.0f + labelType.height) / widget.height, 0.0f);
  7.         labelType.ResetAndUpdateAnchors();
  8. }
  9. // The values 16 and 11 contain the upper+middle+bottom padding of each label inside the widget

[edit] By the moment I change the anchors, the label.height is already wrong (it shows wrong the very next line of the labelName.ProcessText()) sot the anchoring is not the problem.

[edit 2] Debugging it shows that after calling ProcessText() the value of mProcessedtext includes two lines but the value of mText doesn't (it's all one line). But still, in game mode and editor mode it displays the label as a 3 line label. The values of height are correct, since editor panel shows a height of 48 for the 3 line label but Log shows a height of 32 for a 2 line label. Weird...

[edit 3] Attached 2 screenshots. One showing the label.height as 32 in the log (don't mind the error, I coded it as error but it should be a warning, lol) and the other showing the 3 line label and a size of 48. Both screens happening at the same time.

9
NGUI 3 Support / Re: UISprite and UI2DSprite not getting along
« on: October 27, 2014, 02:43:33 AM »
Check quality settings. You likely have web player target set to Fastest or something similar that degrades texture quality.

Thanks, that was it. I had checked the override options, but I didn't check the quality settings and every target was set to fastest (although I have no idea how that happened, lol  :o). Already changed it and everyting looks good now.

I thought this could be a NGUI issue instead of me being careless with Unity settings and that's why I posted here, sorry to bother you guys. Thanks for the help.

10
NGUI 3 Support / Re: UISprite and UI2DSprite not getting along
« on: October 23, 2014, 08:52:34 AM »
Maybe your atlas is set to be mipmapped or compressed? That would only affect the regular sprites, not the uGUI-like sprites.
The atlas is set to Truecolor and it hasn't changed at all ever since it was created. The atlas has the same settings as before I started using the UI2DSprite (I actually checked it several times to see if I had changed it). That's what puzzles me.

It only happens in the build (webplayer target) as in editor mode it doesn't happen. And I also keep the same settings for the build (not override).

11
NGUI 3 Support / UISprite and UI2DSprite not getting along
« on: October 23, 2014, 05:58:23 AM »
Hi there,
I'm switching from using UISPrite elements to UI2DSprite elements because it is easier for me in the current project to store the references to the sprites rather than have the string names of the sprites inside the atlas (I have an info panel that changes some sprites depending on the info being shown).
Right now, while some elements are UISprites and some other are UI2DSprites, it seems that they don't work properly together, resulting in the UISprites being shown blurry while the UI2DSprites are being shown properly. Have I missed something? Is there a place where it states that they can't be used within the same UIRoot? Or is it just some configuration that I set wrong?
Thanks in advance.

12
NGUI 3 Documentation / Re: UITable
« on: October 06, 2014, 08:21:46 AM »
You should pass the panel's game object to it.

Ok, thanks for the response.

13
NGUI 3 Documentation / Re: UITable
« on: October 03, 2014, 03:48:59 AM »
Reposition() function collects all widgets underneath and calculates their dimensions. However if you've just enabled a game object, chances are its widgets haven't initialized yet. If you want widgets to init/refresh immediately, you need to use NGUITools.ImmediatelyCreateDrawCalls.

I don't know why, but ImmediatelyCreateDrawCalls only works the first time I call it (it places every new widget on its place). The following times all the new widgets created (and activated if they were already created) are placed on top of each other overlapping. Does ImmediatelyCreateDrawCalls root parameter need to be the UIRoot? Or can it be the UITable...

(BTW I use a workaround to "solve" the issue of the Reposition not working with the newly created table rows by starting a coroutine that calls the Reposition() function in the following frame)

14
NGUI 3 Documentation / Re: UITable
« on: October 02, 2014, 05:00:30 AM »
How is UITable.Reposition function used? I Have a table with rows generated and activated/deactivated dinamically at runtime (with the addchild function). So whenever I create new rows (or activate/deactivate any row, it's all in the same funciton) I call Reposition function afterwards, but it doesn't seem to work the first time I do it. The table actually takes a few calls to the function to reposition all its contents properly.

15
NGUI 3 Support / Re: Upgrade Unity to 4.5.3 and NGUI to 3.7.1 problem
« on: September 23, 2014, 01:33:07 AM »
You need to make sure that only one camera can see the UI layer -- your UI camera.

Your main camera can likely see it, which is what's causing your issues.

Oh boy, I'm so sorry. You're right, the culling mask of the main camera had the UI layer on... The worst part is that I even knew that the UI scaled to fit another camera, but as I thought the main camera settings were right I didn't even check it. Sorry.

Thanks for the fast response.

Pages: [1] 2