错误CS1514:意外符号'public',期望为'。'或`{'

时间:2019-07-13 11:13:04

标签: c# unity3d

大家早上好!我是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;
    }
}

1 个答案:

答案 0 :(得分:0)

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

using UnityEngine.Rendering.PostProcessing;

您还需要通过PostPrecessing Package

导入的PackageManager

(这里是List of all available Packages