How to debug when using Google VR (Daydream) and Unity? - debugging

I'm using the latest Google VR SDK and Unity 5.6. I've got a Daydream headset/controller and I'm trying to develop a game. I've been stuck on a problem for a while now, which in a typical Unity environment I should be able to solve very quickly, but because I'm forced to build/run the code to the device each time I want to test I'm unable to view the console nor see any error/warnings which are thrown.
Any idea on how I can debug using Unity, or even emulate the Daydream controller/headset within Unity? I've seen that a controller emulator exists, but it appears you still have to run on the device, only in that scenario you have to have two phones; one acting as the controller and another as the 'screen'.
Thanks

Check out this asset Log Viewer.
Using this asset you can see the same log console in Unity Editor in runtime. I don't know about DayDream but it worked for me on Android, Oculus, and GearVR.

Related

How do I clear state such as permission decisions from the Visual Studio/MAUI WebView?

I'm working on MAUI app with a WebView and have gotten into a state where the Camera permission has been denied. I'd like to clear or change this, but the WebView doesn't offer a UI for doing so like a browser does. I'm only trying to debug for Windows locally at this point. How can I clear this state for local development? Like, just reset the WebView to act as if I've never run the app before. Thanks.
Extra info: this is a Blazor MAUI hybrid app. I'm inspecting the embedded WebView using Edge DevTools (the default for this type of project).
There is probably a more elegant solution, but I finally resolved this by changing the Package name in the .appxmanifest file, running the app, and then changing it back.

Xamarin: InitializeComponent () is too complex

I am currently developing an App for IOS and Android with Xamarin Forms. I am debugging with my Android device.
Starting yesterday, when trying to build and test my solution, it falls into a break state before the App is even loaded.
The exception is:
System.InvalidProgramException: Method wuut.Discover:InitializeComponent () is too complex.
It works when I unplug my Android device and open the App on developer mode. But I really need the Console etc. so right now, I am unable to continue developing my app.
I looked up the exception on Google but couldn't really find anything similar to my problem.
The error occurs inside InitializeComponent on one of my Contentpages containing an AbsoluteLayout.
The AbsoluteLayout is rather big with 5400 Lines of Code. So looking into the error messages, I tried to remove a few chunks of my XAML and it started working again.
So my question is: Does XAML or Xamarin have some limitations on how big an AbsoluteLayout/Contentpage should be? If not, how would I resolve this issue?
Thanks in advance and kind regards

Deployment of app to device failed

I have Xamarin Live Player up and running.
When I use it with a newly created Xamarin Forms (Master Details) app, it works fine. I see the app on the device.
However, when I try to run my full-blown app, Visual Studio tells me "Deployment to device failed. Make sure that Xamarin Live Player is open and that the device is in the same network."
Since the new app runs fine, I guess something else is the problem.
I've already set the Android project properties to be same as the newly created app.
Just to make sure, I've made it so that my full-blown app requests all rights.
How could I debug more in detail what's going wrong?
Xamarin Live Player can't run all apps. As soon as you use reflection, embedded resources, a MVVM framework or a custom renderer in Xamarin.Forms it might simply just not run the App.
You can read about the limitations of Xamarin Live Player in the official documentation for it.
You will probably have a much better experience just running directly on the device without Live Player.

ARCore unity debugging

