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

Pages: [1] 2
NGUI 3 Support / Re: NullReferenceException - UIPanel cachedTransform
« on: June 12, 2017, 05:42:03 AM »
Yeah, that is good advice alright, unfortunately not something we can do in this instance. Hopefully this thread is useful for others who encounter the issue too.

NGUI 3 Support / Re: NullReferenceException - UIPanel cachedTransform
« on: June 08, 2017, 11:40:55 AM »
Ok, so I finally have a solution. I found other people had the same issue before (not sure how I didn't see the threads before), namely this one.

Applying the fix mentioned in that thread fixed the issue. However, the same sort of issue started happening if no UIPanel was shown in Scene A before Scene B. So to fix that issue, I call the following code when Scene A is loaded and then again when Scene B is unloaded. Both these fixes together seem to have solved the issue for us.

  1. private void ResetPanelDrawCalls()
  2. {
  3.         // Release inactive draw calls
  4.         UIDrawCall.ReleaseInactive();
  6.         // Set the Panel as dirty so draw calls are rebuilt
  7.         _screenUIPanel.SetDirty();
  8. }

There is definitely something wonky going on when loading scenes with Addictive Loading, but Addictive Loading is required for us to smoothly load the game so dropping it was not an option. Hopefully this is of some use to others encountering the issue. I hope I never see this issue again :(

NGUI 3 Support / Re: NullReferenceException - UIPanel cachedTransform
« on: June 07, 2017, 11:40:49 AM »
After further work on this, I don't think ImmediatelyCreateDrawCalls is going to do the trick. I've tried calling it on the UI Root in Scene A after the UIPanel is destroyed, I have also tried calling it on the UIRoot in Scene B during Awake, Start etc and the issue still occurs (plus it also moves the UIRoot for some reason). I have also tried it on the UIPanel in Scene B that the exception is thrown on, but again it does not fix the issue.

What I find very interesting is that minimising the app and bringing it back to the foreground fixes the issue. I'm not sure why that is, nor can I see any NGUI code been executed in OnApplicationPause that could be fixing the issue. Have you any idea why this works or is it just a Unity engine doing stuff in the background?

So instead I have tried calling Refresh() and RebuildAllDrawCalls() for the UIPanel which the exception is thrown on.

NGUI 3 Support / Re: NullReferenceException - UIPanel cachedTransform
« on: June 06, 2017, 10:13:21 AM »
One thing we have discovered is that when the issue occurs, minimising the app (I should have mentioned this is an iOS app) and bringing it back to the foreground fixes the issue. So perhaps I need to call ImmediatelyCreateDrawCalls at a different time.

So I was hoping to apply a quick fix by simply removing the UIPanel A and then investigate the issue at a future date when not restricted to a deadline. But it appears the issue can occur if any UIPanel is created and destroyed in Scene 1 before loading Scene 2, so I'll be investigating this more and will update this thread in case it's useful for others in the future.

NGUI 3 Support / Re: NullReferenceException - UIPanel cachedTransform
« on: June 06, 2017, 08:20:42 AM »
Unfortunately that did not work, it produces the same error.

NGUI 3 Support / Re: NullReferenceException - UIPanel cachedTransform
« on: June 06, 2017, 03:46:00 AM »
I will give that a go and report back, thanks.

NGUI 3 Support / NullReferenceException - UIPanel cachedTransform
« on: May 26, 2017, 11:43:20 AM »

We are getting a NullReferenceException when the UIPanel attempts to get the cached transform. This only happens under certain conditions. This is the Exception:

  1. NullReferenceException
  2.   at UnityEngine.Component.get_transform () [0x00000] in <filename unknown>:0
  3.   at UIPanel.LateUpdate () [0x00000] in <filename unknown>:0

The only way I can get the issue to happen is if I show UIPanel A in Scene 1, destroy UIPanel A and then load Scene 2 (via additive), it will trigger the exception on another UIPanel in Scene 2 (always the same UIPanel, perhaps because it's first child of UIRoot). I have confirmed that UIPanel A is destroyed before Scene 2 is loaded, and that there are no objects referencing it (or it's  children). I see nothing wrong with UIPanel A, I can display it within Scene 2 and destroy it without any issue, likewise in Scene 1 (before loading Scene 2). There is no relation between the UIPanels involved in this scene either.

Once Scene 2 is loaded, Scene 1 is unloaded and both scenes have their own UIRoot, so that means for a short while, both scenes are active, and thus there are 2 active UIRoots. Is there a potential issue with having 2 UIRoots present (all be it in different scenes) at the same time? This problem is a bit of a headache, because the exception is thrown every update after it occurs and essentially breaks everything NGUI related.

We are using NGUI 3.11.1 (we can't upgrade due to the sorting changes which breaks stuff for us) and Unity 5.5.1.p1.


NGUI 3 Documentation / Re: UIPopupList
« on: June 24, 2016, 03:48:53 AM »
Great, thanks!

NGUI 3 Documentation / Re: UIPopupList
« on: June 22, 2016, 06:13:50 AM »
Hey, I've noticed an issue with the Popuplist inspector. If I remove the reference to an UIAtlas, the options appear to use individual sprites like you implemented above. However, if I select another object, and then go back to the UIPopuplist, the reference to the UIAtlas is returned and is no longer null. The same happens after resetting the component.

I've uploaded a gif to demonstrate the issue.

I'm on version 3.9.9 but this issue may have been happening before, I've only noticed it now

NGUI 3 Documentation / Re: UIPopupList
« on: January 26, 2016, 05:00:25 AM »
You can just change the UISprite's references within UIPopupList to something else if you like. Assuming you want to use UI2DSprites?

Edit: I've gone ahead and added support for 2D sprites. Replace UIPopupList.cs and UIPopupListInspector.cs files with these.

I had gone ahead and rolled my own solution, but this is much better, thanks! One modification I did make which I think would be useful to add is the ability to set the drop-down list panel's sorting layer in the UIPopuplist inspector, as it currently defaults to "Default" which may be behind the sorting layer of the panel which creates the drop-down list.

Anyway, thanks again!

NGUI 3 Documentation / Re: UIPopupList
« on: January 22, 2016, 10:26:34 AM »
Is there anyway to specify a non-UIAtlas sprite for the drop down?

NGUI 3 Support / New TexturePacker feature
« on: December 02, 2015, 05:57:54 AM »

TexturePacker have released a new polygon packing mode which is fantastic for creating tightly packed sprite sheets and actually optimizes the sprite meshes resulting in better performance. You can read their post on the Unity forums about it. This works for SpriteRenderers, but obviously not for UI2DSprite. I think it'd be great if NGUI could support this, it would probably require having a sprite rendered similarly to how SpriteRenderers are.

I understand this isn't a trivial task, nor am I suggesting you do it now, but just thought I'd bring your attention to it and maybe it could be something to consider for NGUI 4 or NGUI 5 :D

NGUI 3 Support / Re: NGUI, 4.3 and new Sortyng Layers
« on: November 26, 2015, 04:37:32 AM »
Oh cool! Glad I could help :)

NGUI 3 Support / Re: NGUI, 4.3 and new Sortyng Layers
« on: November 25, 2015, 08:03:47 AM »
Is there any update on this? I think this is a very important feature and surprised it's not added yet. Even more so when it can be added relevantly quickly to support it at a Panel level (which I think is all that is required, as you would expect everything on a UIPanel to be drawn on the same layer.

I've edited NGUI's code to support it, but I just know someday I will forget to put the edits back in after an update. For those interested, this is my code to show a dropdown for sorting layers in UIPanel inspector (using the latest NGUI version).

In UIPanelInspector.cs, line 9 add:
  1. using UnityEditorInternal;
  2. using System.Reflection;
  3. using System;

In UIPanelInspector.cs, line 458 add:
  1.         GUILayout.BeginHorizontal();
  2.         {
  3.             EditorGUILayout.PrefixLabel("Sorting Layer");
  5.             // Get the names of the Sorting layers
  6.             System.Type internalEditorUtilityType = typeof(InternalEditorUtility);
  7.             PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
  8.             string[] names = (string[])sortingLayersProperty.GetValue(null, new object[0]);
  10.             int index = 0;
  11.             if (!String.IsNullOrEmpty(mPanel.mSortingLayer))
  12.             {
  13.                 for (int i = 0; i < names.Length; i++)
  14.                 {
  15.                     if (mPanel.mSortingLayer == names[i])
  16.                     {
  17.                         index = i;
  18.                         break;
  19.                     }
  20.                 }
  21.             }
  23.             // Get the selected index and update the panel sorting layer if it has changed
  24.             int selectedIndex = EditorGUILayout.Popup(index, names);
  25.             if (index != selectedIndex)
  26.             {
  27.                 mPanel.mSortingLayer = names[selectedIndex];
  28.                 EditorUtility.SetDirty(mPanel);
  29.             }
  30.         }
  31.         GUILayout.EndHorizontal();

In UIDrawCall.cs, line 130 add:
  1.     public string sortingLayerName
  2.     {
  3.         get { return (mRenderer != null) ? mRenderer.sortingLayerName : ""; }
  4.         set { if (mRenderer != null && mRenderer.sortingLayerName != value) mRenderer.sortingLayerName = value; }
  5.     }

In UIPanel.cs, line 97 add:
  1.     /// <summary>
  2.     /// The sorting layer for this panel, used to work with Unity 2D system
  3.     /// </summary>
  4.     public string mSortingLayer = "";

In UIPanel.cs, line 263 add (this could potentially be optimised?):
  1. dc.sortingLayerName = mSortingLayer;

Now you should have a dropdown for your UIPanels to select the sorting layer it should be drawn on.

NGUI 3 Support / Re: NGUI, 4.3 and new Sortyng Layers
« on: April 09, 2015, 05:38:23 AM »
Yeah, I ended up having to roll my own solution (annoying when you are updating NGUI though) as setting the game layer made no difference. Seems like an important feature to have, but doesn't seem like many people have encountered this.

Pages: [1] 2