private void UpdateIconText() { IconCharacterMapping mapping = IconsMap[icon]; textMeshComponent.font = mapping.IsCustom ? GetCustomIconFont() : GetOfficialIconFont(); textMeshComponent.text = mapping.IconCharacter; }
private void UpdateIconText() { IconCharacterMapping mapping = IconsMap[Icon]; #if (UNITY_EDITOR) Undo.RecordObject(textMeshComponent, "Icon Change"); string fontName = mapping.IsCustom ? CustomIconsAssetName : OfficialIconsAssetName; textMeshComponent.font = GetFontAsset(fontName); textMeshComponent.text = mapping.IconCharacter; PrefabUtility.RecordPrefabInstancePropertyModifications(textMeshComponent); #else textMeshComponent.font = mapping.IsCustom ? IconSource.Instance.CustomIconsFont : IconSource.Instance.OfficialIconsFont; textMeshComponent.text = mapping.IconCharacter; #endif }
private static Dictionary <IconKey, IconCharacterMapping> CreateIconMap() { Type iconKeyType = typeof(IconKey); Dictionary <IconKey, IconCharacterMapping> ret = new Dictionary <IconKey, IconCharacterMapping>(); foreach (IconKey iconKey in Enum.GetValues(iconKeyType)) { string iconName = Enum.GetName(iconKeyType, iconKey); FieldInfo field = iconKeyType.GetField(iconName); try { IconCharacterMapping mapping = (IconCharacterMapping)Attribute.GetCustomAttribute(field, typeof(IconCharacterMapping)); ret.Add(iconKey, mapping); } catch (TypeLoadException) { Debug.LogError("No IconCharacterMapping for " + iconName + ". Add an IconCharacterMapping attribute to the enum field in IconController.cs."); } } return(ret); }