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

Pages: [1]
1
NGUI 3 Support / Valid Uses for Legacy Anchors
« on: October 10, 2014, 10:37:07 AM »
I came upon the need to use an anchor that didn't impact the size of an NGUI Panel. The position of my anchored object needs to be outside the boundaries of my rendered panel and by attaching a UIWidget, and thereby gaining access to the righteously cool new anchor system, the panel bounds change to include the new widget, which is of course the behavior you want 99.9% of the time. I could move my anchored, non UIWidget object out of the panel group, but for organizational purposes I'd prefer not to.

No complaints here, I'm just saying I need me the old UIAnchor on occasion for it's simplicity. The inspector warning makes it clear I shouldn't use them, but I couldn't come up with a new anchor alternative.

2
LOL, point taken Nicki. As you said, it might not be as bad a switch as I imagine. I'll have to experiment to see.

3
Thanks for sharing that. Most of my projects that use NGUI (meaning all of them ;) look like ArenMook's example. I spent a ton of time just now trying to justify my current project's organizational method. I still can't find a compelling reason to rebuild it all just to bury everything under the same root. My project would be the same mess, i'd just have to open the now singular root it's under to see it all. Of course I'm worried that half way through rebuilding I would run into problems that I can't predict until I've tried it, versus now, everything works great. Again, what would that gain except having to open one root object to see what amounts to the entire game's content?

4
That's funny, I'm having trouble seeing the advantage of only one root then trying to manage 30+ panels and draggable cameras in that single node. Currently, I can turn off a single UIRoot to hide everything associated with the given UI. Maybe it doesn't really make a huge difference either way. It just seems like having this much content buried in a single parent would make working on the separate pieces a nightmare.

Here's a snapshot of my current setup. Each item labeled "scrolling text" is a UIRoot.

5
Forgive me if necro posting is a serious no-no. My searching lead directly here, and the question for the original post wasn't clearly answered (for my humble abilities to comprehend ;) so I figured that staying here would help contain the issue to one place. I'm using version 3.7.2.

I have a project with MANY separate UIRoots with many different layouts and camera behaviors, and ways of layering those cameras. Various UIRoots are turned on and off as the user moves through the experience. From this thread I'm starting to wonder if my methods are somehow flawed, or if I'm missing something obvious about why you wouldn't ever want to use more than one UIRoot construct per scene. That philosophy is implied by making the menu item disabled when a UIRoot is detected. ArenMook indicated that disabling (graying out) the menu item NGUI >> CREATE >> 2D UI or 3D UI was removed, but it is definitely making this menu item unavailable for me when I forget to hide any of my other UIRoots. You'll note that hiding your other UIRoots is any ease work around.

Am I doing something I shouldn't be with my current methods? Why would you ever want to make this menu item unreachable? Is this a feature meant to help new users understand that in most cases you wouldn't want to have more than one UIRoot at a time? (and my project is either unique or flawed)

6
NGUI 3 Support / Re: Best way to resize collider?
« on: November 21, 2013, 10:47:45 AM »
That was an extremely helpful link, thanks! I overlooked the NGUI Documentation thread entirely.

7
NGUI 3 Support / Re: Best way to resize collider?
« on: November 21, 2013, 01:13:21 AM »
I looked for just that. A hint would have been cool. UpdateWidgetCollider? I'm still wobbling around with C# and couldn't find something HERE
This seems to do the trick and replace the earlier code:
NGUITools.UpdateWidgetCollider(gameObject.GetComponent<BoxCollider>());

