playMaker

Author Topic: Populating an array from a C# script  (Read 2673 times)

unclebob

  • Playmaker Newbie
  • *
  • Posts: 25
Populating an array from a C# script
« on: September 17, 2014, 10:47:22 AM »
Hi

I have a situation where I want to populate an array with data that has been gathered and stored from a C# script very like the one below.

}
DirectoryInfo dir = new DirectoryInfo(Application.persistentDataPath);
FileInfo[] images = dir.GetFiles("*.png");
foreach (FileInfo f in images)
{

I know how to pass individual items to an FSM using for instance:

FsmVariables.GlobalVariables.GetFsmString("tess").Value = Storedstring;

But is there a simple method of doing this with arrays?  My brain has stopped working hence the need for pointers.  ???

So far I have created a "Game Object" variable and set it to Object Type PlayMakerArrayListProxy and set the Object Value to the Object the Proxy is on "Data".

I have also read that

public PlayMakerArrayListProxy myArrayListProxy;

Gives visibility in C#

But when your brain starts hurting we all know we should ask for help so...help please!

Thank you in advance.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Populating an array from a C# script
« Reply #1 on: September 23, 2014, 04:05:05 AM »
Hi,

 ok. you need to do the following:

1: get a pointer to the PlayMakerArrayListProxy component
2: access the arrayList via the property _arrayList

and that's it, then _arrayList is a regular  c# "ArrayList"

Does that answer your question? or do you have problem with c# to populate any array to being with?

Bye,

Jean



unclebob

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Populating an array from a C# script
« Reply #2 on: October 13, 2014, 12:50:28 PM »
Thanks Jean.

Can I ask how I can populate an array using external data like an xls spreadsheet?

Cheers

Unclebob

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Populating an array from a C# script
« Reply #3 on: October 20, 2014, 01:40:07 AM »
Hi,

you'll have to do your parser manually. I have an example in the arrayMaker samples where I take a text files and populate an array with each lines, so you can do some basic parsing this way, but coming from a complex csv or database, it's not covered.

 Bye,

 Jean