For example I try to print out to the console and it doesn't, my script is attached to my main camera so we can rule that out and yes the script is active also, any help will be appreciated, right now what I am working on is to click on a certain part of my GameObject in AR and while my phone is connected to the computer I want to see the name of the certain part I clicked on in the console.
When you run the app on and Android device the log does not go to the Unity editor console. In order to see it you need to open Android Studio and then use the Logcat tab to see the device log.
Alternatively, you can run logcat from the command line
adb logcat.
More information: https://developer.android.com/studio/command-line/logcat.html
I have worked with ARCore and had the same frustating experience when it comes to debugging.
If you just want console prints, then use Log viewer which can catch and show them on Android too. (https://assetstore.unity.com/packages/tools/log-viewer-12047)
However, because I wanted more control and the ability to test and debug my game logic right inside the editor (without deploying to the phone all the time), I wrote a little plugin that allows me to do just that. This plugin simulates the operation of ARCore inside Unity editor. You can just hit play and ARCore will be simulated for you, so you can freely develop and debug your game logic. Moreover, you can then just build and deploy the project without changing anything, and ARCore will work like normal on your phone.
Using it is very similar to native ARCore, so you will not have much difficulty getting into it. It does not cover ALL features of ARCore yet, but it covers the basics. You can still use native ARCore for the rest.
You can find it here: https://github.com/VR-House/Eazy-ARCore-Interface
In current versions of Unity you can output logs from connected devices to Unity Editor. To do this, build your project in Development Mode and connect the Console to your device.
But I would recommend a more advanced way of testing AR in Editor with a plugin I wrote. I wrote it for my project and decided to make it into a plugin so everyone else can benefit from it.
AR Foundation Editor Remote plugin:
https://forum.unity.com/threads/ar-foundation-editor-remote-test-and-debug-your-ar-project-in-the-editor.898433/
I use debugging like this in C# script:
Debug.Log("Debug message and image name "+Image.Name);
To see this real time, I use Android Device Monitor (it's in Android's sdk folder, usually \Users\AppData\Local\Android\sdk\tools\monitor.bat. If device is connected, it appears on the devices list and it can be selected.
Or if I want to see the debug log in device, I put these lines in script:
private void OnGUI()
{
GUIStyle style = new GUIStyle();
style.fontSize = 50;
GUI.Box(new Rect(350, 0, 500, 500), Image.Name, style);
}
The Rect(350,0 is the position, 500,500 is the width and height of rectangle.

How to run DayDream Controller from Unity Editor?

I am developing a DayDream app and working with a Pixel XL and real DayDream Controller (on a MacBook Pro). I would really like to be able to test with the DayDream Controller when running the app from Unity Editor. Currently, I am forced to make a build for every little change and its killing me (slow).
I believe that I can do this by connecting my Pixel XL via USB cable to my Mac and then using adb to configure it. But, all attempts have failed so far.
I don't know about real Daydream Controller, but you can try using your phone as DayDream Controller Emulator.
As it said here, you should download emulator APK from here, install it and run on phone connected to WiFi.
In your Unity project find GvrControllerMain and change Emulator Connection Mode to Wi-Fi. Also find Assets/GoogleVR/Scripts/Controller/Internal/Emulator/EmulatorConfig.cs and change line to IP address displayed on daydream controller emulator app on phone.
// IP address of the phone, when connected to the PC via WiFi.
public static readonly string WIFI_SERVER_IP = "192.168.0.78";//"192.168.43.1";
Click "Play" in Unity, it should work.
In addition to diesersamat's answer, I would like to add two things:
You could run the controller emulator via USB by choosing "USB" from the Emulator Connection property of the GvrController script that is attached to the GvrControllerMain component. For the USB connection to be made, you have to make sure that %AndroidSDKHome%/platform-tools is added to your PATH variable.
You could use the real controller via Emulator: Open the Controller Emulator app --> open the Emulator's overflow menu --> select Switch to Real Controller. For this to work, the phone that runs the emulator has to be Daydream ready. I usually use the same phone that I use for Daydream VR as a controller emulator.
At Google I/O 2017, the Daydream team announced instant-preview which supports a "headless" controller-only mode.
The repo is on github: https://github.com/googlevr/gvr-instant-preview
The moment in the Daydream keynote where it is mentioned is here: https://youtu.be/tto90e-DfeM?t=26m45s
I had the same problem trying to get the emulator to work. The solution for me was to set up the player settings to android and click the VR supported tab with the daydream SDK selected in the VR SDKs dropdown BEFORE importing any daydream/google VR packages.
Took a lot of trial and error for me to figure that out. Hope that helps.

Resources