void DragShape() { if (select != null) { select.Position = mouseOffset + mousePoint; select.SetColor(Color.white); select.RigidbodyType = RigidbodyType.Kinmatic; } else { ShapeObject[] shapes = ShapesCollision.OverlapPoint(mousePoint); if (shapes.Length <= 0) { return; } if (shapes[0].RigidbodyType == RigidbodyType.Static) { return; } select = shapes[0]; selectType = select.RigidbodyType; mouseOffset = select.Position - mousePoint; } }
//Add public void AddShape(ShapeObject checkShape) { if (!IsShapeOverlapTreeRect(checkShape)) { return; } if (chiledShapes.Count < maxAmount || TreeDepth >= maxDepth) { chiledShapes.Add(checkShape); Color color = (TreeDepth == 0) ? Color.blue : (TreeDepth == 1) ? Color.red : (TreeDepth == 2) ? Color.green : (TreeDepth == 3) ? Color.yellow : Color.black; if (ShapeQuadTree.DrawTreeDebug) { checkShape.SetColor(color); } } else { if (TreeDepth >= maxDepth) { return; } if (chiledTrees == null) { CreateChiledTree(); } for (int i = 0; i < chiledTrees.Length; i++) { chiledTrees[i].AddShape(checkShape); } } }