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

Pages: [1] 2
1
I had tried adding the zeros but it wasn't reliably working. It would often group them like this:

001
010
011
002
020
003
030

I saw the same behavior with this too:
001
0010
0011
002
0020
0021

Etc.

I'm pretty certain this DID work in the past though, so I was a little surprised that it didn't now. However, I'm also running Unity 5, and I remember it working in Unity 4. So perhaps this is specifically a Unity 5 related issue.

2
Yes, and I agree that would be the best way - but it doesn't seem to work right as there is a race condition. Once the dialog is opened, NGUI populates the field with its default value. Our code is then setting the .value of the slider. The two collide, and the default value ends up taking control. Since it also toggles the script, the value saved for the game ends up getting set to the default value. The obvious question here is - why not just wait a moment and then set our value? The reason for that is the visual display. NGUI waits until the object is entirely enabled - then it sets the default value. So if we wait for the default value to be set before giving it our value, the user will see a noticeable pop of one value, which then jumps to another value.

So another fix for this would be to have the slider have an option to not set its default value upon enable.

3
In attempting to use the existing Alphabetic sort type to sort UIGrid / UITable lists to sort numeric entries, it does not seem to always reliably sort correctly. I had originally thought that the Alphabetic sort would work for numeric, but that does not seem to be the case. I've coded up a quick fix however that allows Smallest to Largest numeric sort:

In UITable.cs, line 26, change the enum to have a Numeric option:

  1.         public enum Sorting
  2.         {
  3.                 None,
  4.                 Alphabetic,
  5.                 Horizontal,
  6.                 Vertical,
  7.                 Custom,
  8.                 Numeric // Add this
  9.         }
  10.  

Still in UITable.cs, around line 128, add the following inside the "if (sorting != Sorting.none)" block:
  1.                         else if (sorting == Sorting.Numeric) list.Sort(UIGrid.SortNumeric);
  2.  

In UIGrid.cs, at the top where the Enum is for Sorting, add the Numeric option here as well:
  1.         public enum Sorting
  2.         {
  3.                 None,
  4.                 Alphabetic,
  5.                 Horizontal,
  6.                 Vertical,
  7.                 Custom,
  8.                 Numeric
  9.         }
  10.  

Finally, in UIGrid.cs, add the following around line 280, where the other sort methods exist:
  1. static public int SortNumeric (Transform a, Transform b) { return System.Convert.ToInt32(a.name).CompareTo(System.Convert.ToInt32(b.name)); }
  2.  

That's it! Now your numeric entries will for certain sort properly when you call Reposition. Hope it helps!

4
Found some interesting conditions regarding UIProgressBar. Had to make some changes to the UIProgressBar.cs script that I would like to share here, as I think they could be valid updates to it overall.

Silent Value Changing
In our project we have various UISliders (which are derived from UIProgressBar). The values are changed by the player, then saved. When the player returns to that dialog, the sliders need to be the same value where they were left. We ran into issues where we would change the value of the progress bar in script, and since the value changed - the OnChange event would get toggled. This led to some various ugly situations. The best answer we found was to add a method to UIProgressBar which would allow changing the value property, without toggling the OnChange event. That code is as follows. It's pretty much the same as the value property, only does not call the event.

  1.         /// <summary>
  2.         /// Changes the value without toggling the callback. Use for when changing the value in script
  3.         /// </summary>
  4.         /// <param name="newValue">New value to be saved to mValue.</param>
  5.         public void changeValueNoCallback(float newValue)
  6.         {
  7.                 float val = Mathf.Clamp01(newValue);
  8.                 if (mValue != val)
  9.                 {
  10.                         float before = this.value;
  11.                         mValue = val;
  12.                        
  13.                         if (before != this.value)
  14.                                 ForceUpdate();
  15.  
  16.                         #if UNITY_EDITOR
  17.                         if (!Application.isPlaying)
  18.                                 NGUITools.SetDirty(this);
  19.                         #endif
  20.                 }
  21.         }
  22.  


Misplaced Object Creation Event Calls
Next, we found another issue where every time the dialog opened, regardless of us setting the value to what we wanted, it would be automatically changed to whatever we defaulted the value to in the editor. This was tracked down to the OnChange event delegate being called as soon as the dialog was opened. That can be fixed by simply removing those lines of code. This also isn't needed, because the UIProgressBar was just displayed - the value isn't changed by the user, therefore calling the EventDelagate in this case causes far more problems than it helps with. To address that, just change the Start method in UIProgressBar to the following:

  1.         protected void Start ()
  2.         {
  3.                 Upgrade();
  4.  
  5.                 if (Application.isPlaying)
  6.                 {
  7.                         if (mBG != null) mBG.autoResizeBoxCollider = true;
  8.  
  9.                         OnStart();
  10.  
  11.                         // Comment out or remove the following block of code to prevent the event from running.
  12.                         /*if (current == null && onChange != null)
  13.                         {
  14.                                 current = this;
  15.                                 EventDelegate.Execute(onChange);
  16.                                 current = null;
  17.                         }*/
  18.                 }
  19.                 ForceUpdate();
  20.         }
  21.  

