Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: stain2319 on May 03, 2020, 02:12:45 PM

Title: Can't get Sprite from Hash Table?
Post by: stain2319 on May 03, 2020, 02:12:45 PM
I am using Unity 2019.3 and ArrayMaker - everything is the latest version - and trying to get a sprite from a hash table but I don't see how it is done...

I have set up a Hash Table Proxy in a gameobject called arrayManager in my scene.

I have the type set to "Sprite" with 1 sprite in there -

(https://i.imgur.com/w9uFkJg.png)

However when I try the "Hash Table Get" option, there is no "Sprite" available.

(https://i.imgur.com/GrJdF4K.png)

"Texture" does not appear to work as I get an error:

The fsmVar value <UnityEngine.Texture2D> doesn't match the value <UnityEngine.Sprite> on stateAdd To Inventory on fsm:FSM on GameObject:Player

How can I get a Sprite out of a hash table?


Title: Re: Can't get Sprite from Hash Table?
Post by: stain2319 on May 03, 2020, 02:29:46 PM
So I found that it does work with Object->UnityEngine->Sprite.  Is this expected?
Title: Re: Can't get Sprite from Hash Table?
Post by: djaydino on May 03, 2020, 03:13:27 PM
Hi.
Yes, Object->UnityEngine->Sprite is correct
Title: Re: Can't get Sprite from Hash Table?
Post by: jeanfabre on May 05, 2020, 03:38:25 AM
Hi,

 for this, I recommend using Resources, your array will reference sprites as their names using strings, and you then use Resources to load that name.

 but I agree this would be a great addition that we could have a new FsmSprite variable.

also, if you want to simply have a texture in the UI, you can use RawImage component, and you can then display a regular texture, that works too, I am using this very often.


Bye,

 Jean
Title: Re: Can't get Sprite from Hash Table?
Post by: LuminRabbit on February 23, 2021, 07:23:38 PM
Thank you guys for the answer and the poster for posting I just stumbled across the same issue glad to see there’s a quick solution :)
Title: Re: Can't get Sprite from Hash Table?
Post by: curb47 on February 24, 2021, 01:16:19 AM
Ummm... what's the difference between a Hash Table and an Array?

Like, under what circumstances would you use a Hash Table, and not an Array?

I don't know what a Hash Table is.
Title: Re: Can't get Sprite from Hash Table?
Post by: djaydino on February 24, 2021, 04:20:58 AM
Hi.
A hash table uses keys to reference (string)
an Array uses index numbers.

Both array list and hash table can be populated with different value types.

in this video i'm using xml with hash tables :

Title: Re: Can't get Sprite from Hash Table?
Post by: curb47 on February 24, 2021, 04:33:30 AM
Hiya,

Okay, thanks. I'll watch the video and learn something new.

J.