How to fix (29,20): error CS1519: Invalid token '}' in class, struct, or interface member declaration

by Tayyab Irfan   Last Updated April 15, 2019 11:26 AM

I can't compile it, no matter what I do

I have tried every possible changing Help me to make it compile, for me the code is perfect but still it isn't working

[System.Serializable]
public class AQUAS_Parameters{

[System.Serializable]
public class UnderWaterParameters {
    [Header("The following parameters apply for underwater only!")]
    [Space(5)]
    public float fogDensity = 0.1f;
    public Color fogColor;
#if UNITY_POST_PROCESSING_STACK_V1 && AQUAS_PRESENT
    [Space(5)]
    [Header("Post Processing Profiles (Must NOT be empty!)")]
    [Space(5)]
    public PostProcessingProfile underwaterProfile;
    public PostProcessingProfile defaultProfile;
#endif

#if UNITY_POST_PROCESSING_STACK_V2 && AQUAS_PRESENT
    [Space(5)]
    [Header("Post Processing Profiles (Must NOT be empty!)")]
    [Space(5)] }
#endif
Tags : c# unity3d


Answers 2


I think you are missing two Curly braces at the end.

Saad Anees
Saad Anees
April 15, 2019 11:22 AM

An Attribute (that´s what you define by using [...]) gives metadata about a class or a class-member. In other words it can´t stand allone, it allways has to preceed some symbol. That´s why this does not compile:

#if UNITY_POST_PROCESSING_STACK_V2 && AQUAS_PRESENT
    [Space(5)]
    [Header("Post Processing Profiles (Must NOT be empty!)")]
    [Space(5)] }
#endif

It seems to me all you want is different attributes based on which of the two conditions apply, so youd wrap only those lines into #if else if:

[System.Serializable]
public class UnderWaterParameters {
    [Header("The following parameters apply for underwater only!")]
    [Space(5)]
    public float fogDensity = 0.1f;
    public Color fogColor;
#if UNITY_POST_PROCESSING_STACK_V1 && AQUAS_PRESENT
    [Space(5)]
    [Header("Post Processing Profiles (Must NOT be empty!)")]
    [Space(5)]
#elif UNITY_POST_PROCESSING_STACK_V2 && AQUAS_PRESENT
    [Space(5)]
    [Header("Post Processing Profiles (Must NOT be empty!)")]
    [Space(5)] }
#endif
    public PostProcessingProfile underwaterProfile;
    public PostProcessingProfile defaultProfile;
}
HimBromBeere
HimBromBeere
April 15, 2019 11:25 AM

Related Questions



Remove Unity SplashScreen

Updated October 09, 2017 06:26 AM


Need assistance with Mobile Button OnPress issue

Updated February 14, 2018 06:26 AM