playMaker

Author Topic: FSMBool.Value slow due to unboxing  (Read 93 times)

toddprofanegames

  • Playmaker Newbie
  • *
  • Posts: 2
FSMBool.Value slow due to unboxing
« on: September 03, 2024, 04:41:49 PM »
Hello,

In addition to my other post about heap allocations when PlayMakerFSM.Awake is called, I'm also seeing some pretty significant latency due to a frequently run condition which compares FsmBool.Value to a boolean flag, namely the IsTrue method in this custom class:

Code: [Select]
 
[System.Serializable]
  public class BoolTestValue
  {
      [Tooltip("The test will return True if the testVariable has a True value.")]
      public bool TestTrue = true;

      [RequiredField]
      [UIHint(UIHint.Variable)]
      [Tooltip("The Bool variable to check for a True or False value.")]
      public FsmBool testVariable;

      public bool IsTrue()
      {
          return this.testVariable.Value == this.TestTrue;
      }
  }

I've attached a screen shot of the profiler.  This is a worst-case scenario as it doesn't always run this slowly.  That said, if the FSMBool.Value was strongly typed as a boolean this wouldn't be happening.  Is there any alternative to calling FSMBool.Value and therefore NamesVariable.CastVariable which unboxes and runs slowly in a tight loop with a lot of pressure?

Please see the attached profiler screenshot for an example of what I'm dealing with here.