Hi guys, I’m having error while casting object to material.
InvalidCastException: Cannot cast from source type to destination type.
What I’m trying to do is something like this:
mTarget.mMaterial = (Material)EditorGUILayout.ObjectField("Material", mTarget.mMaterial, typeof(Object));
I’m setting an object field in the Editor and it would be taking all the materials, so at the end I need to cast it back to material type.
Is there any solution for this?