示例#1
0
        private void AlignTransform(Transform t, bool rotate)
        {
            if (rotate)
            {
                t.rotation = GridTransfrom.rotation;
            }
            var oldPosition = t.position;

            if (_rectGrid)
            {
                _rectGrid.AlignTransform(t);
            }
            else if (_hexGrid)
            {
                _hexGrid.AlignTransform(t);
            }
            else
            {
                throw new System.NullReferenceException("No grid set");
            }

            for (var i = 0; i < 3; ++i)
            {
                if (IgnoredAxes[i])
                {
                    var newPosition = t.position;
                    newPosition[i] = oldPosition[i];
                    t.position     = newPosition;
                }
            }
        }