Custom UI Element

You can create your own UI Element quite easily by implementing the IUIElement interface from the Runemark.Common namespace.

public class CustomUIElement : MonoBehaviour, IUIElement
{    
    // UI Manager filters the data based on keys.
    // If the data doesn't contain this key, UI Manager never
    // forwards that data to this element.
    public string Key => "myCustomKey";
    
    
    public void BuildContent(UIContentData data)
    {
        // content building logic comes here.
    }
}

You can use the IUIElementContainer interface instead. UIManager ignores the UIElements that are a child of the container and let the container handle the content building.

UI Content Data

Customizable Data class to transfer a variety of parameters to the UIManager. The class stores parameters in a key-value pair fashion.

// return the existing keys in this content
public List<string> Keys;

// Add a new paramter to the content 
// If the key already exist you can choose whether or not to overwrite.
public void Add(string key, object value, bool overwrite = false)

// Get the value of the given key (if none found use the default value)
public T Get<T>(string key, T defaultValue)

// Does the parameter with the given key match the type?
public bool IsType<T>(string key)

You can create your own content data by inheriting your class from UIContentData like the example below.

Last updated

Was this helpful?