private void Init() { text = component.GetComponent <Text>(); UITextStyleManager.Init(); styleDataDic = UITextStyleManager.styleDataDic; oldData = UITextStyleManager.GetTextStyleDataFromText(text); }
// Update is called once per frame public void SetTextStyleData(SystemLanguage language) { if (text == null) { text = GetComponent <Text>(); } if (string.IsNullOrEmpty(styleName)) { return; } UITextStyleManager.SetText(text, styleName, language); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); obj = (UITextStyleComponent)target; if (text == null) { text = obj.GetComponent <Text>(); } if (GUILayout.Button("Open Editor Window")) { UITextStyleManager.GetTextStyleDataFromText(text); UITextStyleManagerWindow.OpenWindow(obj); } }
private void OnGUI() { EditorGUILayout.ObjectField(text, typeof(Text), true); GUILayout.Space(5); name = EditorDrawGUIUtil.DrawBaseValue("Name", name).ToString(); language = (SystemLanguage)EditorDrawGUIUtil.DrawBaseValue("Language", language); if (GUILayout.Button("添加")) { if (string.IsNullOrEmpty(name)) { return; } if (UITextStyleManager.ContainsData(name, language)) { return; } else { Dictionary <SystemLanguage, TextStyleData> data = null; if (styleDataDic.ContainsKey(name)) { data = styleDataDic[name]; } else { data = new Dictionary <SystemLanguage, TextStyleData>(); styleDataDic.Add(name, data); } TextStyleData sd = UITextStyleManager.GetTextStyleDataFromText(text); data.Add(language, sd); } } GUILayout.Space(6); EditorDrawGUIUtil.DrawScrollView(this, () => { foreach (var item in styleDataDic) { GUILayout.BeginHorizontal(); GUILayout.Box(item.Key); GUILayout.FlexibleSpace(); if (GUILayout.Button("-")) { styleDataDic.Remove(item.Key); return; } GUILayout.EndHorizontal(); foreach (var d in item.Value) { GUILayout.BeginHorizontal(); EditorDrawGUIUtil.DrawFoldout(d.Key, d.Key.ToString(), () => { GUILayout.BeginVertical(); EditorDrawGUIUtil.DrawClassData("", d.Value); if (GUILayout.Button("Show")) { UITextStyleManager.SetText(text, item.Key, d.Key); } GUILayout.EndVertical(); }); GUILayout.FlexibleSpace(); if (GUILayout.Button("-")) { styleDataDic[item.Key].Remove(d.Key); return; } GUILayout.EndHorizontal(); } } }); // EditorDrawGUIUtil.DrawDictionary("", styleDataDic); GUILayout.FlexibleSpace(); if (GUILayout.Button("Save")) { UITextStyleManager.SaveData(styleDataDic); } GUILayout.Space(5); }
private void OnDestroy() { UITextStyleManager.SetText(text, oldData); }