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

Pages: 1 [2]
16
NGUI 3 Support / 3.0.8 f7 Exceptions When Selecting Multiple UITextures
« on: January 07, 2014, 02:36:53 PM »
I've been noticing exceptions being thrown in the Editor in a few places. I managed to narrow down one of the causes. If the Inspector is visible and I highlight more than 1 GameObject with a UITexture attached, several errors crop up.

Several from NGUIEditorTools:859
  1. ArgumentException: Getting control 2's position in a group with only 2 controls when doing Repaint
  2. Aborting
  3. UnityEngine.GUILayoutGroup.GetNext () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:512)
  4. UnityEngine.GUILayoutUtility.DoGetRect (Single minWidth, Single maxWidth, Single minHeight, Single maxHeight, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:305)
  5. UnityEngine.GUILayoutUtility.GetRect (Single width, Single height) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:280)
  6. NGUIEditorTools.DrawTexture (UnityEngine.Texture2D tex, Rect rect, Rect uv, Color color, UnityEngine.Material mat) (at Assets/Addons/NGUI/Scripts/Editor/NGUIEditorTools.cs:859)
  7. NGUIEditorTools.DrawTexture (UnityEngine.Texture2D tex, Rect rect, Rect uv, Color color) (at Assets/Addons/NGUI/Scripts/Editor/NGUIEditorTools.cs:796)
  8. UITextureInspector.OnPreviewGUI (Rect rect, UnityEngine.GUIStyle background) (at Assets/Addons/NGUI/Scripts/Editor/UITextureInspector.cs:69)
  9. UnityEditor.Editor.OnInteractivePreviewGUI (Rect r, UnityEngine.GUIStyle background) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorBindings.cs:279)
  10. UnityEditor.Editor.DrawPreview (Rect previewPosition) (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/Inspector/Editor.cs:309)
  11. UnityEditor.InspectorWindow.DrawPreviewAndLabels () (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/Inspector/InspectorWindow.cs:523)
  12. UnityEditor.InspectorWindow.OnGUI () (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/Inspector/InspectorWindow.cs:286)
  13. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

and sometimes another
  1. The targets array should not be used inside OnSceneGUI or OnPreviewGUI. Use the single target property instead.
  2. UnityEditor.DockArea:OnGUI()

17
NGUI 3 Support / Render Q and Non-NGUI Draw Calls
« on: January 06, 2014, 11:34:38 AM »
I'm currently in the process of updating from 2.6.3 to 3.0.8 and I'm running into a little bit of trouble. Our game is fully 2D and we use a series of UIPanels with different Z values to create 'layers'. We use some dynamic, non-atlased UITextures and some ParticleSystems which require the layering things draw in the proper order. In pre-3.0 versions of NGUI this has been dead simple to accomplish. For example, we could have 3 UIPanels: "Panel - Low" at Z = 0, "Panel - Medium" at Z = -10, and "Panel - High" at Z = -20. Then, whenever we needed something that required a new, non-NGUI draw call we just had to make sure it had a Z value above the UIPanel it needed to be drawn above and below the next UIPanel. I don't know how it worked in the background, but everything was automatic. As long as the objects Z value was set appropriately, things drew in the correct order.

Now that we're upgrading to >3.0, this approach appears to have fallen apart. I'm having a hard time obtaining similar functionality as before. The only information I've been able to find so far basically says to create custom shaders for everything that lets us set the render queue for non-NGUI objects. We'll go this route if we have to, but I'd rather skip messing with shaders for now and just have a simple system like we had before.

This leads me to a few questions:

  • Is there any built-in way to see render queue on stuff in the editor? I'm assuming from this post that there is not, and I'll have to modify the shaders we're using. We're using the ones included with NGUI, so I'll have to re-modify them each time we update, which is an annoyance.
  • How did it work automatically before? This documentation page mentions that everything except the Geometry queue is ordered by distance from the camera, so I suspect this is how it was able to order UIPanels and ParticleSystems automatically in the past. Maybe the new NGUI system interferes with this.
  • What is the correct way to handle this sort of layering in NGUI now?
  • Most importantly, is there a simple way to make this automatic again?

18
NGUI 3 Support / Possible Bug In NGUITools.SetActiveChildren (2.6.3)
« on: June 27, 2013, 01:34:53 PM »
In certain circumstances NGUITools.SetActiveChildren will recursively enable objects in Unity 4.0+.

