I’m working on a Custom Inspector for a Class file that contains a List<> of Items, each item has various settings and I’d like to display only a few of these in a custom format, I’ve managed to get what I want using the code below but I can’t seem to figure out how to display the Icon of the right properly (or to the left with the text to the right of the Icon).
I’ve tried to use an Offset value which works until it gets to the fifth Item and then it gets a bit hectic by about 10-20f per Icon after that, clipping through the Item below.
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor(typeof(ItemDatabase))]
public class ItemDatabaseEditor : Editor {
public override void OnInspectorGUI() {
ItemDatabase m_ItemDatabase = (ItemDatabase)target;
m_ItemDatabase.transform.hideFlags = HideFlags.HideInInspector;
if (m_ItemDatabase.autoUpdate) {
m_ItemDatabase.EditorCreate ();
}
EditorGUILayout.Space ();
EditorGUILayout.Space ();
EditorGUILayout.HelpBox ("Create items inside of ItemDatabase.cs", MessageType.Info);
EditorGUILayout.Space ();
for (int i = 0; i < m_ItemDatabase.itemDatabase.Count; i++) {
GUILayout.BeginVertical ("BOX");
//Texture2D texture = Resources.Load <Texture2D> ("Sprites/Icons/" + m_ItemDatabase.itemDatabase *.itemName);*
-
//GUILayout.Label (texture);*
EditorGUILayout.LabelField (m_ItemDatabase.itemDatabase .itemID.ToString() + " - " + m_ItemDatabase.itemDatabase .itemName, EditorStyles.boldLabel);
EditorGUILayout.LabelField ("Value: "+m_ItemDatabase.itemDatabase .itemValue.ToString());
EditorGUILayout.LabelField ("Strength: "+m_ItemDatabase.itemDatabase .itemStrength.ToString());
EditorGUILayout.LabelField ("Type: "+m_ItemDatabase.itemDatabase .itemType.ToString());
EditorGUILayout.LabelField ("Description: "+m_ItemDatabase.itemDatabase .itemDescription);
* GUILayout.EndVertical ();*
* }*
* EditorGUILayout.Space ();*
* EditorGUILayout.Space ();*
* }*
}
I’ve read up on a few related Questions and Forum Posts but I can’t seem to find a way to position them and using the non EditorGUI that requires a Rect doesn’t seem to work as well.