playMaker

Author Topic: UI Image Set Sprite  (Read 3359 times)

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
UI Image Set Sprite
« on: December 03, 2018, 08:23:48 PM »
Hi,
I tried to change ui image with 'UI Image Set Sprite' action and using sprite variable, but I got this error:
Quote
InvalidCastException: Specified cast is not valid.
HutongGames.PlayMaker.Actions.UiImageSetSprite.DoSetImageSourceValue () (at Assets/PlayMaker/Actions/UI/UiImageSetSprite.cs:52)

It was fixed when I changed to line this line:
Code: [Select]
image.sprite = (Sprite)sprite.Value;To
Code: [Select]
image.sprite = sprite.Value as Sprite;
I just thought I would mention this in case it's a problem in the action.
I'm using Unity 2018.2.16f and Playmaker 1.9.0

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: UI Image Set Sprite
« Reply #1 on: December 04, 2018, 12:53:48 AM »
Hi,

 it all works fine here:



is it from a project you have upgraded or something?

Bye,

Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: UI Image Set Sprite
« Reply #2 on: December 04, 2018, 12:55:13 AM »
Hi,

 ok, I get it, it's because your variable has no sprite attached!

I'll report this and we'll change it for the next update.

Bye,

 Jean
« Last Edit: January 25, 2019, 01:57:35 AM by jeanfabre »

strange_aeons

  • Junior Playmaker
  • **
  • Posts: 62
Re: UI Image Set Sprite
« Reply #3 on: January 25, 2019, 12:11:23 AM »
ive run into this error also, unable to change the sprite on a ugui image. making that adjustment to the code makes the error go away, but image displays no sprite. i am using unity 2017.21f1 with playmaker 1.8.3, will upgrading playmaker fix the problem?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: UI Image Set Sprite
« Reply #4 on: January 25, 2019, 01:58:26 AM »
Hi,

yes it will.

 Bye,

 Jean

strange_aeons

  • Junior Playmaker
  • **
  • Posts: 62
Re: UI Image Set Sprite
« Reply #5 on: January 25, 2019, 07:35:12 PM »
hi Jean, i have updated to the latest version of Playmaker and it seems that the action plays FSM no long gets stuck on that action, but i still get the same error and the ui image does not change. i also try the set property action and there is no change.

the image does change if i select one directly, rather than getting the image from an array. so maybe i wont look up images from array
« Last Edit: January 25, 2019, 07:53:33 PM by strange_aeons »

strange_aeons

  • Junior Playmaker
  • **
  • Posts: 62
Re: UI Image Set Sprite
« Reply #6 on: January 25, 2019, 08:34:55 PM »
i added Arraymaker and tried with that and it works how i need it to, button gets the sprite (object) from the arraymaker array and replaces ugui image sprite :)  im not sure why it doesnt like the standard Playmaker Arrays tho, also "Array Get" action only gets float variables and cannot be set to any other type of variables, so its not very useful like that.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: UI Image Set Sprite
« Reply #7 on: January 28, 2019, 12:51:22 AM »
Hi,

 How did you populate the Array in the first place, maybe you have a race condition if you have added the sprite to the array and straight away try to use it. in this case you need to call SaveChanges on the array ( from the Ecosystem).

Bye,

 Jean