Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Zeb on February 23, 2017, 07:26:19 PM
-
Hello,
I’m looking for an example in C# code to take an array list that exists in script and access it in PlayMaker. I can do it easy enough with variables but I cannot seem to find any complete example of how to do this with array lists from script.
I found ways to do this with variables here:
https://hutonggames.fogbugz.com/default.asp?W1103
https://hutonggames.fogbugz.com/?W329
But with this knowledge I’m still unsuccessful.
Thank you kindly,
Zeb
-
When you say "access" - what exactly do you want to do with the array list in Playmaker? Do you want to copy the array list into a Playmaker native array or arraymaker array list? Or just get/set things to/from the array list?
If you describe what you want to do with the data it will make it easier to help you :)
-
Hi,
Have a look at how things are done internally within ArrayMaker, it will likely help you find ways to do this.
Bye,
Jean
-
I appreciate the support guys.
Mdotstrange; first off, big fan of your work!
I’m converting a project over from C# to PlayMaker for the UI flow. All core gameplay features are developed in C#. So, with this hybrid approach I wanted to maintain as much code as possible. With that in mind I have an array I use in C# that I would like to copy the data and place into a native PlayMaker array I can then use for populating UI game objects and such.
Jean, I see what you’re getting at. I opened up a few ArrayMaker scripts and was able to use some of the syntax in the past hour. I did get another step closer. I’m able to carry over string arrays only and they have to be individually created in PlayMaker.
This is a first step. I need sleep but tomorrow I’ll look deeper and see if I can get a 1:1 mapping from the C# array list to PlayMaker Array. One thing I should mention; I have array lists within my array lists. Not sure if PlayMaker will accept that scenario.
Here is a snip of the code I used to get it working…
using HutongGames.PlayMaker;
private List<Challenge> challenges;
public FsmArray Name;
public FsmArray XP;
public FsmArray Fame;
public FsmArray Gold;
public FsmArray Monsters;
public FsmArray RequiredFame;
public FsmArray IsPlotQuest;
private void FetchAllChallenges()
{
this.challenges = new List<Challenge>();
for (int i = 0; i < this.ChallengeIDs.Count; ++i)
{
this.challenges.Add(ChallengeManager.Instance.GetChallengeFromID(this.ChallengeIDs[i]));
//Push challenges list over to PlayMaker
Name = FsmVariables.GlobalVariables.FindFsmArray("challengeName");
Name.Values[i] = this.challenges[i].Name.ToString();
XP = FsmVariables.GlobalVariables.FindFsmArray("challengeXP");
XP.Values[i] = this.challenges[i].XP.ToString();
Fame = FsmVariables.GlobalVariables.FindFsmArray("challengeFame");
Fame.Values[i] = this.challenges[i].Fame.ToString();
Gold = FsmVariables.GlobalVariables.FindFsmArray("challengeGold");
Gold.Values[i] = this.challenges[i].Gold.ToString();
RequiredFame = FsmVariables.GlobalVariables.FindFsmArray("challengeRequiredFame");
RequiredFame.Values[i] = this.challenges[i].RequiredFame.ToString();
Monsters = FsmVariables.GlobalVariables.FindFsmArray("challengeMonsters");
Monsters.Values[i] = this.challenges[i].Monsters.ToString();
IsPlotQuest = FsmVariables.GlobalVariables.FindFsmArray("challengeIsPlotQuest");
IsPlotQuest.Values[i] = this.challenges[i].IsPlotQuest.ToString();
}
}
Thanks again fellas!
Zeb
-
Hi,
PlayMaker doesn't support any of that, you'll have to make it fit with what PlayMaker can do, indeed ArrayMaker will be a good start for you, but nested arrays is complex to deal with even with scripts. so proceed with small incremental steps for developing this feature,
Bye,
Jean
-
Wise advice Jean. I thought about it while I was wide awake last night and since I’m only using this array for UI I can keep the simplistic structure in PlayMaker/ArrayMaker. The more complex structure can remain in code as it’s working fine as is.
I’m going to mark this thread as SOLVED since it has a working sample of code in it.
Thanks again for the support.
Zeb