コード例 #1
0
    protected override void Awake()
    {
        if (_handle != IntPtr.Zero)
        {
            return;
        }
        base.Awake();

        Vector2 offset = BodyRelativeMatrix(body).MultiplyPoint(_center);

        _handle = CP.cpCircleShapeNew(IntPtr.Zero, _maxScale * _radius, offset);
        if (body != null)
        {
            body._AddMassForShape(this);
        }

        var gch = GCHandle.Alloc(this);

        CP._cpShapeSetUserData(_handle, GCHandle.ToIntPtr(gch));
    }