Making Cursor Mouse Always Enabled In Unity CardBoard Plugin - unity3d

i think the title is clear , i want to make the mouse Cursor which is set in GazeInpuModule to be always enabled and in center of the both Left And Right Cameras , can anyone help me ?!
ive tried changing the GazeInputModule code to place the cursor in center , but got nothing !

Here's what worked for me:
Create a Cursor GameObject in the Head hierarchy
Add EventSystem in the project hierarchy
In the EventSystem Gaze Input Module component, ensure "Show Cursor" is selected.
In GazeInputModule.cs, PlaceCursor(), change the SetActive() to:
private void PlaceCursor() {
// ...
cursor.SetActive(showCursor);
// ...
}

Related

How to center mouse cursor in Unreal Engine

I want to center mouse cursor. Here how I do it.
But here is a problem - when I change active window with alt + tab, cursor still in the center all the time. Can I check somehow that game window is focusable?
You can call IsForegroundWindow() on your LocalPlayer’s ViewportClient->Viewport.
Something like:
ULocalPlayer* LocPlayer = Cast<ULocalPlayer>(Player);
if (!LocPlayer->ViewportClient->Viewport || !LocPlayer->ViewportClient->Viewport->IsForegroundWindow())
{
// viewport is either not present or not in the foreground.
}
…should work for you. Player lives within the PlayerController, so the above code will work if called from within a playerController, or can be called somewhere else by grabbing the Player from the local playerController.

How do I check whether I have changed rooms in Game Maker Studio 2?

So I have been working on a pause menu for a game I have been working on with Game Maker Studio 2.
Whenever I change rooms (like going to the options room or main menu) the pause menu stays and everything looks very weird and overlapped. Is there a way to check if I have changed rooms to destroy the objects the menu is made up of
(So like if (room has changed) {Delete pause menu})*
If someone could give me the correct syntax that would be awesome!
Thanks.
*I have sorted out deleting the menu, just need to know what to put in the if statement
For my game, I've done a check if the room is the same as the room in the main menu/options menu, or make a check that the pause menu only appear when it's not the main menu/options menu.
var roomname = room_get_name(room);
if (roomname != r_mainmenu && roomname != r_optionsmenu)
{
//draw pause menu
}
Another idea is to hide the pause menu once you go back to the main menu.

How to find UI in code c# (button, Panel etc)

in an empty game object i have a selection Manger script. I'm having some difficulties with finding a panel (called: OpenSelection) I created in Canvas.
I would like to find the panel where ever it is in the hierarchy and set enabled to true.
But the code isn't finding the panel. I'm not sure why.
any help would be appreciated
//UI
private GameObject panel;
// Start is called before the first frame update
void Start()
{
panel = GameObject.Find("OpenSelection");
panel.SetActive(true);
}
Generally, Find() is never the best approach for anything.
Try to set a variable reference to your OpenSelection, like you did with your panel, then call this variable.
GameObject.Find() only returns active GameObject. Here you are trying to find the OpenSelection panel which is not active. That's why the Find() is not finding the OpenSelection panel.

Unity Editor - validating GameObjects

Task:
I want to create a context menu item that will work on GameObject selected in Hierarchy. This action should be available only when selected GameObject is a Prefab. I'm working on Unity 5.3.2
Code:
File MenuItems.cs is located in Assets\Editor
using UnityEditor;
using UnityEngine;
public static class MenuItems
{
[MenuItem("GameObject/Action on prefab", false, 14)]
private static void MenuActionPrefab()
{
}
[MenuItem("GameObject/Action on prefab", true, 14)]
private static bool ValidateMenuActionPrefab()
{
var isPrefab = PrefabUtility.GetPrefabParent(Selection.activeGameObject) != null;
return isPrefab;
}
}
Problem:
The problem is that the menu item is visible (and can be clicked) no matter if selected GameObject is a Prefab or not. I have tested code in debugger and value returned from ValidateMenuActionPrefab() is OK (true when I run it on Prefab, false on non-prefab gameobject).
I've read somewhere that Unity 5 have problem with validation methods but the example from UNITY EDITOR EXTENSIONS – MENU ITEMS about validation in Assets work perfectly OK.
Question:
So if this is a proper solution? Or is there another way to achieve same goal?
Additional info:
I have tried to run those methods simple way using:
[MenuItem("GameObject/Action on prefab")]
and
[MenuItem("GameObject/Action on prefab", true)]
but in this case there is no Action on prefab in context menu. Also this item isn't visible when I try not to set priority index.
Edit:
Behaviour should be simillar to Select Prefab item (visible on screenshot). When object isn't connected to prefab field should be grey and not-clickable. When object is a prefab field is black and can be clicked.
I've just set up a new unity3d project and your code works then clicking on the menu Gameobject/Action on Asset.
I'm using Unity3d 5.3.4f1. Maybe it's a bug in your specific version, however I didn't find any mention about this neither in the 5.3.3 nor the 5.3.4 changelog
However when you right-click and open the context menu over an object in the hierarchy, the ValidationMethod is not called, so the context menu element is always enabled. But if you actually click the context menu item, then the validation method is called; if it returns false then no action is performed.
Seems like a bug, but at least is safe to use it.
Prefab selected
Instance selected

Input disabled after moving object in editor while in "play mode"

This is my first question here, i couldn't find an answer online for my problem.
Here it is:
I made a simple script to print some debug info about objects when i press a key. It works as expected unless i first move any of the objects in the scene editor while the game is running.
If i move any of the objects after i hit play it seems that Input.GetKeyDown is ignored after that. I am detecting the input inside the Update function of one of the objects.
public GameObject target;
void Update ()
{
if (Input.GetKeyDown(KeyCode.P))
{
Debug.Log (transform.position);
Debug.Log (target.transform.position);
}
}
NOTE: this is not the only thing im trying to achieve with my script, but is the simplest case i could build with the same problem.
thanks in advance!
I think that's because when you move the object, the Unity GameView will lose its focus. So just ensure it has the focus again (klick into it), before hitting the key.