今天发现一个问题,同事写的一个类继承自TrackedPoseDriver,打包运行后手部追踪位置无法追踪。

这里有两个手的Action引用。
我们整个项目有一个启用和关闭的控制,所以开始查了项目的开关,发现也都是开的。
经过折腾发现他的这个脚本是打包成AB发布的,所以他就不受控制了,需要单独enable。
干脆改掉算了,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.XR;
public class TrackedPoseDriverExtended : TrackedPoseDriver
{
public HandEnum handEnum;
[HideInInspector]
public Vector3 tempVector3 = Vector3.zero;
[HideInInspector]
public Quaternion tempQuaternion = Quaternion.identity;
protected override void Awake()
{
base.Awake();
if (InputManager.inst == null || InputManager.inst.inputAction == null)
{
return;
}
//这里自己指向引用,因为这个脚本是在ab包里,如果不这样指向,ab包是单独的Action,会导致没enable
if (handEnum == HandEnum.Left)
{
positionInput = new InputActionProperty(InputManager.inst.inputAction.Player.HandPos_Left);
rotationInput = new InputActionProperty(InputManager.inst.inputAction.Player.HandRot_Left);
}
else
{
positionInput = new InputActionProperty(InputManager.inst.inputAction.Player.HandPos_Right);
rotationInput = new InputActionProperty(InputManager.inst.inputAction.Player.HandRot_Right);
}
}
protected override void SetLocalTransform(Vector3 newPosition, Quaternion newRotation)
{
//Debug.Log($"22222222222 :{positionInput.action.enabled}, {newPosition}, {newRotation}");
newPosition = tempQuaternion * (tempVector3 + newPosition);
newRotation = tempQuaternion * newRotation;
base.SetLocalTransform(newPosition, newRotation);
}
}
这样就使用我的InputAction管理类统一了。
这真的是巨大一个坑,查了很久,放上来有相同问题的希望能看到。
4159

被折叠的 条评论
为什么被折叠?



