- Home /
C# Coding error
I get the error Expression denotes a type', where a
variable', value' or
method group' was expected whenever I try to do this code:
mat = EditorGUILayout.ObjectField(mat, Material, true);
People say you use the 'new' keyword before it, but I couldn't get it to work.
Answer by paulygons · Nov 25, 2013 at 01:37 AM
I see HERE that they use typeof(SomeType) instead of the way you have it "Material". If that isn't the problem, your single line of code looks similar to the script reference so I'm betting the problem is not this line of code.
@paulygons is correct:
mat = EditorGUILayout.ObjectField(mat, typeof($$anonymous$$aterial), true);
When using that code it has ANOTHER error. :( The error is: Cannot implicitly convert type UnityEngine.Object' to
UnityEngine.$$anonymous$$aterial'. An explicit conversion exists (are you missing a cast?) I defined the variable 'mat' as a $$anonymous$$aterial at the beginning of the script.
mat = EditorGUILayout.ObjectField(mat, typeof($$anonymous$$aterial), true) as $$anonymous$$aterial;
or
mat = ($$anonymous$$aterial)EditorGUILayout.ObjectField(mat, typeof($$anonymous$$aterial), true);
using as $$anonymous$$aterial, you would still have to check for nullity, prefix casting will crash if not possible.
It depends what you are after.
Your answer
Follow this Question
Related Questions
Ref modifier 1 Answer
A node in a childnode? 1 Answer
Problems with instantiation... 1 Answer
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer