Hello, i would want to ask if there's any in editor script for syncing or to quickly copy-paste thru a specified array of gameObjects.
My situation: i have 5 characters with about 10 fsms on each. I plan on having about 40 characters, and manually copy pasting each fsm throughout them all doesn't seem too wise of an option.
ExtraDetails: can't place them into a prefab, since i'm using some trigger and collision events which must stay with the rigidbody gameObject, which has to be on the main parent
Sadly i'm not that good with in editor scripts, so any help is appreciated.
Of course it'd be best to have both options (synch current fsm, synch all fsms from this gameobject to the ones in the array), yet i'd be happy to get at least one of them working.
Progress so far:
As of now i'm only able to select current fsm via "FsmEditor.SelectedFsmComponent", however accesing variables such as arrays, or even doing a "PlayMakerFSM.FindFsmOnGameObject" always has a null result. Is there a certain way to find and access fsms while in Editor mode?
My Code
[MenuItem("Tools/Chars FsmSynch")]
public static void FsmSynchCh()
{
if (ArrHolder == null) ArrHolder = GameObject.Find("SaveLoad");
PlayMakerFSM fsmC = FsmEditor.SelectedFsmComponent;
GameObject gOwner = fsmC.gameObject;
FsmArray gList = PlayMakerFSM.FindFsmOnGameObject(ArrHolder, ArrFsmname).FsmVariables.GetFsmArray("PrefChars");
if (fsmC != null && gOwner != null && gList.Length > 0) {
FsmS (fsmC, gList, gOwner);
}
}
static void FsmS(PlayMakerFSM fsmC, FsmArray gList, GameObject gOwner){
ComponentUtility.CopyComponent (fsmC);
for (int i = 0; i < gList.Length; i++) {
if (gList.Values [i] == null) continue;
if ((gList.Values[i] as GameObject).name == gOwner.name) continue;
PlayMakerFSM fsmT = PlayMakerFSM.FindFsmOnGameObject (gList.Values [i] as GameObject, fsmC.FsmName);
if (fsmT != null) ComponentUtility.PasteComponentValues (fsmT);
}
}