playMaker

Author Topic: Unity List to Array or ArrayMaker  (Read 215 times)

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Unity List to Array or ArrayMaker
« on: June 08, 2017, 07:08:19 AM »
I am creating action for opsives third person controller (can be found here: https://github.com/dumbgamedev/thirdpersoncontroller_playmaker)

There is a method that returns a list of inventory items. I am trying to figure out how to get that list into a playmaker FSM array or arraymaker array.


Method:
void Opsive.ThirdPersonController.Inventory.GetAvailableItems ( ref List< ItemType >    itemTypes)   

Returns a list of items which are currently available in the inventory.
itemTypes The list of items which are currently available.

Documentation: https://www.opsive.com/assets/ThirdPersonController/API/class_opsive_1_1_third_person_controller_1_1_inventory.html#a815d5b4f2f50267b7572930771279292

Any ideas or examples?

Zanderfax

  • Playmaker Newbie
  • *
  • Posts: 14
    • View Profile
Re: Unity List to Array or ArrayMaker
« Reply #1 on: June 11, 2017, 07:22:31 AM »
I have found the easiest way to do this is to loop through the list then assign it to the ArrayList.

1) Get the proxy from the game object:

Code: [Select]
PlayMakerArrayListProxy goProxy = go.GetComponents<PlayMakerArrayListProxy>()
2) Then loop through the List with a foreach and add the info:
Code: [Select]
foreach (var item in list) {
    goProxy._arraylist.Add(item);
}

The key here is the _arraylist. It is what is exposed to access the arraylist data itself.

Hope this helps,

Z