private static void GetAvailableDataTypes(out Type[] types, out string[] labels) { types = ScriptableDataUtilities.GetAllDataTypes().OrderBy(type => type.FullName).ToArray(); labels = new string[types.Length + 1]; // First option is always none labels[0] = "None"; for (int i = 0; i < types.Length; i++) { labels[i + 1] = $"{types[i].Name} ({types[i].FullName})"; } }
public static void GenerateMissingTypes() { var missingTypes = ScriptableDataUtilities.GetMissingDataTypes(); if (missingTypes.Count > 0) { Logger.Log(GetTypeGenLogMessage(missingTypes)); GenerateForDataTypes(missingTypes.ToArray()); } else { Logger.Log("No missing types were found, doing nothing."); } }
public static void GenerateAllTypes() { var types = ScriptableDataUtilities.GetAllDataTypes(); if (types.Count > 0) { Logger.Log(GetTypeGenLogMessage(types)); GenerateForDataTypes(types.ToArray()); } else { Logger.Log("No scriptable data types were found, doing nothing."); } }
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(); } }