Beispiel #1
0
        IEnumerator UpdateBoundsCoroutine()
        {
            float time = Time.time - lastUpdateTime;

            if (time < updateTime)
            {
                yield return(new WaitForSeconds(time));
            }

            //get model root
            if (modelRoot != null)
            {
                GridBounds oldBounds = (GridBounds)gridBounds.Clone();

                //get all brick
                var bricks = modelRoot.GetComponentsInChildren <Brick>();
                if (bricks.Length > 0)
                {
                    //calculate all bricks bounds
                    var bounds = bricks[0].GetBounds();
                    for (int i = 1; i < bricks.Length; i++)
                    {
                        if (!(bricks[i] is AgaQTemporaryGroup) && bricks[i].gameObject.activeSelf)
                        {
                            bounds.Encapsulate(bricks[i].GetBounds());
                        }
                    }

                    bounds.Expand(5f);
                    gridBounds.SetSize(bounds);

                    if (oldBounds != gridBounds)
                    {
                        SetUpPlane();
                    }

                    lastUpdateTime = Time.time;
                }
            }
        }