示例#1
0
    public void Save(Transform t)
    {
        CRC cr = new CRC();

        cr.t = t;
        var j = t.GetComponent <CharacterJoint>();

        if (j != null)
        {
            cr.CharacterJoint2 = new CharacterJoint2()
            {
                connectedBody = j.connectedBody.name, anchor = j.anchor, axis = j.axis, highTwistLimit = j.highTwistLimit, lowTwistLimit = j.lowTwistLimit, rotationDrive = j.rotationDrive, swing1Limit = j.swing1Limit, swing2Limit = j.swing2Limit, swingAxis = j.swingAxis, targetAngularVelocity = j.targetAngularVelocity, targetRotation = j.targetRotation
            }
        }
        ;
        Destroy(j);
        var r = t.rigidbody;

        if (r != null)
        {
            var rigidbody2 = new Rigidbody2()
            {
                mass = r.mass
            };
            cr.Rigidbody2 = rigidbody2;
        }
        Destroy(r);
        var c  = t.collider;
        var bc = c as BoxCollider;

        if (bc != null)
        {
            cr.BoxCollider2 = new BoxCollider2()
            {
                center = bc.center, extents = bc.extents
            }
        }
        ;
        var sc = c as SphereCollider;

        if (sc != null)
        {
            cr.SphereCollider2 = new SphereCollider2()
            {
                center = sc.center, radius = sc.radius
            }
        }
        ;
        var cc = c as CapsuleCollider;

        if (cc != null)
        {
            cr.CapsuleCollider2 = new CapsuleCollider2()
            {
                center = cc.center, direction = cc.direction, height = cc.height, radius = cc.radius
            }
        }
        ;
        Destroy(c);
        crcs.Add(cr);
    }
示例#2
0
 public void Save(Transform t)
 {
     CRC cr = new CRC();
     cr.t = t;
     var j = t.GetComponent<CharacterJoint>();
     if (j != null)
         cr.CharacterJoint2 = new CharacterJoint2() { connectedBody = j.connectedBody.name, anchor = j.anchor, axis = j.axis, highTwistLimit = j.highTwistLimit, lowTwistLimit = j.lowTwistLimit, rotationDrive = j.rotationDrive, swing1Limit = j.swing1Limit, swing2Limit = j.swing2Limit, swingAxis = j.swingAxis, targetAngularVelocity = j.targetAngularVelocity, targetRotation = j.targetRotation };
     Destroy(j);
     var r = t.rigidbody;
     if (r != null)
     {
         var rigidbody2 = new Rigidbody2() { mass = r.mass };
         cr.Rigidbody2 = rigidbody2;
     }
     Destroy(r);
     var c = t.collider;
     var bc = c as BoxCollider;
     if (bc != null)
         cr.BoxCollider2 = new BoxCollider2() { center = bc.center, extents = bc.extents };
     var sc = c as SphereCollider;
     if (sc != null)
         cr.SphereCollider2 = new SphereCollider2() { center = sc.center, radius = sc.radius };
     var cc = c as CapsuleCollider;
     if (cc != null)
         cr.CapsuleCollider2 = new CapsuleCollider2() { center = cc.center, direction = cc.direction, height = cc.height, radius = cc.radius };
     Destroy(c);
     crcs.Add(cr);
 }