anylogic: detect mouse click pressed and release events - anylogic

On any image or many other objects there is an onClick action that I can use. But I am interested in the mouse click pressed and release events, as user is dragging the mouse in between these events. Finally I want to capture the coordinates at which click happened and at which release happened. Is it possible?

Tracking click-pressed and release events are not possible anymore since AnyLogic switched to browser-based animations (used to be possible in AnyLogic 6 with Java Swing).
Getting click coordinates, however, is possible. Just drag in a rectangle (or some other shape) and you have a handle as below. Note that these are relative to the shape's position:

Related

World space button click event to take priority over the collider's click event it's inside?

Short story:
I have a button on a world space canvas with a click event handler. This is inside (in 3d space not parenting) of a 3d collider with it's own click event.
The collider always gets the click event as expected as it's nearer the camera.
I want the button to get the event.
Long Story:
I have a person mesh with a collider. You can click on them and the OnPointerClick triggers to do something.
I have a button that sits in a world space canvas which itself is located just above the mesh and is pointed towards the orthographic camera. You click on the coin and the OnClick event triggers to do something else.
Both events work as expected until the coin is inside the mesh's collider (which it is a lot of the time). At which point it's ONLY the mesh collider's OnPointerClick event triggers, not the button.
However, I ALWAYS want the button to take priority over the collider, and any other collider. This is easier when the canvas is screen space, but it's not (with reason).
How do I do this?
NOTES:
The button never gets the onclick event, so any filtering on the containing collider won't help
I've fiddled with the world space canvas and camera ray filtering settings to no effect.
The coin has to be a world space canvas for automatic tracking and because I use text too
IsPointerOverGameObject doesn't help as it's true for any collider, not just UI elements. Not to mention it wont stop the collider consuming the click anyway. A custom version of this that works via a layer wont help either, because again the OnPointerClick on the collider GO stil consumes the click.
I don't want either event to have to do any event filtering & passing on if possible, they should be atomic. Any filtering should be via setting properties in objects and inherent functionality of Unity if possible
Just to reiterate, writing a function to find all objects in the ray and then selecting ones that are on the UI layer first wont help. Because that does not change the fact that the collider still is the only thing that gets the event, which then you'd have to manually propagate down to the button.. which I don't want to do.
I've been able to fix this by putting the button's world space canvas on a sorting layer of 1. That way, even if it's behind colliders, it will register first.
Nice and clear solution that I was hoping would exist.

Cursor doesn't gaze on my UI Slider when deployed in the Hololens

Based on this repo https://github.com/qian256/ur5_unity. I am trying to get this working with some modifications, as I need. You can also see the issue in this repo.
I am unable to get the sliders move when I deploy it in the Hololens. I have a cursor that can gaze over the robot body but doesn't gaze on the slider bar or handle. I have tried most of the suggestions online including setting canvas to world-space.
I have already tried this out: HoloLens - UI/Slider and Cursor do not intersect during gaze
Without knowing more, if you can debug, set a breakpoint, and try to determine which object is being hit by your raycast, If it is an object behind your slider, then you need to adjust the layer of your slider object to be the top most layer and not shared by other game objects. If it is your slider, you might try and use the pinch and hold event, and detect which direction the user is pulling and then adjust the slider value manually.
The gaze would use Physics.Raycast thereby a Collider is required to gaze at somethiing. You can set quad primitives into your UI (with Canvas set to World Space with proper camera) by removing the MeshRenderer component but keeping the Collider one. You would then need to handle yourself gaze events for your UI e.g. gazing upper side of quad, you would manually move the slider up, etc.
Don't have 50 rep otherwise I would have commented but, I answered a very similar question here dealing with if your cursor goes through your UI element.
In the canvas I loose the cursor
However, if the problem is just that you can't move the cursor then, you need to make sure you have subscribed to the scroll/manipulation events for your cursor. You can test this to see if this is the case by just clicking on the slider in a different spot and the slider should jump to the spot you clicked.

UE4 Enabling Mouse During Play?

