playMaker

Author Topic: Global FSM Array in C# Script doesn't update  (Read 1209 times)

kiko

  • Playmaker Newbie
  • *
  • Posts: 17
Global FSM Array in C# Script doesn't update
« 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!
« Last Edit: August 28, 2017, 11:43:47 AM by kiko »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Global FSM Array in C# Script doesn't update
« Reply #1 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