playMaker

Author Topic: FSMEnum problem [SOLVED]  (Read 1105 times)

allender

  • Playmaker Newbie
  • *
  • Posts: 17
FSMEnum problem [SOLVED]
« on: July 04, 2019, 01:06:38 PM »
I have an enum defined as
Code: [Select]
public enum MyEnums: uint
{
    ID1 = 811410733U,
    ID2 = 339470096U
};

In writing a custom editor for this enum (wanting to use Odin's enum picker which is way more user friendly), I'm having trouble assigning the value back to the enum when the choice is made.  I get the MyEnum value back from the picker, and then compare to what I have.  If different I try to assign:

Code: [Select]
            else if (enumVar != currentEnum)
            {
                action.MyEnum = enumVar;
                isChanged = true;
            }

I've tried many different things for the action.MyEnum assignment.  I've tried .Value, .SafeAssign().  No matter what I try, _sometimes_ the code creates exception.  I think it's because the enum is backed as uint instead of int.  The exception is "value was either too large or too small for an Int32".  I've tried all kinds of casting,  but I can't seem to figure out how to make this work correctly.  Any help would be appreciated.
« Last Edit: July 05, 2019, 11:19:20 AM by allender »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: FSMEnum problem
« Reply #1 on: July 05, 2019, 04:28:24 AM »
Hi,

 yes, have you try casting your fsmInt it back to uint before using it as way to get to the enum value?

Bye,

 Jean

allender

  • Playmaker Newbie
  • *
  • Posts: 17
Re: FSMEnum problem
« Reply #2 on: July 05, 2019, 11:19:08 AM »
I have tried all kinds of things with casing.  There are either errors that prevent casting from type int (or uint) to Enum, as well as other similar issues.  I wound up just making the enum a normal int  backed enum.

I may try and come up with a small sample sometime and send it your way, if nothing else as an FYI.