Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Change sprite image in script

Discussion in 'Project Tiny' started by TheFordeD, Jan 28, 2019.

  1. TheFordeD

    TheFordeD

    Joined:
    Jul 9, 2018
    Posts:
    32
    Hi people, and i again need help from you.

    I get index (number of image) from XHR request and i need change current sprite image in current object on index (example: 3).

    I have 9 sprites, how i can load him on game and how i can change this sprites on Sprite renderer object in script

    Necessary changing component in object:
    Screenshot_13.png

    list of sprites in folder:
    Screenshot_14.png
     
    Last edited: Jan 28, 2019
  2. TheFordeD

    TheFordeD

    Joined:
    Jul 9, 2018
    Posts:
    32
    I need load sprite Equals like this code in c# Unity

    Sprite image = Resources.Load<Sprite> (spritesPath + "item_1");
     
  3. TheFordeD

    TheFordeD

    Joined:
    Jul 9, 2018
    Posts:
    32
    How i can do this in Tiny?
     
  4. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    1) Add a sprite reference to a Tiny components
    2) Add component to an entity
    3) Store entity in entity group
    4) Instantiate the group
    5) Get the sprite data from the entity
    6) Set the sprite data on another entity
     
  5. FutureWang

    FutureWang

    Joined:
    May 24, 2018
    Posts:
    22
    there is a project name "FlyingYolk" in TinySamples. If you had import the Sample Projects in your unity, you can see this project in path: "Assets\TinySamples\FlyingYolk" , and your answer is in the class SkinSystem!
     
  6. Zoelovezle

    Zoelovezle

    Joined:
    Aug 7, 2015
    Posts:
    54
    You could reference the sprites in Project Settings > Tiny > Assets
    Similar to Resources.Load you can get them as UT_ASSETS['spritename'] . It returns you base64 encoded image .