I'm extremely new to UE, and doing a few easy tutorials to get started, so I don't exactly know the correct terminology to use to help me find what I am looking for... Anyway, whenever I hit play and the game starts, my mouse disappears and I am only able to use the input that I set up; so my question is, even though I do not need mouse input for movement, as I am using WASD, how do I keep my mouse unlocked and available to move around without being locked to the camera?
When you hit play and the game starts, your mouse gets captured by the game to control the camera. If your play button is set to play in the viewport, you can release the mouse from the viewport by pressing Shift-F1. The game will still be running, but input (including from the keyboard) will be suspended and you can interact with the editor.
You can also change the default behavior of how the mouse is captured and it if is constrained to the viewport boundaries. To see these options, go into the project settings (settings button above main viewport/project settings...). On the left side of the project settings window, select 'Input' under the Engine heading. On the right side will be some mouse preferences that can change its behavior.
For instance, to allow the mouse to travel outside the viewport, change 'Default Viewport Mouse Lock Mode' to 'Do Not Lock'. I don't recommend this, but you might experiment with these to get a feel for what they do. Also, you might look up these settings in the Unreal documentation for more detail.
There are 3 blueprint nodes that change the input method:
Set Input Mode Game
Set Input Mode Game and UI
Set Input Mode UI
You want a combination of the second one and a "Show Mouse Cursor" node. However, if you are making an FPS and you use the mouse to look around, you may lose that ability with the second node above. It comes down to what your game is and how you want to use the mouse.
I had the similar issue. So I did something like this in Level Blueprints to achieve what I want.

Allowing click or raycast to only certain items at time

This is kind of hard to explain so I try to do my best using the following image.
So the case is this: player has selected drill from inventory and "Confirmation menu" (A, S & D) has popped up. Now the player must select one of these actions (A = accept position, S = put item back to inventory, D = keep moving object around). Before the player chooses from one of these action he should not be able to do NOTHING else.
The problem is that if the player clicks the minimap in the upper right corner a button click is detected and menu is opened. If the player clicks the car (detected with Raycast) player gets inside. If the player drags the joysticks he starts walking around (using Unity's Joystick script). NONE of these should be allowed.
To the question: does Unity have some kind of method to "Prevent any kind of click detection to any other objects but these" OR "If mouse is not over this object do nothing when clicked"? There probably is nothing like that so what would be the best workaround?
Because these "click to do something" actions are triggered from various places with various styles (buttons and raycasts in tens of different scripts) I try to avoid doing this by setting booleans everywhere. Open ideas are more than welcome.
An easy workaround could be via using GUI Depth (https://docs.unity3d.com/ScriptReference/GUI-depth.html).
If "Confirmation menu" guiDepth is on top and all the other GUIs are below, you could add another GUI in between covering the whole screen; a Raycast would then return the first element and if it's the middle GUI just do nothing.

simple UI menu and canvas for DK2

I am using Unity 5.1.2p3 with DK2 SDK 0.6.0.1 and I understand from this post that Screen Space - Overlay is not supported in Unity VR. It is recommended to use Screen Space - Camera (which in my case does not work) or World Space (which I am using now) but I need someone to help me understand how I get simple menu with buttons and toggles to show as a still image and how I can make selections and button presses with my mouse cursor.
I have created a menu for my app, with 4 toggles and 1 button. When I check the Virtual Reality Supported option with the Oculus being in Direct Mode and Canvas being in World Space, I can see it in VR, but I cannot see/find my mouse cursor to tick one of the toggles.
When I take off the headset, on my monitor's Game View tab, I can see and even use the mouse and select a toggle. Obviously, I have to keep the headset steady, so in my Game View, things do not shake!
Another thing I notice is that the VR camera is the same as the Main Camera in the Unity Hierarchy, but when I take off the headset and move it around, the position of the camera does not change, only looking up and down and around is reflected.
How do I simply do a static menu like a 2D surface that does not move in VR and a user can use button presses and muse clicks with the headset on? What settings are required for this way of doing UI and canvas stuff? There are 2 attachments, showing my current settings...
Are you specifically wanting to use the mouse? If you look through a blog entry I wrote below, it will show you how to use Gaze looking to trigger menu buttons:
http://talesfromtherift.com/vr-gaze-input/
You can achieve this by some code I list there that raycasts from the center of the screen and if it hits any UI, it will trigger the correct events and make it clickable by button (or by time).