<ExampleView>
<UserInterface>
<Button Text="Play" Click="StartGame" />
</UserInterface>
<EventSystem />
</ExampleView>
public class ExampleView : View
{
public void StartGame()
{
Debug.Log("Play Clicked");
}
}
[ExcludeComponent("ImageComponent")]
[HideInPresenter]
public class Label : UIView
{
Class Attribute | Description |
---|---|
HideInPresenter | When specified the view is not shown in the view presenter's main view selection. Used to not clutter up the main view selection with views only intended to be used internally in other views. |
ExcludeComponent | When encountering a component field in the view the processor automatically adds the component to the view. This attribute tells the processor to not add component associated with the specified field. Used primarily to exclude one graphic component so it can be replaced with another since Unity doesn't allow multiple graphic components to be added to a view. |
MapViewField | Allows you to map one view field to another on the class level. Usually MapTo is used when mapping fields but in some cases such as when view actions are mapped you'd want to use this instead. |
public class Example : UIView
{
public string Text;
}
<Example Text="Example Text" />
SetValue(() => Text, "Test"); // sets Text = "Test" and notifies observers
SetValue(() => ChildView.Orientation, Orientation.Horizontal);
public class Example : UIView
{
public _string Text;
}
Text.Value = "Test"; // sets value and notifies observers
Text.DirectValue = "Test"; // sets value without notifying observers
public class Example : UIView
{
public Label MyLabel;
}
<Example>
<Label Id="MyLabel" />
</Example>
<Example MyLabel.Text="Label Text" />
public class Example : UIView
{
public UnityEngine.UI.Text TextComponent;
}
<Example TextComponent.text="Example Text" />
public class TriggerExample : UIView
{
public ViewAction MyCustomAction;
}
public class ListenExample : UIView
{
public void MyCustomActionHandler(Example source, string data)
{
}
}
<ListenExample>
<TriggerExample MyCustomAction="MyCustomActionHandler" />
</ListenExample>
public class TriggerExample : UIView
{
public ViewAction Click;
}
public class Example : UIView
{
public UnityEngine.UI.Text TextComponent;
}
<Example TextComponent.text="Example Text" />
public class Example : UIView
{
[MapTo("TextComponent.text")]
public _string GameTitle;
public UnityEngine.UI.Text TextComponent;
}
GameTitle.Value = "Example Text";
<Example GameTitle="Example Text" />
public class Example : UIView
{
[ChangeHandler("TextChanged")]
public _string Text;
public virtual void TextChanged()
{
// called once at init and whenever text changes value
}
}
[MapTo("TextComponent.text", "TextChanged")]
public _string Text;
public class Example : UIView
{
public _string Player;
}
<Example Player="Default Player">
</Example>
public override void Initialize()
{
base.Initialize();
// populate runtime data, do lookups, etc.
}
Be notified when new themes, views, tutorials and updates are available