public override void OnEnter() { base.OnEnter(); var poolCtrl = pool.GetPoolController(Fsm, false); if (poolCtrl) { poolCtrl.ReleaseAllByType(template.GetName()); } Finish(); }
// Code that runs on entering the state. public override void OnEnter() { var poolCtrl = pool.GetPoolController(Fsm, false); if (poolCtrl) { string typeName = template != null?template.GetName() : ""; //setup name string toName; if (spawnName.IsNone) { toName = null; } else { toName = spawnName.Value; } //setup parent Transform toParent; if (spawnToParent.IsNone) { toParent = null; } else { toParent = spawnToParent.Value.transform; } //setup parameters for (int i = 0; i < spawnParamNames.Length; i++) { var parmName = spawnParamNames[i].Value; if (!string.IsNullOrEmpty(parmName)) { mSpawnParms[parmName] = spawnParamObjects[i].GetValue(); } } //spawn var spawn = poolCtrl.Spawn(typeName, toName, toParent, mSpawnParms); if (spawn) { var spawnTrans = spawn.transform; if (!spawnPosition.IsNone) { spawnTrans.position = spawnPosition.Value; } if (!spawnRotation.IsNone) { spawnTrans.rotation = Quaternion.Euler(spawnRotation.Value); } if (!spawnOutput.IsNone) { spawnOutput.Value = spawn.gameObject; } } else { Debug.LogWarning(string.Format("Unable to spawn from pool: {0}, type: {1}", poolCtrl.name, typeName)); } } else { Debug.LogWarning("Pool does not exists."); } Finish(); }