Jump to content


GUI Errors with Unity 5.3.0f4


  • Please log in to reply
3 replies to this topic

#1 artofcode

artofcode

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 09 December 2015 - 05:57 PM

I'm getting these warningswhen loading up the project in the latest version of Unity (5.3.0f4)

P4Connect reinitialized
Application unityVersion: 5.3.0f4
P4Connect Initializing: 2015.3.131.1537-Release
P4Connect - Perforce Integration is Active
P4Connect Initializing: 2015.3.131.1537-Release
null texture passed to GUI.DrawTexture
> UnityEngine.GUI:DrawTexture(Rect, Texture)
> P4Connect.Icons:DrawItemIcons(AssetStatus, Boolean, Rect, Boolean) (at c:/tmp/59391429/depot/main/p4-connect/src/P4Connect/P4Connect/P4Connect.Icons.cs:375)
> P4Connect.Icons:DrawItemIcons(String, Rect, Boolean) (at c:/tmp/59391429/depot/main/p4-connect/src/P4Connect/P4Connect/P4Connect.Icons.cs:277)
> P4Connect.Icons:OnProjectWindowItem(String, Rect) (at c:/tmp/59391429/depot/main/p4-connect/src/P4Connect/P4Connect/P4Connect.Icons.cs:168)
> UnityEditor.DockArea:OnGUI()

Where the "null texture passed to GUI.DrawTexture" is being repeated quite a lot of times.
Any idea what this could be?

#2 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 28 January 2016 - 01:35 AM

Hi Nerbert,

Thanks for the snippet above with the warning as an example. I'm checking with one of our developers to see if anyone is familiar with this warning message. We do not have any reported issues with this message. However, I did some research for you online and found this post:

http://answers.unity...rawtexture.html

which suggested to check in Inspector your object to which the script attached. Check all public variable. Also check that the lockPic2 variable had a texture. A different post suggests this indicates that you are missing some icon possibly; or that it comes from calling GUI.DrawTexture with a null value.

Here are some other related posts to the warning message you reported:

https://www.reddit.c...guidrawtexture/

http://answers.unity...ut-not-for.html
http://answers.unity...rawtexture.html
http://www.daikonfor...awtexture.1255/

#3 artofcode

artofcode

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 29 January 2016 - 04:11 PM

Hi,

Thanks for the info. However, from what I can tell from the stack-trace:

null texture passed to GUI.DrawTexture
UnityEngine.GUI:DrawTexture(Rect, Texture)
P4Connect.Icons:DrawItemIcons(AssetStatus, Boolean, Rect, Boolean) (at [...]P4Connect.Icons.cs:375)
P4Connect.Icons:DrawItemIcons(String, Rect, Boolean) (at [...]P4Connect.Icons.cs:277)
P4Connect.Icons:OnProjectWindowItem(String, Rect) (at [...]P4Connect.Icons.cs:168)
UnityEditor.DockArea:OnGUI()

Is that the draw call originates from the Perforce plugin. Since the variables are private, I couldn't look at them directly, but by digging a bit deeper, I managed to get a reference to the private static variables to determine the values. All variables were null, indicating that the icons were never loaded.

This led me to the Initialize function of P4Connect.Icons.Initialize:



public static void Initialize()
{
	string iconsPack = Utils.FullPathToAssetPath(Path.Combine(Utils.GetEditorAssetFullDirectory(), "icons.pack"));
	if (Icons.iconbundle != null)
	{
		Icons.iconbundle.Unload(true);
	}
	Icons.iconbundle = AssetBundle.CreateFromFile(iconsPack);
	if (Icons.iconbundle != null)
	{
		if (Utils.IsRunningUnity5())
		{
			MethodInfo _LoadAllAssets = typeof(AssetBundle).GetMethod("LoadAllAssets", new Type[]
			{
				typeof(Type)
			});
			object result = _LoadAllAssets.Invoke(Icons.iconbundle, new object[]
			{
				typeof(Texture)
			});
			Icons.allTextures = (UnityEngine.Object[])result;
		}
		else
		{
			Icons.allTextures = Icons.iconbundle.LoadAll(typeof(Texture));
		}
		Icons.iconbundle.Unload(false);
	}
	if (Icons.allTextures != null)


Here we can see that it's using the CreateFromFile call, which is deprecated since 5.3.0p1 -- http://docs.unity3d....teFromFile.html
and should be replaced with the LoadFromFile instead. The CreateFromFile method is returning 'null', causing P4Connect to fail to load the status icons.
The same goes for the LoadAll function from AssetBundle (e.g. Icons.allTextures = Icons.iconbundle.LoadAll(typeof(Texture));), which has been replaced with LoadAllAssets.

To work around this, I saw that P4Connect offered to disable the status icons, which seem to prevent the drawcalls from ever being called.

I'd suggest updating the code to use LoadFromFile and LoadAll instead. You should be able to reproduce this bug by running 5.3.0p1 or higher, with the status icons turned on in P4Connect.

Cheers!

#4 P4Norman

P4Norman

    Advanced Member

  • Staff
  • 81 posts
  • LocationOakland CA, USA

Posted 06 April 2016 - 10:25 PM

Thank you for the bug report.  I have reproduced it and have a fix pending.  I needed to add Reflection code to call LoadFromFile() when running in Unity 5.3.0p1 or higher.

https://swarm.worksh.../jobs/job000488

This should be fixed with the 2016.1.137.527 ( patch 2 )
Now available on the Perforce ftp site:   ftp://ftp.perforce.com/perforce/r16.1/bin.multiarch/p4Connect.unitypackage




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users