Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Texture2D not implemented?

Discussion in 'Scripting' started by Tobias J., Apr 16, 2012.

  1. Tobias J.

    Tobias J.

    Joined:
    Feb 21, 2012
    Posts:
    423
    Hi,

    I have declared a Texture2d like this:

    Code (csharp):
    1. public Texture2D leftBoxBG;
    In my Start() function i try to set the dimensions of it:

    Code (csharp):
    1. leftBoxBG.width = 150;
    2.         leftBoxBG.height = 300;
    But I get an error saying:

    Exception: not implemented
    UnityEngine.Texture.set_width (Int32 value) (at C:/BuildAgent/work/842f9557127e852/Runtime/ExportGenerated/Editor/Graphics.cs:420)
    GuiBuilder.Start () (at Assets/Standard Assets/Scripts/Game/GuiBuilder.cs:49)


    I'm not sure how to understand, much less fix this. I mean, the intelliSense picks up a .width and .height, so I don't get how they could not be implemented?

    Any amount of light-shedding is appreciated!
     
  2. Zethariel1

    Zethariel1

    Joined:
    Mar 21, 2012
    Posts:
    439
    Height and Width are read-only variables. If you want to change your texture, try something like this:

    leftBoxBG = new Texture2D (100,100); // where 100 and 100 are your desired width and height

    EDIT:

    Also, you may want to check this. And the whole Texture2D class in general
     
    Last edited: Apr 16, 2012
  3. Tobias J.

    Tobias J.

    Joined:
    Feb 21, 2012
    Posts:
    423
    oh. I see.
    Thank you!

    Weird exception to throw, though. But I guess it's referring to the operation rather than the member.
     
  4. Zethariel1

    Zethariel1

    Joined:
    Mar 21, 2012
    Posts:
    439
    I believe it was reffering to UnityEngine.Texture.set_width not being implemented, which makes sense as there is no such method/function :)

    You're welcome :)