public static Vector2 GetTargetPosition(AnchoredJoint2D joint2D, AnchorBias bias = AnchorBias.Either)
    {
        var transform = GetTargetTransform(joint2D, bias);

        if (transform == null) {
            return Vector2.zero;
        }
        return transform.position;
    }
 public static Vector2 GetAnchorPosition(AnchoredJoint2D joint2D, AnchorBias bias = AnchorBias.Either)
 {
     switch (bias) {
         case AnchorBias.Connected:
             return GetConnectedAnchorPosition(joint2D);
         default:
             return GetMainAnchorPosition(joint2D);
     }
 }
    public static Vector2 GetTargetPosition(AnchoredJoint2D joint2D, AnchorBias bias = AnchorBias.Either)
    {
        var transform = GetTargetTransform(joint2D, bias);

        if (transform == null)
        {
            return(Vector2.zero);
        }
        return(transform.position);
    }
    public static float GetTargetRotation(AnchoredJoint2D joint2D, AnchorBias bias = AnchorBias.Either)
    {
        var transform = GetTargetTransform(joint2D, bias);

        if (transform == null) {
            return 0;
        }

        return transform.rotation.eulerAngles.z;
    }
    public static float GetTargetRotation(AnchoredJoint2D joint2D, AnchorBias bias = AnchorBias.Either)
    {
        var transform = GetTargetTransform(joint2D, bias);

        if (transform == null)
        {
            return(0);
        }

        return(transform.rotation.eulerAngles.z);
    }
    public static Vector2 GetAnchorPosition(AnchoredJoint2D joint2D, AnchorBias bias = AnchorBias.Either)
    {
        switch (bias)
        {
        case AnchorBias.Connected:
            return(GetConnectedAnchorPosition(joint2D));

        default:
            return(GetMainAnchorPosition(joint2D));
        }
    }
    public static Transform GetTargetTransform(AnchoredJoint2D joint2D, AnchorBias bias = AnchorBias.Either)
    {
        Transform transform;

        if (bias == AnchorBias.Connected)
        {
            transform = joint2D.connectedBody != null ? joint2D.connectedBody.transform : null;
        }
        else
        {
            transform = joint2D.transform;
        }
        return(transform);
    }
    public static void SetWorldAnchorPosition(AnchoredJoint2D joint2D, Vector2 position, AnchorBias bias)
    {
        switch (bias)
        {
        case AnchorBias.Connected:
            SetWorldConnectedAnchorPosition(joint2D, position);
            break;

        case AnchorBias.Main:
            SetWorldMainAnchorPosition(joint2D, position);
            break;

        case AnchorBias.Either:
            SetWorldMainAnchorPosition(joint2D, position);
            SetWorldConnectedAnchorPosition(joint2D, position);
            break;
        }
    }
 public static AnchorBias GetOppositeBias(AnchorBias bias)
 {
     return(bias == AnchorBias.Connected
         ? AnchorBias.Main
         : AnchorBias.Connected);
 }
 public static Transform GetTargetTransform(AnchoredJoint2D joint2D, AnchorBias bias = AnchorBias.Either)
 {
     Transform transform;
     if (bias == AnchorBias.Connected) {
         transform = joint2D.connectedBody != null ? joint2D.connectedBody.transform : null;
     } else {
         transform = joint2D.transform;
     }
     return transform;
 }
 public static AnchorBias GetOppositeBias(AnchorBias bias)
 {
     return bias == AnchorBias.Connected
         ? AnchorBias.Main
         : AnchorBias.Connected;
 }
 public static void SetWorldAnchorPosition(AnchoredJoint2D joint2D, Vector2 position, AnchorBias bias)
 {
     switch (bias) {
         case AnchorBias.Connected:
             SetWorldConnectedAnchorPosition(joint2D, position);
             break;
         case AnchorBias.Main:
             SetWorldMainAnchorPosition(joint2D, position);
             break;
         case AnchorBias.Either:
             SetWorldMainAnchorPosition(joint2D, position);
             SetWorldConnectedAnchorPosition(joint2D, position);
             break;
     }
 }