-
- RisingSunStudios
- Posts: 21
- Joined:
How to access NoesisView from a TriggerAction
Hi,
I have a NoesisApp.TriggerAction that I would like to access the NoesisView to interact with the InputAction asset assigned to it.
Any idea how I can access the NoesisView monobehavior component from inside a trigger?
I have a NoesisApp.TriggerAction that I would like to access the NoesisView to interact with the InputAction asset assigned to it.
Any idea how I can access the NoesisView monobehavior component from inside a trigger?
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: How to access NoesisView from a TriggerAction
Hi,
All AttachableObjects (the base class for TriggerAction) expose a View property. You can use that to find the corresponding NoesisView component available in your scene:
Is this what you're looking for?
All AttachableObjects (the base class for TriggerAction) expose a View property. You can use that to find the corresponding NoesisView component available in your scene:
Code: Select all
protected override void Invoke(object parameter)
{
NoesisView[] noesisViews = GetComponents<NoesisView>();
for (int i = 0; i < noesisViews.Length; i++)
{
if (noesisViews[i].Content.View == View)
{
// do whatever you need with noesisViews[i]
break;
}
}
}-
- RisingSunStudios
- Posts: 21
- Joined:
Re: How to access NoesisView from a TriggerAction
Hi sorry for late reply,
That is what I'm after yes, but for NoesisApp.TriggerAction<T> I do not have a GetComponents<T>() method in 3.2.8 - is that an extension method?
That is what I'm after yes, but for NoesisApp.TriggerAction<T> I do not have a GetComponents<T>() method in 3.2.8 - is that an extension method?
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: How to access NoesisView from a TriggerAction
I meant to use any API Unity provides to access the desired GameObjects and find all the NoesisView components to search for the correct one.
Sorry for the misunderstanding.
Sorry for the misunderstanding.
-
- RisingSunStudios
- Posts: 21
- Joined:
Re: How to access NoesisView from a TriggerAction
I'm not sure I understand, there is no game object associated with a NoesisApp.TriggerAction so I can't access the Unity API to get the view unless you mean the static search methods
If you mean to use the static Unity API like GameObjects.FindWithTag() then sure as a workaround, but I guess the answer is no, you can't get the NoesisView from the TriggerAction itself
Code: Select all
protected override void Invoke(object parameter)
{
NoesisView[] noesisViews = GetComponents<NoesisView>(); // how is this possible?
}
}-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: How to access NoesisView from a TriggerAction
I was referring to the static Unity methods, yes. Sorry for the confusion.
There is no reference from UI elements to the NoesisView component, only to the core View where they are placed.
Perhaps we can store a list of all created NoesisView components and expose a static method in the NoesisView to do something like:
Could that work for you?
There is no reference from UI elements to the NoesisView component, only to the core View where they are placed.
Perhaps we can store a list of all created NoesisView components and expose a static method in the NoesisView to do something like:
Code: Select all
protected override void Invoke(object parameter)
{
NoesisView view = NoesisView.FromView(this.View);
...
}-
- RisingSunStudios
- Posts: 21
- Joined:
Re: How to access NoesisView from a TriggerAction
Hey yeah something like that would work great, but if there's a reason you'd prefer not to do this that is perfectly understandable.
Personally I try to avoid using the static Unity api as much as possible, especially for referencing GameObjects. In our current project we don't have a large number of noesis views so tagging them and using FindByTag() won't be a problem. I was just hoping there was some way to get it via the View, casting it to an interface or something that I may have missed!
Personally I try to avoid using the static Unity api as much as possible, especially for referencing GameObjects. In our current project we don't have a large number of noesis views so tagging them and using FindByTag() won't be a problem. I was just hoping there was some way to get it via the View, casting it to an interface or something that I may have missed!
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: How to access NoesisView from a TriggerAction
Ok, if you feel a method like that would be helpful for you please create a ticket in our bugtracker and we will try to implement it.
Thanks for your feedback.
Thanks for your feedback.
Who is online
Users browsing this forum: No registered users and 5 guests