public Texture2D pimage;
public void showObjects () {
pimage = EditorGUI.ObjectField(pimage,typeof(Texture2D));
}
Gives me a “No overload for method ‘ObjectField’ takes 2 arguments” error.
public Texture2D pimage;
public void showObjects () {
pimage = EditorGUI.ObjectField(pimage,typeof(Texture2D));
}
Gives me a “No overload for method ‘ObjectField’ takes 2 arguments” error.
Hi reissgrant,
It’s because you are missing some arguments.
If you are using Visual Studio, it should tell you what arguments you need in order for it to work. If you don’t have that, go to the following url and you can search any function or scripting name and you will get all the information that you need.
In this case, here are the your options;
ObjectField (position : Rect, obj : Object, objType : System.Type) : Object
ObjectField (position : Rect, label : string, obj : Object, objType : System.Type) : Object
ObjectField (position : Rect, label : GUIContent, obj : Object, objType : System.Type) : Object
But what exactly are you trying to do?
Everything maparizeau said is good, but the simple answer is, you’re not specifying where the ObjectField should go.
static function ObjectField (
obj : Object,
objType : System.Type,
params options : GUILayoutOption[]) : Object
This is the implementation that I am using.
I am supplying an Object (or so I think) which is the pimage variable and the Texture2D is the System.Type. pimage is then taking the return value, so it is outputting to an object as well.
So I’m not sure where I’m going wrong, the GUILayout options is optional. Is the pimage not a valid Object? How can I make it valid? Is it not enough just to declare it?
You’re listing an EditorGUILayout method, but you’re not calling it. You’re calling an EditorGUI method, which requires a Rect as the first parameter.
That is, the last thing you listed is this:
But the method you listed in the first post is this:
(1st method on each page)
Do you see? Notice the Layout here, that’s necessary for correction?
pimage = EditorGUILayout.ObjectField(pimage,typeof(Texture2D));
Jessy sorry for the confusion, you’re right; somehow I missed that. Problem is fixed by calling this:
pimage = EditorGUILayout.ObjectField(pimage,typeof(Texture2D)) as Texture2D;
Thanks!