无法在Unity的补充工具栏中查看公共变量

时间:2017-11-25 00:03:02

标签: c# unity3d

我正在使用this教程在Unity中编写VR游戏代码。当我进入脚本时,我遇到了一个问题。我无法在Inspector侧栏中看到变量。这是我的代码:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Hello : MonoBehaviour {
    [SerializeField]
    public AudioClip clip;
    public AudioSource audioSource;
    public Transform gunBarrelTransform;

    void Start ()
    {
        audioSource = GetComponent<AudioSource> ();
        audioSource.clip = clip;
    }

    void Update (){
        if (OVRInput.Get (OVRInput.Button.SecondaryHandTrigger)) {
            audioSource.Play ();
            RaycastGun ();
        }

    }
    private void RaycastGun()
    {
        RaycastHit hit;
        if (Physics.Raycast (gunBarrelTransform.position, 
gunBarrelTransform.forward, out hit)) {
            if (hit.collider.gameObject.CompareTag ("Cube")) {
                Destroy (hit.collider.gameObject);

            }
        }
    }
}

即使我删除[SerializeField]它也不起作用。有人知道为什么变量没有显示出来吗?非常感谢你的帮助!

0 个答案:

没有答案