8 [AddComponentMenu(
"TrueSync/Physics/BoxCollider2D", 0)]
11 [FormerlySerializedAs(
"size")]
13 private TSVector2 _size = TSVector2.one;
21 TSVector2 halfVector = ((Physics2D.PolygonShape)_body.FixtureList[0].Shape).Vertices[0] * 2;
37 ((Physics2D.PolygonShape)_body.FixtureList[0].Shape).Vertices =
TrueSync.Physics2D.PolygonTools.CreateRectangle(sizeScaled.
x * FP.Half, sizeScaled.
y * FP.Half);
47 if (GetComponent<BoxCollider2D>() != null) {
48 BoxCollider2D boxCollider2D = GetComponent<BoxCollider2D>();
50 size =
new TSVector2(boxCollider2D.size.x, boxCollider2D.size.y);
51 Center =
new TSVector2(boxCollider2D.offset.x, boxCollider2D.offset.y);
53 }
else if (GetComponent<BoxCollider>() != null) {
54 BoxCollider boxCollider = GetComponent<BoxCollider>();
56 size = boxCollider.size.ToTSVector2();
57 Center = boxCollider.center.ToTSVector2();
68 return new TrueSync.Physics2D.PolygonShape(
TrueSync.Physics2D.PolygonTools.CreateRectangle(sizeScaled.
x * FP.Half, sizeScaled.
y * FP.Half), 1);
72 Gizmos.DrawWireCube(Vector3.zero, Vector3.one);
FP y
The Y component of the vector.
bool isTrigger
If it is only a trigger and doesn't interfere on collisions.
override Vector3 GetGizmosSize()
Returns the gizmos size.
override void DrawGizmos()
Draws the specific gizmos of concrete collider (for example "Gizmos.DrawWireCube" for a TSBoxCollider...
void Reset()
Sets initial values to size based on a pre-existing BoxCollider or BoxCollider2D. ...
void Scale(TSVector other)
Multiplies each component of the vector by the same components of the provided vector.
TSVector2 Center
Center of the collider shape.
override TrueSync.Physics2D.Shape CreateShape()
Create the internal shape used to represent a TSBoxCollider.
Collider with a box 2D shape.
TSVector lossyScale
Holds an first value of the GameObject's lossy scale.
FP x
The X component of the vector.
TSVector2 size
Size of the box.
Abstract collider for 2D shapes.