private static object OverlapGeneric(Physics2D.Shape shape, TSVector2 position, Physics2D.BodySpecialSensor sensorType) { Physics2D.World world = (Physics2D.World)Physics2DWorldManager.instance.GetWorld(); Physics2D.Body body = Physics2D.BodyFactory.CreateBody(world); body.CreateFixture(shape); body.BodyType = Physics2D.BodyType.Static; body.IsSensor = true; body.CollidesWith = Physics2D.Category.All; body.SpecialSensor = sensorType; body.Position = position; world.RemoveBody(body); world.ProcessRemovedBodies(); if (body._specialSensorResults.Count > 0) { if (sensorType == Physics2D.BodySpecialSensor.ActiveOnce) { return(Physics2DWorldManager.instance.GetGameObject(body._specialSensorResults[0]).GetComponent <TSCollider2D>()); } else { TSCollider2D[] result = new TSCollider2D[body._specialSensorResults.Count]; for (int i = 0; i < body._specialSensorResults.Count; i++) { result[i] = Physics2DWorldManager.instance.GetGameObject(body._specialSensorResults[i]).GetComponent <TSCollider2D>(); } return(result); } } return(null); }
public static Fixture AttachLoopShape(Vertices vertices, Body body, object userData = null) { ChainShape shape = new ChainShape(vertices, true); return(body.CreateFixture(shape, userData)); }
public static Fixture AttachEdge(TSVector2 start, TSVector2 end, Body body, object userData = null) { EdgeShape edgeShape = new EdgeShape(start, end); return(body.CreateFixture(edgeShape, userData)); }