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

Pages: [1] 2 3 4
1
NGUI 3 Support / Re: Panel tool isn't sorted alphabetically
« on: March 14, 2014, 01:40:48 PM »
Thanks, will do!

2
NGUI 3 Support / Re: Panel tool isn't sorted alphabetically
« on: March 14, 2014, 11:27:54 AM »
Of course.  I manage my "top level" panels (all depth=1) using show/hide so that never happens.  If there's a sub-panel or overlay it'll always have a higher depth to ensure it appears in front of the panel that is its parent.  I don't depend on panel depth to determine which panel is showing.

So I guess this comes down to how one manages their panels.  Given my setup, I'm going to put the alphabetical compare back in, since it's getting hard for me to find panels in the list.

I think that others who use a system like UIWindow to manage their top level panels will have a similar situation.  Perhaps alphabetical sorting could be made an optional addition, i.e. clicking on the Panel Tool's "Panel Name" header sorts on that, or clicking on the "DP" header sorts on depth?

3
NGUI 3 Support / Re: Panel tool isn't sorted alphabetically
« on: March 14, 2014, 10:54:47 AM »
It's never a good idea to leave panels using the same depth. I'll fix the comment, but adding a change that makes them sort alphabetically is a mistake as it may change the order of existing UIs where people also didn't specify unique depth values. Furthermore, instance IDs can change and are unreliable -- another reason why it's important to give your panels unique depth values.

Actually, I'm not understanding this.  Why is it never a good idea to leave panels using the same depth?  I'm using UIWindow's Show(), Hide(), and GoBack() functions to turn panels on and off.  I've got all my panels set to depth 1 (with contained subpanels at higher depths), and it's working great.  Am I asking for trouble somehow?  I don't see what the problem is.

4
NGUI 3 Support / Re: Panel tool isn't sorted alphabetically
« on: March 14, 2014, 10:46:58 AM »
Fair enough, but the next question is why should the Panel Tool use the same sort algorithm as panels sorted in a scene at runtime?  Maybe there needs to be a simple alphabetical sort for the Panel Tool, while keeping the non-alphabetized version for other uses.

5
NGUI 3 Support / Panel tool isn't sorted alphabetically
« on: March 14, 2014, 10:05:35 AM »
Using NGUI 3.5.3, Unity Pro, Win 7.

In looking at UIPanelTool.cs, line 124, the comment says the panel tool's entries should be being sorted alphabetically.  However, the sort function is comparing using UIPanel.CompareFunc(), which apparently defaults to sorting based on panel depth and then GetInstanceID(), and does no alphabetical comparison.  It would be far more useful (to me anyway) if the panels of the same depth were actually sorted alphabetically before resorting to using the instance IDs.

I propose changing UIPanel.cs to use this updated CompareFunc():

  1.         /// <summary>
  2.         /// Function that can be used to depth-sort panels.
  3.         /// </summary>
  4.  
  5.         static public int CompareFunc (UIPanel a, UIPanel b)
  6.         {
  7.                 if (a != b && a != null && b != null)
  8.                 {
  9.                         if (a.mDepth < b.mDepth) return -1;
  10.                         if (a.mDepth > b.mDepth) return 1;
  11.                         int sortRet = string.Compare(a.name, b.name);
  12.                         if (sortRet != 0) return sortRet;
  13.                         return (a.GetInstanceID() < b.GetInstanceID()) ? -1 : 1;
  14.                 }
  15.                 return 0;
  16.         }
  17.  

I have tested this and it seems to work fine here.

6
Thanks, I will try adding UICamera to my main camera as you suggest.  Hadn't really considered that. :)

7
What is the recommended way of dealing with scene object selection?

If I use Unity's OnMouseOver(), OnMouseDown(), etc. then I don't know if there is any way you disable those events when the player is "supposed" to be interacting with a UI panel.

How do I keep my clicks EITHER in my gui panel, OR on scene objects?

