예제 #1
0
 public virtual void initModel(string modelPath, string animationControllerPath = "")
 {
     if (modelPath != "")
     {
         // 模型节点也就是角色节点,并且将节点挂到角色管理器下
         GameObject model = mObjectManager.createObject(modelPath);
         setObject(model, true);
         // 将外部节点设置为角色节点后,角色在销毁时就不能自动销毁节点,否则会出错
         setDestroyObject(false);
         setParent(mCharacterManager.getManagerNode());
         mAvatar.setModel(model, modelPath);
         mRigidBody = model.GetComponent <Rigidbody>();
     }
     if (animationControllerPath != "")
     {
         mAvatar.mAnimator.runtimeAnimatorController = mResourceManager.loadResource <RuntimeAnimatorController>(animationControllerPath, true);
     }
 }
예제 #2
0
    protected virtual void notifyModelLoaded(GameObject go)
    {
        Vector3 lastPosition = getPosition();
        Vector3 lastRotation = getRotation();
        Vector3 lastScale    = getScale();

        setObject(go, true);
        // 将外部节点设置为角色节点后,角色在销毁时就不能自动销毁节点,否则会出错
        setDestroyObject(false);
        setParent(mCharacterManager.getObject());
        mAvatar.setModel(go, mModelPath);
        mRigidBody = go.GetComponent <Rigidbody>();
        if (!isEmpty(mAnimationControllerPath))
        {
            mAvatar.getAnimator().runtimeAnimatorController = mResourceManager.loadResource <RuntimeAnimatorController>(mAnimationControllerPath, true);
        }
        OT.MOVE(this, lastPosition);
        OT.ROTATE(this, lastRotation);
        OT.SCALE(this, lastScale);
    }