8
NGUI 3 Support / Re: Best way to resize collider?
« on: November 20, 2013, 06:29:16 PM »
I've rebuilt Malzbier's awesome code to work for the newer version of NGUI's width and height instead. Fair warning, I've only tested pivot left so far!

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. [ExecuteInEditMode]
  5. [AddComponentMenu("NGUI/Helper/ColliderUpdater")]
  6. public class UpdateCollider : MonoBehaviour
  7. {
  8.    
  9.     public Transform targetTransform;
  10.     public BoxCollider cachedCollider;
  11.     public Vector2 sizeoffset = new Vector2 (1, 1);
  12.     public float depth;
  13.        
  14.     /// <summary>
  15.     /// Getting Stuff Cached
  16.     /// </summary>
  17.     void Start ()
  18.     {
  19.         if (targetTransform == null) {
  20.             targetTransform = transform.FindChild ("Background");
  21.         }
  22.         if (this.GetComponent<BoxCollider> () != null) {
  23.             cachedCollider = this.GetComponent<BoxCollider> ();
  24.         }
  25.     }
  26.    
  27.     /// <summary>
  28.     /// Update the possition of the collider according to the size of the target UISlicedSprite.
  29.     /// </summary>
  30.     void Update ()
  31.     {
  32.        
  33.         if (targetTransform != null) {
  34.                         UISprite thisSprite = targetTransform.GetComponent<UISprite> ();
  35.  
  36.                         cachedCollider.size = new Vector3 (sizeoffset.x * thisSprite.width, sizeoffset.y * thisSprite.height, 1);
  37.             cachedCollider.center = targetTransform.localPosition;
  38.                        
  39.             if (thisSprite != null) {
  40.                                
  41.                                 switch (thisSprite.pivot) {
  42.                                 case UIWidget.Pivot.Bottom:
  43.                                         cachedCollider.center += new Vector3 (0, sizeoffset.y * thisSprite.height / -2, depth);
  44.                                     //cachedCollider.center += new Vector3 (0, sizeoffset.y * targetTransform.localScale.y / -2, depth);
  45.                                     break;
  46.                                 case UIWidget.Pivot.BottomLeft:
  47.                                         cachedCollider.center += new Vector3 (sizeoffset.x * thisSprite.width / 2, sizeoffset.y * thisSprite.height / 2, depth);
  48.                                     //cachedCollider.center += new Vector3 (+sizeoffset.x * targetTransform.localScale.x / 2, sizeoffset.y * targetTransform.localScale.y / 2, depth);
  49.                                     break;
  50.                                 case UIWidget.Pivot.BottomRight:
  51.                                         cachedCollider.center += new Vector3 (sizeoffset.x * thisSprite.width / -2, sizeoffset.y * thisSprite.height / 2, depth);
  52.                                     //cachedCollider.center += new Vector3 (sizeoffset.x * targetTransform.localScale.x / -2, sizeoffset.y * targetTransform.localScale.y / 2, depth);
  53.                                     break;
  54.                                 case UIWidget.Pivot.Top:
  55.                                         cachedCollider.center += new Vector3 (0, sizeoffset.y * thisSprite.height / -2, 0);
  56.                                     //cachedCollider.center += new Vector3 (0, sizeoffset.y * targetTransform.localScale.y / -2, 0);
  57.                                     break;
  58.                                 case UIWidget.Pivot.TopLeft:
  59.                                         cachedCollider.center += new Vector3 (sizeoffset.x * thisSprite.width / 2, sizeoffset.y * thisSprite.height / -2, depth);
  60.                                     //cachedCollider.center += new Vector3 (sizeoffset.x * targetTransform.localScale.x / 2, sizeoffset.y * targetTransform.localScale.y / -2, depth);
  61.                                     break;
  62.                                 case UIWidget.Pivot.TopRight:
  63.                                         cachedCollider.center += new Vector3 (sizeoffset.x * thisSprite.width / -2, sizeoffset.y * thisSprite.height / -2, depth);
  64.                                         //cachedCollider.center += new Vector3 (sizeoffset.x * targetTransform.localScale.x / -2, sizeoffset.y * targetTransform.localScale.y / -2, depth);
  65.                                         break;
  66.                                 case UIWidget.Pivot.Left:
  67.                                         cachedCollider.center += new Vector3 (sizeoffset.x * thisSprite.width / 2, 0, depth);
  68.                                         break;
  69.                                 case UIWidget.Pivot.Right:
  70.                                         cachedCollider.center += new Vector3 (sizeoffset.x * thisSprite.width / -2, 0, depth);
  71.                                     //cachedCollider.center += new Vector3 (sizeoffset.x * targetTransform.localScale.x / -2, 0, depth);
  72.                                     break;
  73.                                 case UIWidget.Pivot.Center:
  74.                                         cachedCollider.center += new Vector3 (cachedCollider.center.x, cachedCollider.center.y, depth);
  75.                                     //cachedCollider.center += new Vector3 (cachedCollider.center.x, cachedCollider.center.y, depth);
  76.                                     break;
  77.                                 }
  78.             }
  79.         }
  80.     }
  81. }
  82.  

9
NGUI 3 Support / Re: NGUI 3 - resize handles cannot constrain dimensions?
« on: October 10, 2013, 07:09:25 PM »
I found the new tutorial movies (right after I found my brain). I get it now, you're the man.

If I may be so bold: Holding a modifier key or combination of keys, while performing the click-drag (be that in the inspector Dimensions value or the editor window controls). I'm not sure which modifier keys are unused by Unity. Also, no rush, you have bigger fish to fry, I'm sure.

10
NGUI 3 Support / Re: NGUI 3 - resize handles cannot constrain dimensions?
« on: October 08, 2013, 09:07:35 PM »
I'd like to know if I understand how the newest version of NGUI works. You've swapped out the use of a GameObject's scale in favor of a Widget's Dimensions, although scaling the GameObject still seems to work like before. So instead of using Unity's scale tool, I need to change scale by manually changing the Dimensions value in the inspector or using the new in-editor controls, neither of which seem to be able to maintain the aspect ratio of the values as I change them.

I'm sure there is a brilliant reason for these changes, by the way. I have learned to trust ArenMook for he is wise. It's entirely likely I've overlooked new help material that covers this.

11
NGUI 3 Support / Re: Event Messages being delayed
« on: May 17, 2012, 11:22:33 AM »
This was a valuable conversation for me as the way NGUI and C# works, slowly dawns a bit more every day. I understand where the sighs come from, so I want ArenMook to know, your time was well spent in answering this.

Pages: [1]