Question by
SandorChickane · Jan 17, 2016 at 02:40 AM ·
unity 5editor window
Is it possible to add a sprite-picker in a custom Editor Window?
Hello,
I've been using a custom Editor Window to help create custom items for a game I'm working on. One of the properties of the items that I'm trying to assign with this window is the sprite to use for it in the inventory. I've searched far and wide, attempted to use pretty much every function and field, but I can't seem to find anything appropriate.
Is there a built in EditorGUILayout function or similar that adds an image or sprite picker to an editor window?
Thanks.
Comment
Best Answer
Answer by michaeleconomy · Aug 31, 2018 at 09:49 PM
This worked for me:
[CustomEditor(typeof(PlayerCharacter))]
public class PlayerCharacterEditor : CharacterEditor {
public override void OnInspectorGUI() {
var player = (PlayerCharacter)target;
player.headSprite = (Sprite) EditorGUILayout.ObjectField("Head", player.headSprite, typeof(Sprite));