Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: hunter on March 19, 2019, 05:37:05 PM

Title: Recreating a Sprite to Match Thumbnail [SOLVED]
Post by: hunter on March 19, 2019, 05:37:05 PM
Hi there! Let me start by saying I'm sure there's a fairly easy solution to what I'm trying to do here, I just for the life of me can't find it.

I have a series of thumbnail image that I'm generating with a series of randomized layers (body, pants, top, face, hair, etc...) When the user clicks on one of these thumbnails, a full screen image of the pictured character will slide in.

What I'm trying to do is have the full-screen picture get the sprite textures that were assigned to the thumbnail, then set them on the full-screen image before it slides in.

So I added a "UI Image Get Sprite" action, and here's where I hit a snag. After I define the Game Object I want to look at, how do I make it load the image sprite?

I feel like there's something I'm misunderstanding, so any advice / points in the right direction would be hugely appreciated!
Title: Re: Recreating a Sprite to Match Thumbnail
Post by: jeanfabre on March 20, 2019, 03:27:20 AM
Hi,

 you use UiImageSetSprite action. Is that not working?

BYe,

 Jean
Title: Re: Recreating a Sprite to Match Thumbnail
Post by: djaydino on March 20, 2019, 04:56:10 AM
Hi.
You probably need some (2 or more) arrays.

1 array with the game objects. and 1 with the sprite (thumbnail) images.

Element index from the 2 arrays should match. (if element 0 = pants game object on the game object array, then element 0 on sprite array should be the pants sprite (thumbnail).


after defining a Game Object, use 'Array Contains' and store the index.
use that index with 'Array Get' to get the sprite from the sprite array.

Then you can use UiImageSetSprite.

here is a tutorial about arrays :

Title: Re: Recreating a Sprite to Match Thumbnail
Post by: hunter on March 20, 2019, 11:48:51 AM
Thanks for the info!

After playing around a bit with my setup, and then watching a few more tutorials on arrays, I've decided on a new workflow that seems to be working so far!

I'm having my random look generation store to an array, and then I'm having both the thumbnail and the full image pull from that array when rendering their images. This sort of bypasses the initial issue of having to retrieve the defined images from the thumbnail, but it also just feels like a better workflow.

Just in case this is helpful to anyone down the road, I also switched to the Raw Image script on my visuals, so I can just deal with textures (which seem to be easier to work with because you can store them directly in arrays).

Thanks Jean & djaydino for taking the time to respond! 
Title: Re: Recreating a Sprite to Match Thumbnail
Post by: djaydino on March 20, 2019, 12:50:38 PM
Hi.
Sprites can be stored also directly in arrays :)  (along with other components).

Select array type  : object
Then you will get a new line called Object Type.

Click on it and select UnityEngine/Sprite.
Title: Re: Recreating a Sprite to Match Thumbnail
Post by: hunter on March 20, 2019, 02:17:58 PM
@djaydino

Ah ha! That clears up so much!

I kept reading 'object' in articles & posts and I assumed they meant Game Object. Now that I see the Object class & the Object Type option, you've opened up a whooooole new world. Thanks a ton!

Title: Re: Recreating a Sprite to Match Thumbnail [SOLVED]
Post by: djaydino on March 20, 2019, 07:47:17 PM
Hi.
Np, happy to help!