首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >统一控制台显示“类型或名称空间定义,或文件的预期统一”。

统一控制台显示“类型或名称空间定义,或文件的预期统一”。
EN

Stack Overflow用户
提问于 2022-08-15 18:28:48
回答 1查看 34关注 0票数 0

我正在做一个虚拟现实测试,我遇到了一个问题,不知道该怎么做。统一一直在说“类型或名称空间定义,或文件的预期统一”,我正在使用其他人的代码,但我正在遵循本教程。这是我的密码

代码:

代码语言:javascript
复制
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;
    }
}
EN

回答 1

Stack Overflow用户

发布于 2022-08-15 18:40:52

您正在创建一个空类,方法是在类声明之后打开并关闭花括号。在使用类成员声明代码块之后,但从不将其分配给任何东西。如果您在类声明之后放置了一个开始曲括号,并且在您的所有成员之后关闭它,那么它应该可以工作。

代码语言:javascript
复制
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;
    }
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73365039

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档