コード例 #1
0
ファイル: NodePanel.cs プロジェクト: suppaduppax/BeeTree
        /// <summary>
        /// sort children based on the x position
        /// returns true if order has changed
        /// </summary>
        public bool SortChildren()
        {
            List <int> oldGuids = new List <int>(childrenGuids);

            childrenGuids.Sort((x, y) =>
                               canvasState.GetNodePanel(x).transform.position.x.CompareTo(canvasState.GetNodePanel(y).transform.position.x)
                               );

            if (oldGuids != childrenGuids)
            {
                List <int> nodeChildren = new List <int>();
                for (int i = 0; i < childrenGuids.Count; i++)
                {
                    nodeChildren.Add(canvasState.GetNodePanel(childrenGuids[i]).Node.guid);
                }

                Node.childrenGuids = nodeChildren;
            }

            return(oldGuids != childrenGuids);
        }
コード例 #2
0
ファイル: CanvasState.cs プロジェクト: suppaduppax/BeeTree
        public CanvasState CloneWithSubstituteTree(BehaviourTree treeAsset)
        {
            CanvasState canvasState = ScriptableObject.CreateInstance <CanvasState>();

            canvasState.tree          = treeAsset;
            canvasState.RootNodePanel = this.RootNodePanel;

            canvasState.nodePanels = new List <NodePanel>();

            for (int i = 0; i < nodePanels.Count; i++)
            {
                canvasState.nodePanels.Add(nodePanels[i].Clone(treeAsset, canvasState));
            }


            canvasState.canvasRect = canvasRect;
            canvasState.zoom       = zoom;
            canvasState.panOffset  = panOffset;
            canvasState.OnEnable();

            for (int i = 0; i < nodePanels.Count; i++)
            {
                NodePanel clonedPanel = canvasState.GetNodePanel(nodePanels[i].guid);
                NodePanel oldPanel    = nodePanels[i];

                clonedPanel.inHandle.transform.rect = oldPanel.inHandle.transform.rect;
                if (clonedPanel.hasOuthandle)
                {
                    clonedPanel.outHandle.transform.rect = oldPanel.outHandle.transform.rect;
                }
            }

            for (int i = 0; i < nodePanels.Count; i++)
            {
                NodePanel nodePanel = nodePanels[i];

                for (int j = 0; j < nodePanel.Children.Count; j++)
                {
                    NodePanel child = nodePanel.Children[j];
                    nodePanel.outHandle.Connect(child.inHandle);
                }
            }

            return(canvasState);
        }