void AddField(ThemeFieldType fieldType) { switch (fieldType) { case ThemeFieldType.Color: if (asset.Colors == null) { asset.Colors = new string[0]; } ArrayUtility.Add(ref asset.Colors, "ColorKey"); showColorKeys = true; break; case ThemeFieldType.Font: if (asset.Fonts == null) { asset.Fonts = new string[0]; } ArrayUtility.Add(ref asset.Fonts, "FontKey"); showFontKeys = true; break; case ThemeFieldType.Sprite: if (asset.Sprites == null) { asset.Sprites = new string[0]; } ArrayUtility.Add(ref asset.Sprites, "SpriteKey"); showSpriteKeys = true; break; } }
void RemoveField(string field, ThemeFieldType fieldType) { switch (fieldType) { case ThemeFieldType.Color: ArrayUtility.Remove(ref asset.Colors, field); break; case ThemeFieldType.Font: ArrayUtility.Remove(ref asset.Fonts, field); break; case ThemeFieldType.Sprite: ArrayUtility.Remove(ref asset.Sprites, field); break; } }
public void DrawFieldList(string[] fields, ThemeFieldType fieldType) { string remove = null; EditorGUILayout.BeginVertical(GUI.skin.box); if (fields != null) { for (int i = 0; i < fields.Length; i++) { EditorGUILayout.BeginHorizontal(); fields[i] = EditorGUILayout.TextField(fields[i]); if (GUILayout.Button("Remove")) { remove = fields[i]; } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); if (remove != null) { RemoveField(remove, fieldType); } }