public void Init(ColliderPrefab prefab, CTransform2D trans) { this.Prefab = prefab; _bound = prefab.GetBounds(); Transform2D = trans; _prePos = Transform2D.pos; _preDeg = Transform2D.deg; unchecked { Id = autoIncId++; } }
public LRect GetBounds() { var col = collider; var tran = transform; var type = (EShape2D)col.TypeId; switch(type) { case EShape2D.Circle: var radius = ((CCircle)col).radius; return LRect.CreateRect(tran.pos, new LVector2(radius, radius)); case EShape2D.AABB: var halfSize = ((CAABB)col).size; return LRect.CreateRect(tran.pos, halfSize); case EShape2D.OBB: var rad = ((COBB)col).radius; return LRect.CreateRect(tran.pos, new LVector2(rad, rad)); } Debug.LogError("No support type" + type); return new LRect(); }
public static Rect ToRect(this LRect vec) { return(new Rect(vec.position.ToVector2(), vec.size.ToVector2())); }