@ All,
I did find this code for a custom action which helps my thinking A LOT... :-
// (c) Copyright HutongGames, LLC 2010-2015. All rights reserved.
/*--- __ECO__ __ACTION__ __BETA__ ---*/
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Array)]
[Tooltip("Get all children of a gameobject and save them in an Array.")]
public class GetGameObjectChildrenInArray : FsmStateAction
{
[RequiredField]
[Tooltip("The gameObject Variable to get its children from.")]
public FsmOwnerDefault gameObject;
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("The Array Variable to use.")]
public FsmArray array;
[UIHint(UIHint.Layer)]
[Tooltip("Only consider objects from these layers.")]
public FsmInt[] layerMask;
[Tooltip("Invert the mask, so you pick from all layers except those defined above.")]
public FsmBool invertMask;
[UIHint(UIHint.Tag)]
[Tooltip("Filter by Tag")]
public FsmString withTag;
public override void Reset ()
{
gameObject = null;
array = null;
withTag = "Untagged";
layerMask = null;
invertMask = null;
}
// Code that runs on entering the state.
public override void OnEnter ()
{
DoGetChilds ();
Finish ();
}
private void DoGetChilds ()
{
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null) return;
int _layerMask = ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value);
List<GameObject> _list = new List<GameObject>();
foreach (Transform child in go.transform)
{
bool _valid = true;
// tag filtering
if (! string.IsNullOrEmpty(withTag.Value) || withTag.Value != "UnTagged")
{
_valid = child.tag == withTag.Value;
}
// layer filtering, if still valid
if (_valid) _valid = (_layerMask & (1 << child.gameObject.layer)) > 0 ;
if (_valid) _list.Add(child.gameObject);
}
array.Values = _list.ToArray();
}
}
}
So it's that last array.Values = _list.ToArray(); which helps the most.
If I am reading that correctly, an fsm array uses .Values rather than, as with other fsm variables a .Value. Also, it would seem I can just transpose across any old (same variable type) unity array - and I can (if the List<T>) is simple also copy across an unity List<T> if we're just talking about a single variable (unity variable) List...?
Please someone tell me if I am wrong in some way...?