Search Unity

error CS1001: Unexpected symbol `{', expecting identifier need help :(

Discussion in 'Scripting' started by yanibanihd, Jul 20, 2019.

  1. yanibanihd

    yanibanihd

    Joined:
    Jul 20, 2019
    Posts:
    1
    using UnityEngine;
    using UnityEngine.PostProcessing;

    namespace UnityEditor.PostProcessing.
    {
    [CustomPropertyDrawer(typeof(UnityEngine.PostProcessing.MinAttribute))]
    sealed class MinDrawer : PropertyDrawer
    {

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {

    UnityEngine.PostProcessing.MinAttribute attribute = (UnityEngine.PostProcessing.MinAttribute)base.attribute;


    if (property.propertyType == SerializedPropertyType.Integer)
    {
    int v = EditorGUI.IntField(position, label, property.intValue);
    property.intValue = (int)Mathf.Max(v, attribute.min);
    }
    else if (property.propertyType == SerializedPropertyType.Float)
    {
    float v = EditorGUI.FloatField(position, label, property.floatValue);
    property.floatValue = Mathf.Max(v, attribute.min);
    }
    else
    {
    EditorGUI.LabelField(position, label.text, "Use Min with float or int.");
    }
    }
    }
    }
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    Please use code tags.
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.PostProcessing;
    3.  
    4. namespace UnityEditor.PostProcessing. {
    5.     [CustomPropertyDrawer(typeof(UnityEngine.PostProcessing.MinAttribute))]
    6.     sealed class MinDrawer : PropertyDrawer {
    7.  
    8.         public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
    9.  
    10.             UnityEngine.PostProcessing.MinAttribute attribute = (UnityEngine.PostProcessing.MinAttribute)base.attribute;
    11.  
    12.  
    13.             if(property.propertyType == SerializedPropertyType.Integer) {
    14.                 int v = EditorGUI.IntField(position, label, property.intValue);
    15.                 property.intValue = (int)Mathf.Max(v, attribute.min);
    16.             }
    17.             else if(property.propertyType == SerializedPropertyType.Float) {
    18.                 float v = EditorGUI.FloatField(position, label, property.floatValue);
    19.                 property.floatValue = Mathf.Max(v, attribute.min);
    20.             }
    21.             else {
    22.                 EditorGUI.LabelField(position, label.text, "Use Min with float or int.");
    23.             }
    24.         }
    25.     }
    26. }
    Remove the period at the end your namespace:
    namespace UnityEditor.PostProcessing.
     
  3. ismaelflorit

    ismaelflorit

    Joined:
    Apr 16, 2019
    Posts:
    38
    Edit: Damn got beat to it

    Hi!

    Please use the code formatting when submitting code, makes things a bit easier to read.

    In case you're still needing help, it seems you have a typo after your namespace declaration:

    Code (CSharp):
    1. namespace UnityEditor.PostProcessing. // remove this period
    2. {
    3. [CustomPropertyDrawer(typeof(UnityEngine.PostProcessing.MinAttribute))]