Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    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 :)