NGUITools.SetActiveChildren(gameObject, true) will call NGUITools.Activate() which contains the following:

  1. static void Activate (Transform t)
  2. {
  3.         SetActiveSelf(t.gameObject, true);
  4.         // Prior to Unity 4, active state was not nested. It was possible to have an enabled child of a disabled object.
  5.         // Unity 4 onwards made it so that the state is nested, and a disabled parent results in a disabled child.
  6. #if UNITY_3_5
  7.         for (int i = 0, imax = t.GetChildCount(); i < imax; ++i)
  8.         {
  9.                 Transform child = t.GetChild(i);
  10.                 Activate(child);
  11.         }
  12. #else
  13.         // If there is even a single enabled child, then we're using a Unity 4.0-based nested active state scheme.
  14.         for (int i = 0, imax = t.childCount; i < imax; ++i)
  15.         {
  16.                 Transform child = t.GetChild(i);
  17.                 if (child.gameObject.activeSelf) return;
  18.         }
  19.  
  20.         // If this point is reached, then all the children are disabled, so we must be using a Unity 3.5-based active state scheme.
  21.         for (int i = 0, imax = t.childCount; i < imax; ++i)
  22.         {
  23.                 Transform child = t.GetChild(i);
  24.                 Activate(child);
  25.         }
  26. #endif
  27. }

Notice that if !UNITY_3_5 and all children of the transform are activeSelf == false, the final for loop is executed. For example, in the following hierarchy:

  1. Parent (active)
  2.         Child (inactive)
  3.                 Subchild (inactive)
  4.  

If NGUITools.SetActiveChildren(Parent, true) is called, both Child and Subchild will be enabled. Obviously, this can occur recursively to any depth.

19
NGUI 3 Support / Changing UITextures at runtime
« on: June 12, 2013, 03:06:41 PM »
I've run into a bit of a problem using UITextures and hoping someone can point me in the right direction. I'm instantiating 6 copies of a prefab with a UITexture on it. Then I'm choosing which texture should be used on each item, of which there are 2 placeholder textures and the rest are downloaded from the internet. What I'm seeing is things working precisely as I expect for a while, but then after running the game enough times in the editor, changing the texture on one instance causes all of the other instances to change too. I'm trying to prevent this from happening.

I'm guessing it has something to do with the materials being used for the UITextures. Possibly that they all have the same material. However, I thought UITextures generated their materials automatically.

Some extra info: the prefab has the Unlit/Transparent Colored shader assigned. The prefab does not have any texture assigned (though I noticed the prefab actually get's updated based on which textures are set at runtime, odd). I'm using mUITexture.mainTexture = downloadedTexture to change the textures.

20
NGUI 3 Support / Occasionally Skipping A Tween
« on: March 06, 2013, 04:15:47 PM »
I'm having a bit of trouble accomplishing something with tweening. I use a generic script from my in game windows with a Hide and Show method that tweens the windows in and out. (from .1 to 1 scale when Show, and reversed in Hide). Occasionally, I want to Show a window, but not have it tween, and I need to accomplish this is such a way that it doesn't interfere with any future Show or Hide calls.

Is there a recommended way to handle this?

For reference, here's what I have currently:

  1. using UnityEngine;
  2.  
  3. [RequireComponent(typeof(TweenScale))]
  4. public class TweenedWindow : MonoBehaviour
  5. {
  6.         public bool tweenOnAwake;
  7.         public bool destroyOnHide;
  8.  
  9.         private UITweener tweener;
  10.  
  11.         private void Awake ()
  12.         {
  13.                 tweener = GetComponent<UITweener>();
  14.  
  15.                 if ( !tweenOnAwake )
  16.                 {
  17.                         tweener.enabled = false; //This breaks subsequent tweens
  18.                 }
  19.         }
  20.  
  21.         private void Show ()
  22.         {
  23.                 tweener.Play(true);
  24.         }
  25.  
  26.         public void Hide ()
  27.         {
  28.                 if ( destroyOnHide )
  29.                 {
  30.                         tweener.onFinished += Destroy;
  31.                 }
  32.  
  33.                 tweener.Play(false);
  34.         }
  35.  
  36.         private void Destroy ( UITweener twnr )
  37.         {
  38.                 GameObject.Destroy(gameObject);
  39.         }
  40. }
  41.  

Pages: 1 [2]