protected override void Awake() { if (_handle != IntPtr.Zero) { return; } base.Awake(); // in case no vertices have been set yet if (_verts == null) { _verts = defaultVerts; } Vector2[] transformed = MakeVerts(); _handle = CP.NewConvexPolyShapeWithVerts(transformed.Length, transformed); CP.cpPolyShapeSetRadius(_handle, _maxScale * _radius); if (body != null) { body._AddMassForShape(this); } GCHandle gch = GCHandle.Alloc(this); CP._cpShapeSetUserData(_handle, GCHandle.ToIntPtr(gch)); }
protected override void Awake() { if (_handle != IntPtr.Zero) { return; } base.Awake(); var verts = MakeVerts(); _handle = CP.NewConvexPolyShapeWithVerts(verts.Length, verts); CP.cpPolyShapeSetRadius(_handle, _maxScale * _radius); if (body != null) { body._AddMassForShape(this); } var gch = GCHandle.Alloc(this); CP._cpShapeSetUserData(_handle, GCHandle.ToIntPtr(gch)); }
protected override void Awake() { if (_handle != IntPtr.Zero) { return; } base.Awake(); // Force generating the hull. this.verts = _verts; var transformed = MakeVerts(); _handle = CP.NewConvexPolyShapeWithVerts(transformed.Length, transformed); CP.cpPolyShapeSetRadius(_handle, _maxScale * _radius); if (body != null) { body._AddMassForShape(this); } var gch = GCHandle.Alloc(this); CP._cpShapeSetUserData(_handle, GCHandle.ToIntPtr(gch)); }