- Home /
Need help with post processing error.
So I've updated unity to the newest version and updated the post processing stack and now I'm getting this error and I'm not sure how to fix it:
Assets_PostProcessing\Editor\PropertyDrawers\MinDrawer.cs(6,34): error CS0104: 'MinAttribute' is an ambiguous reference between 'UnityEngine.PostProcessing.MinAttribute' and 'UnityEngine.MinAttribute'
I'm not sure how to fix this though and I'm sure if anyone else has had this same problem, can anyone help me fix this? Here's the script I'm getting the error on:
using UnityEngine;
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
[CustomPropertyDrawer(typeof(MinAttribute))]
sealed class MinDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
MinAttribute attribute = (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.");
}
}
}
}
And I think it's having some connection with this script:
namespace UnityEngine.PostProcessing
{
public sealed class MinAttribute : PropertyAttribute
{
public readonly float min;
public MinAttribute(float min)
{
this.min = min;
}
}
}
Answer by Honorsoft · Jan 15, 2020 at 02:57 AM
It's 2020 now, I have been trying out different versions of Unity and different projects lately, and I have been coming across the 'MinAttribute ambiguous' error a lot, and in searching for an answer online, I see a lot of others still are too. I have had sucess with a different fix than hexagonius mentioned. You make sure to have "`using Unity.Engine.PostProcessing` and add just put "UnityEngine." (including the period) in front of all the "MinAttribute" references. To clarify, instead of "MinAttribute", put "UnityEngine.MinAttribute".
So, here's a full script for anyone to copy and paste in case you don't want to do the typing:
//MinAttribute.cs
using UnityEngine;
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
[CustomPropertyDrawer(typeof(UnityEngine.MinAttribute))]
sealed class MinDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
UnityEngine.MinAttribute attribute = (UnityEngine.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.");
}
}
}
}
Answer by hexagonius · Dec 20, 2018 at 08:27 PM
you need to fully qualify MinAttribute:
[UnityEngine.PostProcessing.MinAttribute]
I'm not sure where I need to add or change code. I tried using this in different places but could not figure out how to use it.
Confirmed replacing $$anonymous$$inAttribute with UnityEngine.PostProcessing.$$anonymous$$inAttribute resolved the error.
However, I'm not sure if this post processing will be discontinued in the future, as there seems to be a newer version that is obtained through the Package $$anonymous$$anager.
Answer by YannLescot · Jun 04, 2020 at 08:58 AM
Just an update, you can't import Unity.Engine.PostProcessing (anymore?) Having UnityEngine Imported (`using UnityEngine;`) should be enough.
So, in your error message, a component is specified. In my case the error was :
'*Vector2' est une référence ambiguë entre 'System.Numerics.Vector2' et 'UnityEngine.Vector2*'
The specified object is "Vector2", so the only thing I did was replacing every Vector2
I had with UnityEngine.Vector2
.
It fixed it ! :)
Answer by BlueDragoness · Oct 22, 2020 at 03:45 PM
In minattribute change "namespace UnityEngine" to "namespace UnityEditor".
I also added
using UnityEngine; using UnityEngine.PostProcessing;
to the top of this file before making that change. It didn't fix the problem on it's own, but if that first step doesn't work, perhaps it needed both. The first time I did it there was something random that happened about obsolete code and I had to change it back. I didn't understand what happened so I tried it again and it worked.