Page 2 of 3
Re: Gamepad Support?
Posted: 10 Aug 2014, 23:32
by jsantos
Because I need to get that element from the script code using FindName:
var start = root.FindName<Button>("start");
start.Focus()
That way, the focus starts in the centered button.
Re: Gamepad Support?
Posted: 11 Aug 2014, 02:32
by S0L0
I am liking XAML the more I learn it.
Now I am trying to have the menu slide in by playing an animation on the grid when DPadUp is pressed, however it doesn't seem to be working correctly. Also, is it possible to play the animation in reverse when for example menuOnScreen = true?
using System;
using UnityEngine;
using InControl;
using Noesis;
namespace BasicExample
{
public class Controller : MonoBehaviour
{
NoesisGUIPanel noesisGUI_;
private Storyboard _ani;
private Grid _root;
void Start()
{
noesisGUI_ = GetComponent<NoesisGUIPanel>();
var root = noesisGUI_.GetRoot<Grid>();
_ani = root.FindStringResource<Storyboard> ("animation");
var start = root.FindName<Button>("start");
start.Focus();
}
private void Handle(OneAxisInputControl input, Noesis.Key key)
{
if (input.WasPressed)
{
noesisGUI_.KeyDown(key);
}
if (input.WasReleased)
{
noesisGUI_.KeyUp(key);
}
}
private void Handle(InputControl input, Noesis.Key key)
{
if (input.WasPressed)
{
noesisGUI_.KeyDown(key);
}
if (input.WasReleased)
{
noesisGUI_.KeyUp(key);
}
}
void Update()
{
// Use last device which provided input.
var inputDevice = InputManager.ActiveDevice;
//Menu Navigation
Handle(inputDevice.DPadLeft, Key.Left);
Handle(inputDevice.DPadRight, Key.Right);
//Menu Toggle
if (inputDevice.DPadUp.WasPressed)
{
_ani.Begin(_root);
}
//Button
Handle(inputDevice.DPadDown, Key.Space);
}
}
}
Re: Gamepad Support?
Posted: 12 Aug 2014, 15:43
by jsantos
I am liking XAML the more I learn it.
Now I am trying to have the menu slide in by playing an animation on the grid when DPadUp is pressed, however it doesn't seem to be working correctly. Also, is it possible to play the animation in reverse when for example menuOnScreen = true?
Hi!
What is the problem with the animation? Does it behave properly on Blend? The way you are activating it seems to be correct.
You can activate AutoReverse in the animations but I think that is not what you want. I think you will have to create two animations, one forward and another backward.
Re: Gamepad Support?
Posted: 12 Aug 2014, 23:22
by S0L0
Re: Gamepad Support?
Posted: 12 Aug 2014, 23:30
by jsantos
Have you verified that _root and _ani are not null?
Please, paste us here the entire XAML you are using.
Re: Gamepad Support?
Posted: 12 Aug 2014, 23:33
by S0L0
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid.Resources>
<Storyboard x:Key="animation">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="grid">
<EasingDoubleKeyFrame KeyTime="0" Value="-85.5"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<Grid x:Name="grid" HorizontalAlignment="Center" VerticalAlignment="Top" KeyboardNavigation.DirectionalNavigation="Cycle" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Grid.RenderTransform>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Button Content="Button" Padding="20" FontSize="20" Grid.Row="1" Grid.Column="0" />
<Button Content="Button" x:Name="start" Padding="20" FontSize="20" Grid.Row="1" Grid.Column="1" />
<Button Content="Button" Padding="20" FontSize="20" Grid.Row="1" Grid.Column="2" />
</Grid>
</Grid>
Re: Gamepad Support?
Posted: 12 Aug 2014, 23:50
by jsantos
The problem is at this line of your code:
var root = noesisGUI_.GetRoot<Grid>();
it should be:
_root = noesisGUI_.GetRoot<Grid>();
Although I would expect an error in the C# (null object or something like that) instead of a crash error in C land. I will investigate it.
Re: Gamepad Support?
Posted: 12 Aug 2014, 23:56
by S0L0
Re: Gamepad Support?
Posted: 12 Aug 2014, 23:58
by jsantos
It is the same error. Are you sure you updated the script? It is working fine here:
using System;
using UnityEngine;
using InControl;
using Noesis;
namespace BasicExample
{
public class Controller : MonoBehaviour
{
NoesisGUIPanel noesisGUI_;
private Storyboard _ani;
private Grid _root;
void Start()
{
noesisGUI_ = GetComponent<NoesisGUIPanel>();
_root = noesisGUI_.GetRoot<Grid>();
_ani = _root.FindStringResource<Storyboard>("animation");
var start = _root.FindName<Button>("start");
start.Focus();
}
private void Handle(OneAxisInputControl input, Noesis.Key key)
{
if (input.WasPressed)
{
noesisGUI_.KeyDown(key);
}
if (input.WasReleased)
{
noesisGUI_.KeyUp(key);
}
}
private void Handle(InputControl input, Noesis.Key key)
{
if (input.WasPressed)
{
noesisGUI_.KeyDown(key);
}
if (input.WasReleased)
{
noesisGUI_.KeyUp(key);
}
}
void Update()
{
// Use last device which provided input.
var inputDevice = InputManager.ActiveDevice;
//Menu Navigation
Handle(inputDevice.DPadLeft, Key.Left);
Handle(inputDevice.DPadRight, Key.Right);
//Menu Toggle
if (inputDevice.DPadUp.WasPressed)
{
_ani.Begin(_root);
}
//Button
Handle(inputDevice.DPadDown, Key.Space);
}
}
}
Re: Gamepad Support?
Posted: 13 Aug 2014, 00:02
by S0L0
Its working now, thanks again.