Unity 4.3 - 2D, how to assign programmatically sprites to an object

后端 未结 3 1448
感情败类
感情败类 2021-02-13 18:37

I\'m trying to create an object that will be responsible of creating and showing different sprites, so I would like to access directly the assets/sprites programmatically instea

3条回答
  •  感动是毒
    2021-02-13 19:17

    Just to throw my tuppence worth in. I had this problem when I changed a SerializedField from Texture2D to Sprite in the code. The texture was already a sprite in the editor but it needed to be Sprite in the code. The field in the editor initially said type mismatch and then displayed the sprite texture again. To cure it I set the field in the editor to none and the reset it to the required sprite.

提交回复
热议问题