【问题标题】:error CS1514: Unexpected symbol `public', expecting `.' or `{'错误 CS1514:意外符号“公共”,应为“。”或'{'
【发布时间】:2019-07-14 01:02:15
【问题描述】:

大家早上好!我是 C# 和游戏开发的初学者,所以不要发誓))) 所以我有一个代码,但我在第 5 行有 1 个错误。请帮助我,我几乎尝试了所有方法,但没有帮助。希望你能帮助我。谢谢)) 错误:PostProcessingController.cs(5,6): error CS1514: Unexpected symbol public', expecting .' or {' 我不太懂 C#,你是我唯一的希望!

using UnityEngine;
using System.Collections;
namespace UnityEngine.Rendering.PostProcessing

public class PostProcessingController : MonoBehaviour \\<--ERROR IN HERE 
{
    public PostProcessVolume Volume;
    public DepthOfFieldSettings DofSettings;

    public ColorGradingSettings ColorSettings;

    DepthOfField dof;
    ColorGrading colorGrading;

    void Start()
    {
        Volume.sharedProfile = Instantiate(Volume.sharedProfile);

        dof = Volume.profile.GetSetting<DepthOfField>();
        colorGrading = Volume.profile.GetSetting<ColorGrading>();

        DofSettings.focusDistance = dof.focusDistance.value;
        DofSettings.aperture = dof.aperture.value;
        DofSettings.focalLength = dof.focalLength.value;

        ColorSettings.Lift = colorGrading.lift.value;
        ColorSettings.GreenOutGreenIn = colorGrading.mixerGreenOutGreenIn.value;
    }

    void Update()
    {
        dof.focusDistance.value = DofSettings.focusDistance;
        dof.aperture.value = DofSettings.aperture;
        dof.focalLength.value = DofSettings.focalLength;

        colorGrading.lift.value = ColorSettings.Lift;
        colorGrading.mixerGreenOutGreenIn.value = ColorSettings.GreenOutGreenIn;
    }

    public void LerpDof(DepthOfFieldSettings start, DepthOfFieldSettings end, float t)
    {
        DofSettings.focusDistance = Mathf.Lerp(start.focusDistance, end.focusDistance, t);
        DofSettings.aperture = Mathf.Lerp(start.aperture, end.aperture, t);
        DofSettings.focalLength = Mathf.Lerp(start.focalLength, end.focalLength, t);
    }

    public void LerpColorGrading(ColorGradingSettings start, ColorGradingSettings end, float t)
    {
        ColorSettings.Lift = Vector4.Lerp(start.Lift, end.Lift, t);
        ColorSettings.GreenOutGreenIn = Mathf.Lerp(start.GreenOutGreenIn, end.GreenOutGreenIn, t);
    }

    [ContextMenu("Show grading")]
    void showLift()
    {
        colorGrading = Volume.profile.GetSetting<ColorGrading>();
        Debug.Log(colorGrading.lift.value);
        Debug.Log(colorGrading.mixerGreenOutGreenIn.value);
    }

    [System.Serializable]
    public struct DepthOfFieldSettings
    {
        public float focusDistance;
        public float aperture;
        public float focalLength;
    }

    [System.Serializable]
    public struct ColorGradingSettings
    {
        public Vector4 Lift;
        public float GreenOutGreenIn;
    }
}

【问题讨论】:

  • namespace UnityEngine.Rendering.PostProcessing 之后缺少{,最后可能还有}
  • 不起作用((我试过但有9个错误,例如:
  • 类型或命名空间名称PostProcessingController' could not be found. Are you missing UnityEngine.Rendering.PostProcessing' using 指令?

标签: c# unity3d


【解决方案1】:

namespace 替换为using 并在行尾添加;

using UnityEngine.Rendering.PostProcessing;

您还需要通过PackageManager 导入的PostPrecessing Package

(这里是List of all available Packages

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-15
    • 1970-01-01
    相关资源
    最近更新 更多