示例#1
0
        public void Add(Vector3i index, GameObject gameObject)
        {
            var grid = gameObject.GetComponent <VoxelGrid>();

            if (grid != null)
            {
                Remove(index);
                gameObject.Transform.Position = new Vector3(index.X * GridSize.X * VoxelSize, index.Y * GridSize.Y * VoxelSize, index.Z * GridSize.Z * VoxelSize);
                GameObject.AddChild(gameObject);
                _grids[index]  = grid;
                _indices[grid] = index;
                if (IsAlive)
                {
                    grid.VoxelsChanged += Grid_VoxelsChanged;
                }
                GridAdded?.Invoke(index, grid);
            }
        }