Forum rules - please read before posting.

Get the main graphic item as Sprite in code

Hi! I want to get the texture as sprite of the main graphic item. Is it possible to do in a easy way?

items = AC.KickStarter.player.Inventory.InvItems;
selected.sprite = items[indexSelected].tex; (I need a sprite here)

Thanks!

Comments

  • You can generate a new sprite from a texture with code:

    Texture2D itemTexture = items[indexSelected].tex;
    Sprite sprite = Sprite.Create (itemTexture, new Rect (0f, 0f, itemTexture.width, itemTexture.height), new Vector2 (0.5f, 0.5f));
    
  • Thanks Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.