UnityEngine.Texture2D.LoadImage is missing

Hi,

I noticed that this method is missing because a plugin/asset i’m using is throwing a “method not found” exception.

Texture2D.LoadImage has been removed from 2017.1.0b1 documentation.

Saw nothing in the release note or upgrade guide about this.

So should we stop using this or is there a replacement/rename for the method?

Thanks,

3 Likes

We use this in our project too. Hopefully there’s a replacement if it’s been removed.

Why has it been removed without a better replacement or even any notice?

yes,and the cinemachine cause error also.how to do?

I am wondering this as well, do we get a replacement for this? maybe the long hoped for Async image loading method?

Seems like the bypass for this is using UnityWebRequest.GetTexture

Texture2D.LoadImage has been moved to a Texture2D extension method ImageConversion.LoadImage: Unity - Scripting API: ImageConversion.LoadImage

Since it is an extension method of Texture2D, you can still use it the same way, and any existing code using it, should compile without changes. Compiled code in managed dlls will need updating, but that should be handled automatically by our assembly updater.

Unfortunately, our documentation is not yet good in making extension methods discoverable. This is something the docs team will be working on.

This change was done to untangle dependencies in our code base, to make it more modular and strippable (so that ultimately, you can ship a game which does not include libpng/libjpg when you don’t use them).

6 Likes

As I wrote, the method has been moved to an extension method, but it should work without changes. Are you calling it by reflection for some reason by any chance? (That would indeed break).

Heads up, Cinemachine on 2017.1.0b2 seems to have this problem!

System.MissingMethodException: Method not found: ‘UnityEngine.Texture2D.LoadImage’.
at Cinemachine.Editor.CinemachineSettings…cctor () [0x000dc] in C:\GML\cinemachine\cinemachine-1.1.2\source\Cinemachine.Editor\Windows\CinemachineSettings.cs:234
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes()

I can’t access General Preferences->Cinemachine due to that error being repeated 7 times. Some of the other features still work, I was able to do some work with virtual camreas and timeline. Still though… given the hype around the produce they should probably fix this quick. Sorry, not sure where exactly to report this, i found this thread by search for the error.

So it’s a plugin that uses this. Can you try to reimport it?
If you have plugin sources, recompiling that plugin against most recent UnityEngine.dll should resolve the issue. There is the API compatibility at source code level.