Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: kiko on August 28, 2017, 11:40:23 AM

Title: Global FSM Array in C# Script doesn't update
Post by: kiko on August 28, 2017, 11:40:23 AM
Hi there! Long time developer, amateur coder. I'm calling a method every few frames that contains this:


Texture2D texture = (Texture2D)Resources.Load("mytexture");

var fow = FsmVariables.GlobalVariables.GetFsmArray("MyColorArray").vector4Values;


...and then I'm applying those values to a texture using this:

      texture.SetPixel(4, 13, fow[0]);
      texture.SetPixel(5, 13, fow[1]);
      texture.SetPixel(6, 13, fow[2]);
      texture.SetPixel(7, 13, fow[3]);
      texture.SetPixel(8, 13, fow[4]);
      texture.SetPixel(9, 13, fow[5]);
      texture.SetPixel(10, 13, fow[6]);

      texture.Apply();


For some reason updated colors in the array won't update on the texture, but if I wiggle the playmaker Global Variables Tab, it WILL update. What am i missing here? Do i need to manually refresh the array in my script somehow? Something else? Thank you for your help!
Title: Re: Global FSM Array in C# Script doesn't update
Post by: jeanfabre on September 19, 2017, 02:51:36 AM
Hi,

 yes, you probably need to call SaveChanges() on the FsmArray. There is an action for this on the Ecosystem if you want to do this inside PlayMaker and not inside your script.

 Bye,

 Jean