joshmond
Topic Author
Posts: 22
Joined: 02 Jun 2018, 00:10

A few questions about working with Noesis and Unity

17 Nov 2020, 06:27

Hello guys, after playing around with Noesis I was able to get some simple UI's set up with Unity and get basic interaction but I have a few questions about the general workflow. The first question I have is whether or not I can interact with views/UI's without making the ViewModel a Monobehaviour. For example, take the "NorthGame" example, would it be possible to create a menu that complex where the user could interact with it using a gamepad and not have to create a Monobehaviour class to do so or does all interaction within Unity need the ViewModels to be a Monobehaviour?

The second question I have is whether or not it is possible to have the user interact with a Noesis menu or UI element using Unity's new input system?

Thanks

-Joshmond

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 2327
Joined: 22 Dec 2011, 19:20

Re: A few questions about working with Noesis and Unity

17 Nov 2020, 11:47

For example, take the "NorthGame" example, would it be possible to create a menu that complex where the user could interact with it using a gamepad and not have to create a Monobehaviour class to do so or does all interaction within Unity need the ViewModels to be a Monobehaviour?
ViewModels don't need to be MonoBehaviors to interact with the View (although it could be handy sometimes to directly edit properties within Unity editor). Communication between the View and ViewModel should be done (if following the recommended MVVM pattern) using bindings to properties and commands.

Then input iteraction from a gamepad is just about handling the keyboard focus in the view. If you set the focus to a Button in your view, for example using interactivity:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
  <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" KeyboardNavigation.DirectionalNavigation="Cycle">
    <Button Content="First">
      <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
          <noesis:SetFocusAction />
        </i:EventTrigger>
      </i:Interaction.Triggers>
    </Button>
    <Button Content="Second"/>
    <Button Content="Third"/>
  </StackPanel>
</Grid>
Then Noesis plugin will take care of moving the focus when you use the gamepad left analog stick or D-pad. You don't need a MonoBehavior polling Input to do that, we already provide a mapping in InputManager for the gamepad, and you can configure it for your needs.
The second question I have is whether or not it is possible to have the user interact with a Noesis menu or UI element using Unity's new input system?
As I said in other ticket, it is not yet supported but we are implementing it for a future release: #1828.

Who is online

Users browsing this forum: Bing [Bot] and 3 guests