8
NGUI 3 Support / Re: UISlider OnValueChange events
« on: February 23, 2014, 09:29:47 PM »
Thanks Michael.  Your code almost worked, but failed due to floating point compare error.  Rounding fixed it.  I figured that since there can't be more than 20 steps, it was safe enough to compare after multiplying the floats by 1000 and then casting to int.  Here's the updated code FYI:

  1.     public float value
  2.     {
  3.         get
  4.         {
  5.             if (numberOfSteps > 1) return Mathf.Round(mValue * (numberOfSteps - 1)) / (numberOfSteps - 1);
  6.             return mValue;
  7.         }
  8.         set
  9.         {
  10.             float val = Mathf.Clamp01(value);
  11.  
  12.             if (mValue != val)
  13.             {
  14.                 int before = (int)Mathf.Round(this.value * 1000);
  15.                 mValue = val;
  16.  
  17.                 if (NGUITools.GetActive(this))
  18.                 {
  19.                     if (before != Mathf.Round(this.value * 1000))
  20.                     {
  21.                         if (EventDelegate.IsValid(onChange))
  22.                         {
  23.                             current = this;
  24.                             EventDelegate.Execute(onChange);
  25.                             current = null;
  26.                         }
  27.                         ForceUpdate();
  28.                     }
  29. #if UNITY_EDITOR
  30.                     if (!Application.isPlaying)
  31.                         NGUITools.SetDirty(this);
  32. #endif
  33.                 }
  34.             }
  35.         }
  36.     }
  37.  

9
NGUI 3 Support / Re: UISlider OnValueChange events
« on: February 23, 2014, 01:54:39 PM »
It matters because I'm using the slider to control a character avatar editor.  Every time the value changes I need to rebuild the avatar from its many various components, which is expensive.

I tried using the UIProgressBar.value as you suggested, but it still updates the same number of times.

I still don't understand why the value change event is triggered in this case.  The idea of a stepped value on the control implies that if the value doesn't change the event shouldn't be triggered.

10
NGUI 3 Support / Re: UISlider OnValueChange events
« on: February 23, 2014, 12:25:36 PM »
Thanks.  Okay, so then how can I only trigger events when the value steps up?  I don't want events happening for irrelevant changes.

11
NGUI 3 Support / UISlider OnValueChange events
« on: February 22, 2014, 11:14:32 PM »
I've got a UISlider, set to have some number of discrete steps.  When I drag the slider, why am I getting multiple OnValueChange events triggering, even if the drag doesn't actually change the UISlider's value to a new step?  How can I keep those events from triggering in all cases where the value hasn't actually changed?

Thanks!

12
NGUI 3 Support / Re: how to set scrollview child's position?
« on: February 13, 2014, 02:34:43 AM »
Thanks for the tip about NGUITools.AddChild().  I don't think that's the problem, but it looks like a helpful function anyway.

In any case, in my post I guess I didn't make it clear that the selected button IS being clipped.  The problem is how do I keep the grid in position so the selected button is visible?


13
NGUI 3 Support / how to set scrollview child's position?
« on: February 12, 2014, 02:04:59 PM »
I have a UIScrollView on a panel, set to Vertical movement.  The scroll view has one child, which is a (draggable) UIGrid containing a dynamic list of buttons.  The UIGrid and all its children (the buttons) have UIDragScrollView components on them.  Vertical dragging/scrolling is working fine.

When I make dynamic changes to the button list (i.e. adding new buttons at runtime via code), I call Reposition() on the grid.  However, sometimes the particular button that I want to show as "selected" (it has an extra glow around it) is outside the bounds of the clipping panel.  How can I ensure that a particular button is showing after Reposition()?

Again, here's my object setup:
-panel/scrollview
-- grid
--- button
--- button
--- button
--- button
--- (etc.)

14
NGUI 3 Support / Re: UIDragScrollView anchor in one direction only?
« on: February 12, 2014, 11:10:32 AM »
Wow.  I've been struggling with this issue for weeks, and one minute after I post the question I figure out the solution.

For others with this same question, the solution is Advanced anchoring.  The key is to anchor the Left and Right to the scrollview, but set the Bottom and Top anchors to None.

Happy anchoring!

15
NGUI 3 Support / UIDragScrollView anchor in one direction only?
« on: February 12, 2014, 11:06:44 AM »
I have a UIScrollView on a panel, set to Vertical movement.  The scroll view has one child, which is a UIGrid containing a dynamic list of buttons.  The UIGrid and all its children (the buttons) have UIDragScrollView components on them.

Vertical scrolling is working fine.  The problem is that I can't figure out how to position the grid horizontally without using absolute pixel position (which makes the grid off-center in the scroll view when the main game window is resized).

What I'd like to do is anchor the grid to the parent scrollview horizontally, while letting it still be draggable vertically.  Is there a way to apply an anchor in one direction only?

Pages: [1] 2 3 4