// TODO: This needs more testing with more complex data types. private static void DrawDataRegion(SerializedProperty property) { GUILayout.BeginVertical("GroupBox"); foreach (var dataProperty in SerializedObjectUtilities.EnumerateChildProperties(property)) { EditorGUILayout.PropertyField(dataProperty); } GUILayout.EndVertical(); }
public override void OnInspectorGUI() { EditorGUILayout.LabelField("Data Type", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); m_index = EditorGUILayout.Popup(label: s_dataTypeLabel, selectedIndex: m_index, m_labels); if (EditorGUI.EndChangeCheck()) { if (m_index < 1) { var script = MonoScript.FromScriptableObject(ScriptableObject.CreateInstance <DataContainer>()); SerializedObjectUtilities.SetScriptType(serializedObject, script); } else if (m_index <= m_types.Length) { int typeIndex = m_index - 1; var selectedDataType = m_types[typeIndex]; if (ScriptableDataUtilities.TryFindScriptForDataContainer(selectedDataType, out MonoScript script)) { SerializedObjectUtilities.SetScriptType(serializedObject, script); } else { Logger.LogError($"Failed to find MonoScript for scriptable data with data type {selectedDataType}."); } } // Return early to avoid errors. return; } EditorGUILayout.Space(); EditorGUILayout.LabelField("Serialized Data", EditorStyles.boldLabel); if (m_dataProperty != null) { DrawDataRegion(m_dataProperty); } else { DrawNoTypeInfoBox(); } }