/// <summary> /// Creates the <see cref="BehaviourNode"/> corresponding to this <see cref="XMLElement"/> /// </summary> /// <param name="selectedNode"></param> /// <param name="currentTree"></param> /// <param name="currentElement"></param> public void ToBehaviourNode(BaseNode selectedNode, BehaviourTree currentTree, ClickableElement currentElement) { switch (this.elemType) { case nameof(FSM): this.ToFSM(currentElement, selectedNode); break; case nameof(BehaviourTree): this.ToBehaviourTree(currentElement, selectedNode); break; case nameof(UtilitySystem): this.ToUtilitySystem(currentElement, selectedNode); break; case nameof(BehaviourNode): BehaviourNode nodeBT = ScriptableObject.CreateInstance <BehaviourNode>(); nodeBT.InitBehaviourNodeFromXML(currentTree, (behaviourType)Enum.Parse(typeof(behaviourType), this.secondType), this.windowPosX, this.windowPosY, this.Id, this.name, this.delayTime, this.Nloops, this.isRandom, this.isInfinite, this.index); currentTree.nodes.Add(nodeBT); if (selectedNode) { TransitionGUI transition = ScriptableObject.CreateInstance <TransitionGUI>(); transition.InitTransitionGUI(currentTree, selectedNode, nodeBT, true); currentTree.transitions.Add(transition); } else { nodeBT.isRoot = true; } foreach (XMLElement childState in this.nodes) { childState.ToBehaviourNode(nodeBT, currentTree, currentTree); } break; default: Debug.LogError("Wrong content in saved data"); break; } }