Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

UnityEngine.Texture2D.LoadImage is missing

Discussion in '2017.1 Beta' started by fpilote, Apr 20, 2017.

  1. fpilote

    fpilote

    Joined:
    Jul 19, 2013
    Posts:
    5
    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,
     
    CWolf and MrEsquire like this.
  2. CWolf

    CWolf

    Joined:
    Oct 24, 2011
    Posts:
    106
    We use this in our project too. Hopefully there's a replacement if it's been removed.
     
  3. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Why has it been removed without a better replacement or even any notice?
     
  4. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    CENE.png yes,and the cinemachine cause error also.how to do?
     
    Last edited: Apr 24, 2017
  5. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    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
     
    Last edited: Apr 24, 2017
  6. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Texture2D.LoadImage has been moved to a Texture2D extension method ImageConversion.LoadImage: https://docs.unity3d.com/2017.1/Documentation/ScriptReference/ImageConversion.LoadImage.html

    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).
     
  7. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    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).
     
  8. haskins

    haskins

    Joined:
    Oct 11, 2013
    Posts:
    24
    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.
     

    Attached Files:

  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
  10. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    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.