我正在做一个虚拟现实测试,我遇到了一个问题,不知道该怎么做。统一一直在说“类型或名称空间定义,或文件的预期统一”,我正在使用其他人的代码,但我正在遵循本教程。这是我的密码
代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VrRig : MonoBehaviour { }
public Transform headConstraint;
public Vector3 headBodyOffset;
{
// Start is called before the first frame update
void Start()
{
headBodyOffset = transform.position - headConstraint.position;
}
// Update is called once per frame
void Update()
{
transform.position = headConstraint.position + headBodyOffset;
transform.forward = Vector3.ProjectOnPlane(headConstraint.up,Vector3.up).normalized;
}
}发布于 2022-08-15 18:40:52
您正在创建一个空类,方法是在类声明之后打开并关闭花括号。在使用类成员声明代码块之后,但从不将其分配给任何东西。如果您在类声明之后放置了一个开始曲括号,并且在您的所有成员之后关闭它,那么它应该可以工作。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VrRig : MonoBehaviour
{
public Transform headConstraint;
public Vector3 headBodyOffset;
// Start is called before the first frame update
void Start()
{
headBodyOffset = transform.position - headConstraint.position;
}
// Update is called once per frame
void Update()
{
transform.position = headConstraint.position + headBodyOffset;
transform.forward = Vector3.ProjectOnPlane(headConstraint.up,Vector3.up).normalized;
}
}https://stackoverflow.com/questions/73365039
复制相似问题