void AddBlock(Vector2 position, VFXModelDescriptor <VFXBlock> descriptor) { int blockIndex = -1; var blocks = m_BlockContainer.Query().OfType <VFXBlockUI>().ToList(); for (int i = 0; i < blocks.Count; ++i) { Rect worldBounds = blocks[i].worldBound; if (worldBounds.Contains(position)) { if (position.y > worldBounds.center.y) { blockIndex = i + 1; } else { blockIndex = i; } break; } } using (var growContext = new GrowContext(this)) { controller.AddBlock(blockIndex, descriptor.CreateInstance(), true /* freshly created block, should init space */); } }
public void BlocksDropped(int blockIndex, IEnumerable <VFXBlockUI> draggedBlocks, bool copy) { HashSet <VFXContextController> contexts = new HashSet <VFXContextController>(); foreach (var draggedBlock in draggedBlocks) { contexts.Add(draggedBlock.context.controller); } using (var growContext = new GrowContext(this)) { controller.BlocksDropped(blockIndex, draggedBlocks.Select(t => t.controller), copy); foreach (var context in contexts) { context.ApplyChanges(); } } }