void OnGUI() { var res = AssetDatabase.FindAssets("t:" + typeof(T).Name); T newData = null; //if there is only 1 then just load it if (res.Length == 1) { newData = AssetDatabase.LoadAssetAtPath <T>(AssetDatabase.GUIDToAssetPath(res[0])); } else { newData = (T)EditorGUILayout.ObjectField((string)"Target", data, typeof(T), true, null); GUILayoutHelper.DrawSpacerLine(Color.black); } if (newData != data) { data = newData; if (newData != null) { ed = Editor.CreateEditor(data); } else { ed = null; } scrollPos = Vector2.zero; } if (data != null && ed == null) { ed = Editor.CreateEditor(data); scrollPos = Vector2.zero; } if (ed != null) { scrollPos = EditorGUILayout.BeginScrollView(scrollPos); ed.OnInspectorGUI(); EditorGUILayout.EndScrollView(); } }
// Override the GUI drawing for this attribute public override void OnGUI(Rect position) { var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; position.y += divider.leadingSpace; var left = divider.TransformRectLeft(position); GUI.Box(left, GUIContent.none, GUILayoutHelper.GetTexColGUIStyle(divider.divLineCol)); if (divider.HasMsg) { var msgPos = divider.TransformRectMsg(position); GUI.Label(msgPos, divider.msg); var right = divider.TransformRectRight(position); GUI.Box(right, GUIContent.none, GUILayoutHelper.GetTexColGUIStyle(divider.divLineCol)); } EditorGUI.indentLevel = indent; }