playMaker

Author Topic: Set Enum value via string/index?[SOLVED]  (Read 827 times)

craigz

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Haven Made
Set Enum value via string/index?[SOLVED]
« on: February 12, 2018, 08:10:19 AM »
Wasn't sure if there currently was a way to do this or not...

I'm looking for a way to save current enum values, and best I can find to do is save the index/int for the enum. But then I realized there's no way to actually SET an enum by any value other than an enum.

Could have an int-switch tied to set-enum but that seems like a bit of a workaround. *shrugs* just wasn't sure if there was a better way?

best,

craigz
« Last Edit: February 21, 2018, 11:17:32 PM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13321
  • Official Playmaker Support
    • View Profile
Re: Set Enum value via string/index?
« Reply #1 on: February 19, 2018, 11:46:19 PM »
Hi,

 Good point. Made an action for this on the Ecosystem. Search for "ConvertIntToEnum"



 bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13321
  • Official Playmaker Support
    • View Profile
Re: Set Enum value via string/index?
« Reply #2 on: February 19, 2018, 11:53:58 PM »
Hi,

 and the second one: ConvertStringToEnum



 Bye,

 Jean

craigz

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Haven Made
Re: Set Enum value via string/index?
« Reply #3 on: February 21, 2018, 04:39:55 PM »
BOOM!

As usual Jean, thank you!

You rock :D

-craigz

craigz

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Haven Made
Re: Set Enum value via string/index?[SOLVED]
« Reply #4 on: February 27, 2018, 11:15:19 PM »
So a follow up question, that I feel you might have answered else, couldnt remember if it was a Unity limitation or not.

But would some sort of a 'FSM Enum Switch' or 'FSM Enum Test' action be possible? (similar to how the FSM Bool Test action tests the bool on another without having to have a local data variable made on the object thats doing the testing)

I find myself needing to test if the enum on other game objects is a certain one. And things have been getting cluttered from making duplicate variables on the manager type gameobject just for the purpose of doing 'Get FSM Enum' then followed by 'Enum Switch' etc :)

-craigz

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13321
  • Official Playmaker Support
    • View Profile
Re: Set Enum value via string/index?[SOLVED]
« Reply #5 on: March 01, 2018, 01:55:09 AM »
Hi,

 yes, I'll see if I can work on this action, it should feasible. Can you bump me mis next week if I haven't delivered?

 Bye,

 Jean

craigz

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Haven Made
Re: Set Enum value via string/index?[SOLVED]
« Reply #6 on: March 01, 2018, 08:17:41 AM »
Excellent! :D Thanks Jean! Will do :)

-craigz

craigz

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Haven Made
Re: Set Enum value via string/index?[SOLVED]
« Reply #7 on: March 06, 2018, 05:18:52 PM »
Just an almost mid-week bump ;D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13321
  • Official Playmaker Support
    • View Profile
Re: Set Enum value via string/index?[SOLVED]
« Reply #8 on: March 07, 2018, 02:33:41 AM »
thanks :)

on it!

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13321
  • Official Playmaker Support
    • View Profile
Re: Set Enum value via string/index?[SOLVED]
« Reply #9 on: March 07, 2018, 02:48:55 AM »
Hi,

 ok, done, it's called 'FsmEnumSwitch'

the only bad thing is that you have to manually define the enum type for all your case as there is no mechanism built action to match the type this way.

 Let me know how it works for you.

 Bye,

 Jean

craigz

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Haven Made
Re: Set Enum value via string/index?[SOLVED]
« Reply #10 on: March 07, 2018, 08:34:44 PM »
You rock Jean! :D

This is working perfect! No worries about having to manual set them, still saves a ton of time :D

Thanks for cranking this out, it means a lot to me! :)

-craigz