Comments (14)
If you mean to render OnGUI in VR, see the Legacy/DemoScene which has an example of doing that.
from gvr-unity-sdk.
Thanks for your advice. I'd like to do an old-fashioned OnGUI directly onto the screen frame. The legacy example appears to render the GUI to a render texture which is then imposed in the 3d environment (see screengrab):
from gvr-unity-sdk.
Is this GUI meant to be in VR mode or out of VR mode?
from gvr-unity-sdk.
the gui will simply be a static button locked to the corner of the screen that toggles between regular and VR mode. Traditionally this could be done with an OnGUI(){ GUI.Button()... but this is being overwritten by the SDK's rendering.
from gvr-unity-sdk.
If you are willing to modify the Cardboard.cs script slightly, you can get something to draw on the screen after the stereo view is done. That would be in the EndOfFrame() function. You can use CardboardOnGUIWindow script as well. Which version of the Cardboard SDK are you using? (The exact way to do this depends on the version.)
from gvr-unity-sdk.
That did it, thanks! It was a little fiddly to capture touch inputs because OnGUI can occur more than once per frame, but that hook allows GUI textures to be rendered correctly. (Using latest version btw)
Maybe for the next version there could be a standardized way of toggling Cardboard mode? I'd imagine there will be many apps that want to support it, but don't necessarily want to maintain two separate apps on the store.
from gvr-unity-sdk.
hello @miketucker Could the buttons in legacy DemoScene receive any input?
In my built demo, the buttons can't be touchable on a mobile phone.
from gvr-unity-sdk.
In Cardboard.cs add this to the header:
public delegate void CardboardOnGUIEvent();
public event CardboardOnGUIEvent OnGUIRender;
and in the EndOfFrame function:
if(OnGUIRender != null) OnGUIRender();
This will provide a hook for doing regular OnGUI stuff.
Then in your script with the GUI:
void Start(){
cardboard.OnGUIRender += HandleOnGUIRender;
}
void OnDestroy(){
cardboard.OnGUIRender -= HandleOnGUIRender;
}
void OnGUI(){
HandleOnGUIRender();
}
void HandleOnGUIRender(){
if(GUI.Button ...
}
The key thing here is that Unity will continue to check for mouse/touch button events with the OnGUI function, and the new event hook will allow it to be rendered properly by Cardboard
from gvr-unity-sdk.
@miketucker
It works well on Editor, but failed on Phone.
Is it ok on your phone?
from gvr-unity-sdk.
@ro4tub The new 0.5.1 release should fix the missing java function bug.
from gvr-unity-sdk.
@smdol It works on iPhone but not on Android, why? I amusing 0.5.1
from gvr-unity-sdk.
@smxthereisonlyone Try turning off TapIsTrigger on the Cardboard script. That setting makes screen touches look like magnet trigger events (which only happens on Android but not iPhone).
from gvr-unity-sdk.
@smdol But then there is no build in solution to register button events for the new cardboard v2?
from gvr-unity-sdk.
You can see screen taps either with Input.touches or Input.GetMouseButtonDown(0).
from gvr-unity-sdk.
Related Issues (20)
- Not working for LWRP (only left eye rendered) HOT 4
- Building to iOS fails Unity 2019.3.0b + Google VR + Universal Render Pipeline
- Distortion Correction Toggling with Unity and Daydream
- Can it work for Gear VR? HOT 1
- ios 13 beta xcode11 without error log when running, but the splash screen pops out
- Detecting if a recenter event just happened appears to be broken HOT 1
- Still getting "GvrShimUnity: getControllerConnectionStatus device 0 api" even with [email protected] HOT 1
- HLS live 360 playback is distorted on Oculus Go HOT 2
- How to turn on deinterlace using OpenGL
- Mirage Solo instant preview "not connected to editor"
- Mirage Solo - Instant Preview "Not connected to editor"
- googleVR Scaling issue.
- GVR audio engine issue?
- Zoom in Cardbard
- Cardboard stereo view mask does not fit into a Xiaomi with display aspect ratio greater than 2.1
- Weird image glitch with Universal Rendering Pipeline HOT 6
- [Question] Is there a way to use the controller without displaying two eyes
- Arrow on iphone HOT 4
- Camera Viewport Rect
- Magic Window launches with offset
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gvr-unity-sdk.