Hopefully those help out some people stuck with other similar oddities when working with UIProgressBar and UISlider!

5
They are indeed set to that proper event, however the problem persists. Now my scene does have a series of cameras to have different layered shader effects and the like, so there could be something related to that.

6
In the case of these objects, it's a standard UI setup, and the objects use the EventTrigger component to send the events. Where do I set the Event Type for the objects?

7
Figured out a fix. This can be improved as it doesn't take multiple parent UIPanels into consideration among other things, but it fixes the issue.

In UIScrollView.cs, on line 879, paste the following block of code.

  1.                 // Quick hack implementation of a fix for NGUI failing to clip colliders in UIPanels.
  2.                 UIPanel parentPanel = NGUITools.FindInParents<UIPanel>(gameObject);
  3.                 float panelTop = parentPanel.GetSides(parentPanel.transform)[1].y;
  4.                 float panelBottom = parentPanel.GetSides(parentPanel.transform)[3].y;
  5.                 BoxCollider[] childColliders = GetComponentsInChildren<BoxCollider>();
  6.                 foreach(BoxCollider thisCol in childColliders)
  7.                 {
  8.                         Bounds goBounds = thisCol.GetComponent<BoxCollider>().bounds;
  9.                         float objBottom = parentPanel.transform.InverseTransformPoint(goBounds.min).y;
  10.                         float objTop = parentPanel.transform.InverseTransformPoint(goBounds.max).y;
  11.  
  12.                         thisCol.enabled = (objBottom < panelTop && objTop > panelBottom);
  13.                 }
  14.  

With that, NGUI once again properly culls colliders that are outside of a panel. Hope this helps anyone else plagued with this problem!

8
Bumping this as the issue is causing us to possibly have to redesign our entire UI...

9
This seems to be a problem in all versions of NGUI in Unity 5. When we create an object with a UIPane, and apply Soft Clip, then place objects inside of the panel, the clipping works fine. We can move objects all around, no problem. However - NGUI is now allowing objects that have the UIEventTrigger component and are outside of the clipping zone to still receive OnClick events. This is obviously causing us a bit of a problem, as if we have a draggable list in the middle with buttons above and below it, we cannot click on the buttons above and below as the hidden objects takes the input instead!

Is anyone else seeing this issue as well? Are there any known fixes available? For reference we are running NGUI 3.8.2 in Unity 5.0.1p2, however the issues persists with other combinations of NGUI 3 and Unity 5 as well.

Thank you in advance!

10
That's actually what I did - though in my initial test, I wasn't trying to mask. What I initially wanted to do was just duplicate the shader and get the identical result to the original shader. So I duplicated the shader and changed it's name - but the resulting shader did not function the same as the identical original shader.

11
Thanks ArenMook - that indeed gets the job done! Though when you have a few moments, I would really like to understand why duplicating the original shader did not work. I'm a big baffled on that one and feel like I should really understand why it didn't work.


13
I'm afraid this is still not working for me. I have copy / pasted the contents of the Unlit - Transparent Colored 1 shader into a new shader. Quite literally the only difference between that shader and my shader is the name at the top.

The original:  Shader "Hidden/Unlit/Transparent Colored 1"
Mine:  Shader "Unlit/NGUI Unlit Colored Clip Mask"

When I apply the original shader, it clips fine. When I apply my shader, the clipping fails (see attached image). Since I can't even get a duplicate of the original shader to work here, I'm not sure where to go next. Any continued assistance would be very helpful!

14
I know that similar questions have been asked a hundred times. Reading through them, I can't quite seem to find a solution though for my issue here.

We have a UIScrollView. Inside of it is a grid which contains entries. Each entry has a user photo in a UITexture. However, we want the user photo to be circular. So to make this work, we have a custom shader that uses a second Texture2D as the alpha, allowing the end result to be just a circle.

This works fine in NGUI until we enable Clipping on the UIPanel of the UIScrollView. The result is the UITexture does not clip _AT ALL_. The alpha mask is completely disabled giving us a square image, and when the UITexture is going past the clip edge, it still renders in completely as a full square until the entire UITexture has passed the clipping threshold.

Reading in the forums, it appears I need to have a modified version of the shader Unlit - Transparent Colored which comes with NGUI. So for starters, I simply cloned this shader, and dropped it onto the material for my UITexture. It doesn't work. So I drop the original Unlit - Transparent Colored onto my UITexture. That DOES work. I am very confused as to why the identical shader with nothing changed but the file name and Shader name would fail to function the same as its original.

At this point I am stumped and need assistance. Thank you in advance!

15
NGUI 3 Support / Re: Animating Panel Alpha is Inconsistent
« on: December 11, 2014, 04:55:18 PM »
I had a feeling I was just doing it wrong - that works perfectly! Thanks ArenMook!

Pages: [1] 2