// Tries to add a callback to the NamedEvent based on the given node name. // The callback parameter is assigned the value associated with the node. private void TryAddCallback <T>(string nodeName, EventCallback <T> callback) { T value; if (nodeReader.TryGet(nodeName, out value)) { currentEvent.AddCallback(() => callback(value)); } }
// Tries to add a single-argument callback to the NamedEvent based on // the given node name. // The callback parameter is assigned the value associated with the node. private void TryAddCallback <T>(string nodeName, EventCallback <T> callback) { T value; if (nodeReader.TryGet(nodeName, out value)) { string description = string.Format(nameToDescription[nodeName], value); currentEvent.AddCallback(() => callback(value), description); } }
// Retrieves ("translates") a string using the current language file. // The given key argument is the key to retrieve the corresponding // string value from in the language file. public string Translate(string translationKey) { string result; if (translationReader.TryGet(translationKey, out result)) { return(result); } else { string errorStr = "ERROR IN Translator.Translate: Couldn't find translation key: " + translationKey; Debug.LogError(errorStr); return(errorStr); } }