public override void OnInspectorGUI() { var originalText = ((RinityText)target).originalText; var style = new GUIStyle(GUI.skin.FindStyle("HelpBox")); if (string.IsNullOrEmpty(originalText)) { originalText = ((RinityText)target).GetComponent <Text>().text; } var keys = SharedVariables.GetBoundKeys(originalText); style.richText = true; foreach (var key in keys) { originalText = originalText.Replace(key, "<b><color=blue>" + key + "</color></b>"); } EditorGUILayout.Space(); EditorGUILayout.LabelField(originalText, style); fold = EditorGUILayout.Foldout(fold, "TargetVariable(s)"); EditorGUI.indentLevel++; if (fold) { foreach (var key in keys) { EditorGUILayout.LabelField(key); } } EditorGUI.indentLevel--; }
void OnDisable() { var keys = SharedVariables.GetBoundKeys(originalText); foreach (var key in keys) { PubSub.UnsubscribeNotifyChange(key, handlers[key]); } handlers.Clear(); }
void OnEnable() { var keys = SharedVariables.GetBoundKeys(originalText); text.text = SharedVariables.Bind(originalText); foreach (var key in keys) { Action <IPubSubMessage> handler = (_message) => { var message = (NotifyChangeMessage)_message; text.text = SharedVariables.Bind(originalText); }; handlers[key] = handler; PubSub.SubscribeNotifyChange(key, handler); } }
public void UpdateTemplate(string templateString) { originalText = templateString; var keys = SharedVariables.GetBoundKeys(originalText); text.text = SharedVariables.Bind(originalText); foreach (var key in keys) { Action <IPubSubMessage> handler = (_message) => { var message = (NotifyChangeMessage)_message; text.text = SharedVariables.Bind(originalText); }; AddHandler(key, handler); } }