예제 #1
0
    /// <summary>
    /// Set up the GUI.
    /// </summary>
    private void SetUpGUI()
    {
        // First, create an instance of the view we want to bind the GUI to
        var viewModel = new ExampleView();

        // Set up the GUI widgets
        gui = new UnityEditorUI.GUI();
        gui.Root()
        .Label()
        .Text.Value("My new editor window")
        .End()
        .Button()
        .Text.Value("Do something!")
        .Click.Bind(() => viewModel.DoSomething())
        .Tooltip.Value("Click to trigger an event")
        .End();

        // Bind the resulting GUI to the view.
        gui.BindViewModel(viewModel);
    }
예제 #2
0
    /// <summary>
    /// Set up the GUI.
    /// </summary>
    private void SetUpGUI()
    {
        // First, create an instance of the view we want to bind the GUI to
        var viewModel = new ExampleView();

        // Set up the GUI widgets
        gui = new UnityEditorUI.GUI();
        gui.Root()
        .Label()
        .Text.Value("Object movement tool")
        .Bold.Value(true)
        .End()
        .HorizontalLayout()
        .Label()
        .Text.Value("Object to look for")
        .End()
        .TextBox()
        .Text.Bind(() => viewModel.SelectedObjectName)
        .End()
        .End()
        .Vector3Field()
        .Label.Value("Position")
        .Vector.Bind(() => viewModel.ObjectPosition)
        .End()
        .Button()
        .Text.Value("Capture position")
        .Click.Bind(() => viewModel.CaptureObjectPosition())
        .End()
        .Button()
        .Text.Value("Set position")
        .Click.Bind(() => viewModel.SetObjectPosition())
        .End();

        // Bind the resulting GUI to the view.
        gui.BindViewModel(viewModel);
    }