-
- aliagha.huseynli
- Posts: 44
- Joined:
RiveApp Trigger issue
Hi Noesis team members,
I have a problem with using the Rive trigger type in C#
Any idea how can I use it in C# also how can I bind it within my xaml?
By the way, I can add other types such as boolean, number(float, int)
I have a problem with using the Rive trigger type in C#
Any idea how can I use it in C# also how can I bind it within my xaml?
By the way, I can add other types such as boolean, number(float, int)
Code: Select all
<NoesisGUIExtensions:RiveControl Height="500" Width="500" Source="/Assets/App/TestRive/Anchor_Cannon.riv">
<!--#region Boolean-->
<NoesisGUIExtensions:RiveInput InputName="IsThrow" InputValue="{Binding IsThrow}"/>
<NoesisGUIExtensions:RiveInput InputName="IsDown" InputValue="{Binding IsDown}"/>
<!--#endregion-->
<!--#region Number-->
<NoesisGUIExtensions:RiveInput InputName="AnchorReload" InputValue="{Binding AnchorReload}"/>
<!--#endregion-->
</NoesisGUIExtensions:RiveControl> -
-
sfernandez
Site Admin
- Posts: 3364
- Joined:
Re: RiveApp Trigger issue
If you are referring to the RiveTriggerAction, it is defined as an interactivity action you can use in response to any interactivity trigger as shown in the documentation example.
If you want to trigger the action from C# you can use the DataEventTrigger and just raise an event that you will be listening from the xaml.
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
<noesis:RiveControl x:Name="rive" Source="player.riv"/>
<Button Content="{Binding PlayerName}">
<b:Interaction.Triggers>
<b:EventTrigger EventName="Click">
<noesis:RiveTriggerAction TargetName="rive" TriggerName="Fire"/>
</b:EventTrigger>
</b:Interaction.Triggers>
</Button>
</Grid>-
- aliagha.huseynli
- Posts: 44
- Joined:
Re: RiveApp Trigger issue
Thanks but it is outdated documentation. And with all due respect, it is horrible :)If you are referring to the RiveTriggerAction, it is defined as an interactivity action you can use in response to any interactivity trigger as shown in the documentation example.If you want to trigger the action from C# you can use the DataEventTrigger and just raise an event that you will be listening from the xaml.Code: Select all<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"> <noesis:RiveControl x:Name="rive" Source="player.riv"/> <Button Content="{Binding PlayerName}"> <b:Interaction.Triggers> <b:EventTrigger EventName="Click"> <noesis:RiveTriggerAction TargetName="rive" TriggerName="Fire"/> </b:EventTrigger> </b:Interaction.Triggers> </Button> </Grid>
It does not show me any path I can follow. This one as well (https://www.noesisengine.com/docs/App.R ... ntrol.html)
Do you believe that to call or reach this Rive input from .xaml to my C# code I watched a video from YouTube at 21:51 I saw the code which I want (https://youtu.be/F6Q4pfnBhbI)
It should be in the documentation not in the video ))
Anyway...
Now I need a similar version of the code example to know how can I use it.
Can you help me with this?
Thanks in advance :)
https://ibb.co/b1cj3q5
https://ibb.co/3RcRBvK
Code: Select all
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:NoesisGUIExtensions="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" x:Class="Testing.TestEventTrigger"
x:Name="Root" Width="1920" Height="1080">
<Grid>
<NoesisGUIExtensions:RiveControl Height="500" Width="500" Source="/Assets/App/TestEventTrigger/Shapes.riv"/>
<NoesisGUIExtensions:RiveTriggerAction TargetName="rive" TriggerName="Fire"/>
</Grid>
</UserControl>Code: Select all
using UnityEngine;
using Noesis;
using NoesisGUIExtensions;
public class TestEventTriggerViewModel : MonoBehaviour
{
private void Start()
{
}
private void Update()
{
}
}
-
-
sfernandez
Site Admin
- Posts: 3364
- Joined:
Re: RiveApp Trigger issue
In what sense is outdated? The sample included in that document is functional.it is outdated documentation
Well, there is always room for improvement. What are you missing from that class documentation? The code/data binding stuff? There is more documentation about code-behind and data binding topics in other tutorials.And with all due respect, it is horrible :)
From your first message I understood you already had the bool/number inputs working. So you probably had a ViewModel exposing bool/number properties, and already notifying of changes, and the ViewModel set as DataContext of the xaml. And if your question was about the RiveTriggerAction and how to trigger it from C# the best option is to expose an event in your ViewModel and use the DataEventTrigger in xaml as I mentioned. The C# code will look like this:It does not show me any path I can follow.
Code: Select all
public class RiveTriggerViewModel : MonoBehaviour
{
public event EventHandler OnStar;
private void RaiseOnStar() { OnStar?.Invoke(this, EventArgs.Empty); }
void Start() {
NoesisView view = GetComponent<NoesisView>();
view.Content.DataContext = this;
}
void Update() {
if (Input.GetKeyDown(KeyCode.Space))
RaiseOnStar();
}
}Code: Select all
<Grid>
<b:Interaction.Triggers>
<NoesisGUIExtensions:DataEventTrigger Source="{Binding}" EventName="OnStar">
<NoesisGUIExtensions:RiveTriggerAction TargetName="rive" TriggerName="OnStar"/>
</NoesisGUIExtensions:DataEventTrigger>
</b:Interaction.Triggers>
<NoesisGUIExtensions:RiveControl x:Name="rive" Height="500" Width="500" Source="/Assets/App/TestEventTrigger/Shapes.riv"/>
</Grid>-
- aliagha.huseynli
- Posts: 44
- Joined:
Re: RiveApp Trigger issue
Thanks for your time. Right now it works how it should be.
Who is online
Users browsing this forum: No registered users and 10 guests