调试日志不适用于FixedUpdate

时间:2016-08-18 18:25:46

标签: c# unity3d

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 个答案:

答案 0 :(得分:1)

您似乎在函数名称d中添加了额外的FixedUpdated FixedUpdate

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

我还要尝试的第一件事是在Debug.Log的开头添加一个FixedUpdate调用,以查看该函数是否被调用。它没有被调用会表明该功能存在问题。如果它被调用,那么它将指向围绕日志调用的if语句。

相关问题