mindlube
Topic Author
Posts: 9
Joined: 06 Apr 2014, 20:10

hit testing! how to suppress Input events in Unity?

08 Apr 2014, 01:57

working on the evaluation still...

I have a Button, and behind it is a collider with OnMouseDrag() OnMouseUp(), etc. How do I prevent the OnMouse* methods from running, if the player clicked or dragged on the button, for instance?

I have read the docs and searched the forums. I learned there is an example of HitTest() here,
http://www.noesisengine.com/docs/Gui.Co ... orial.html
But that's C++ code and I have no idea what the code context is or what those variables are. Can you provide some examples of how to suppress input events from the Unity C# side of things?

HitTesting is pretty basic requirement that pretty much everyone is going to run into sooner or later. It seems like there should be some code in Samples/ having to do with Hit testing?

Also Your C# plugin does not seem to have any code comments (in visual studio- all the methods I have looked at don't have any inline documentation). Is there a reason for this? For example- I am trying to figure out how to use
VisualTreeHelper.HitTest(). But the parameters are Noesis.Visual, and Noesis.Point. No idea how to find or create the required parameters, to perform the test.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: hit testing! how to suppress Input events in Unity?

09 Apr 2014, 19:06

You should use the VisualTreeHelper.HitTest() as follows:
// You can obtain the 'root' element through the NoesisGUIPanel component, GetRoot method
// The 'mousePos' in screen coordinates, with Y growing from top to bottom of the screen
HitTestResult hit = VisualTreeHelper.HitTest(root, mousepos);
if (hit.visualHit == null)
{
    // No UI element was hit
    // ...your collider code here
}
You are right, this code is very useful, and we should have some example of this in the documentation. We will add it in a following release.

About the lack of inline documentation in the C# classes, is because we are using SWIG to automatically create C# proxy classes from the native plugin classes. This tool does not embed the C++ documentation, but we are investigating the best way to incorporate it to the C# classes. Will be done as soon as possible.
 
mindlube
Topic Author
Posts: 9
Joined: 06 Apr 2014, 20:10

Re: hit testing! how to suppress Input events in Unity?

10 Apr 2014, 08:11

Thanks that is a lot simpler than I was expecting for some reason!

Who is online

Users browsing this forum: No registered users and 89 guests