Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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 :)