- Home /
The question is answered, right answer was accepted
Show model Image in Editor Window
I am trying to make an editor that takes all the models (.dae) from a folder and load them into an window as buttons that are clickable during edit mode not play mode. Any help would be awesome.
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor(typeof(ObjectBuildingScript))]
public class ObjectBuilderEditor : Editor {
public override void OnInspectorGUI()
{
DrawDefaultInspector();
ObjectBuildingScript myScript = (ObjectBuildingScript)target;
if(GUILayout.Button("Build Object"))
{
myScript.BuildObject();
}
if(GUILayout.Button("Build Object2"))
{
myScript.BuildObject();
}
}
}
I have the above working to make the buttons on the editor but I need them to show and image of the models ins$$anonymous$$d of just being a plane button. I would also be willing to settle with just using a button texture I create.
Pass in a GUIContent to the button - GUIContent takes a Texture parameter. See the different Button overrides.
Ok so I see what your getting at there but my problem is, its an editor script so its not actualy on an object so I cant place the texture in public texture and set it for the button. What do I have to do different to make it use the texture for an editor script?
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor(typeof(ObjectBuildingScript))]
public class ObjectBuilderEditor : Editor {
public Texture tex;
public override void OnInspectorGUI()
{
DrawDefaultInspector();
ObjectBuildingScript myScript = (ObjectBuildingScript)target;
if(GUILayout.Button(tex))
{
myScript.BuildObject();
}
if(GUILayout.Button("Build Object2"))
{
myScript.BuildObject();
}
}
}
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Initialising List array for use in a custom Editor 1 Answer
Move Editor Button 1 Answer
Spawn with rotation of 90 on x axis. 1 Answer