// Display text entered by the user in a paragraph element on the canvas. private void displayInputString(ref Binding binding) { // 1. Retrieve a Utml canvas element via its tag: UtmlElement outputElement = getElementByTag("outputParagraph"); // 2. Replace text contents on the UI element by the content supplied by the binding: outputElement.setLabel(binding.eventString); // 3. Set binding response code to OK, so the calling element may react accordingly: binding.responseCode = BindingResponse.OK; // NOTE: The response code is a direct feedback signal used by the binding system. // It is the major reason why 'binding' is passed by reference rather than by value, despite // it being a struct. The response code is reset to 'None' by the caller after processing it. }
public UtmlElement getElementByTag(string inTag) { if (string.IsNullOrEmpty(inTag)) { Debug.LogError("[UtmlCanvas] Error! Unable to get UI element using null or empty tag!"); return(null); } if (elements == null || elements.Count == 0) { Debug.LogError("[UtmlCanvas] Error! No elements were registered in canvas, cannot retrieve by tag!"); return(null); } // Try to find the element by its tag, then return result: UtmlElement element = null; elements.TryGetValue(inTag, out element); if (element == null) { Debug.LogError("[UtmlCanvas] Error! No element with tag '" + inTag + "' could be found!"); } return(element); }