2016-08-18 44 views
-2

Debug.log在Awake()函数中正常工作,但不在FixedUpdate()中正常工作。不知道什么是错的调试日志不适用于固定更新

using UnityEngine; 
using System.Collections; 

[RequireComponent(typeof(SteamVR_TrackedObject))] 
public class PickupParent : MonoBehaviour { 

    SteamVR_TrackedObject trackedObj; 

    void Awake() { 
     trackedObj = GetComponent<SteamVR_TrackedObject>(); 
     Debug.Log("debug log is working"); 
    } 

    // Update is called once per frame 
    void FixedUpdated() { 
     SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index); 

     if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger)) 
     { 
      Debug.Log("You are holding down the 'Touch' on the Trigger"); 
     } 
    } 
} 

回答

1

看起来你增加了一个额外d函数名FixedUpdated应该FixedUpdate

// Update is called once per frame 
void FixedUpdated() { // <---------- should be FixedUpdate 
    ... 

另外我想尝试的第一件事就是加入在FixedUpdate开始的Debug.Log电话,看看是否函数被调用的。它没有被调用会表明该功能存在问题。如果它被调用,那么它会指向围绕日志调用的if语句。