Esempio n. 1
0
        public virtual void CalcFlowchartCenter(Flowchart flowchart, Block[] blocks)
        {
            if (flowchart == null ||
                blocks.Count() == 0)
            {
                return;
            }

            Vector2 min = blocks[0].nodeRect.min;
            Vector2 max = blocks[0].nodeRect.max;

            foreach (Block block in blocks)
            {
                min.x = Mathf.Min(min.x, block.nodeRect.center.x);
                min.y = Mathf.Min(min.y, block.nodeRect.center.y);
                max.x = Mathf.Max(max.x, block.nodeRect.center.x);
                max.y = Mathf.Max(max.y, block.nodeRect.center.y);
            }

            Vector2 center = (min + max) * -0.5f;

            center.x += position.width * 0.5f;
            center.y += position.height * 0.5f;

            flowchart.centerPosition = center;
        }