示例#1
0
    private Collider CreateColliderOn(Transform instanceRoot, Transform root, Transform bone, bool mirrored)
    {
        if (!bone)
        {
            throw new ArgumentException("there was no bone");
        }
        string    str        = AuthorShared.CalculatePath(bone, root);
        Transform transforms = instanceRoot.FindChild(str);

        if (!transforms)
        {
            throw new MissingReferenceException(str);
        }
        switch (this.kind)
        {
        case HitShapeKind.Sphere:
        {
            SphereCollider center = transforms.gameObject.AddComponent <SphereCollider>();
            center.center = this.GetCenter(mirrored);
            center.radius = this.radius;
            break;
        }

        case HitShapeKind.Capsule:
        {
            CapsuleCollider capsuleCollider = transforms.gameObject.AddComponent <CapsuleCollider>();
            capsuleCollider.center    = this.GetCenter(mirrored);
            capsuleCollider.radius    = this.radius;
            capsuleCollider.height    = this.height;
            capsuleCollider.direction = this.capsuleAxis;
            break;
        }

        case HitShapeKind.Line:
        {
            throw new NotSupportedException();
        }

        case HitShapeKind.Box:
        {
            BoxCollider boxCollider = transforms.gameObject.AddComponent <BoxCollider>();
            boxCollider.center = this.GetCenter(mirrored);
            boxCollider.size   = this.size;
            break;
        }

        default:
        {
            throw new NotSupportedException();
        }
        }
        return(transforms.collider);
    }
示例#2
0
 public virtual string RootBonePath(AuthorPeice callingPeice, Transform bone)
 {
     return(AuthorShared.CalculatePath(bone, bone.root));
 }