How can I get sensor data into Unity while using Google Cardboard? - unity3d

I have the basic Google Cardboard Unity application loaded and working great.
I want to utilize a few sensors on my phone that aren't available in Unity. For example, I want to get access to the STEP_DETECTOR sensor.
I created my own UnityPlayerActivity, and without Cardboard, it seems to work well. My problem is that I have no idea how to use my custom UnityPlayerActivity WITH cardboard.
From what I can tell, the cardboard demo uses a "UnityCardboardActivity" class as the main activity. I took a look at UnityCardboardActivity.jar and it looks like the UnityCardboardActivity class inherits from CardboardActivity, NOT UnityActivity.
So my guess is that UnityCardboardActivity is manually starting the default UnityPlayerActivity somewhere in its code, but I can't change that to start my own custom UnityPlayerActivity in any way that I can tell.
Is there any way to get that sensor data without using a UnityPlayerActivity?
I tried making my activity extend UnityCardboardActivity instead, but for some reason I don't have access to the "getSystemService" method when do that, so I can't get access to any sensors.

Related

Maneuver issues in Turn By Turn Navigation with HERE maps in Flutter

Thanks in advance.
We have to use HERE map's Turn by turn navigation feature in one of our Flutter application, we have added billing in the developer account and have created the necessary keys.
When we try HERE map examples they have provided, we get everything except maneuver instructions that shows the user when to turn right/left/go straight for some distance etc.
I'm new to this and I have no idea how to get this, we never get events on the listener and it only shows updating there, am I missing something ?
this is how it looks right now, Updating...
I think we should be getting the progress here, but we are not getting it here...
_visualNavigator.routeProgressListener = Navigation.RouteProgressListener((routeProgress) { }
Please look into the provided example app. It shows here how to get the maneuver actions.
Your screenshot shows a different app, so make sure everything works with the example app, at first. The app offers to run a simulation mode. This should work. If you run the example app with real GPS updates, you may need to go outside and move to get location updates. This should also work.
If this still does not work, it could either mean that your device has an issue with getting GPS locations. Some iPads, for example, lack support. Or that you have disabled getting location updates. You can cross-check this when trying the positioning_app example from the same repository that shows how to get location updates.
A last point may be to clarify what events you get and what you miss: There are multiple event listeners providing real-time information during guidance - if you have only an issue with maneuvers, then most likely you can solve your issue by following strictly the code of the example app.
Note that previous HERE SDK versions, prior to HERE SDK 4.13.0, only provided empty maneuver instruction texts during guidance when they have been taken from the route instance. Make sure to take this information from the VisualNavigator instead.

How to get GLFW window Id of FlutterWindow

I am trying to build a video player using flutter for Desktop. There is a video_player plugin available for iOS and Android, but not for Desktop. So, for the time being thought of trying to use gstreamer for decoding and hardware rendering in C++ code as back-end to flutter. The idea is to pass the Window Id of the flutter window to gstreamer's glimagesink plugin for rendering the video.
I am using the latest code from https://github.com/google/flutter-desktop-embedding as the base for my experiments. Below mentioned points are with reference to this repo.
In file flutter-desktop-embedding/example/linux/main.cc, FlutterWindowController object is created as shown below.
flutter::FlutterWindowController flutter_controller(icu_data_path);
This internally calls
FlutterDesktopInit();
While hovering the mouse pointer on the above method, VS code shows the following
bool FlutterDesktopInit()
Sets up the library's graphic context. Must be called before any other
methods.
Note: Internally, this library uses GLFW, which does not support multiple
copies within the same process. Internally this calls glfwInit, which will
fail if you have called glfwInit elsewhere in the process.
It is clear that FlutterDesktopInit() uses GLFW to create window. Checked whether I can get the window handle. But, no luck. I could only get the FlutterWindow object as shown below.
flutter::FlutterWindow *win = flutter_controller.window();
Appreciate if somebody can give some hint on how to get the GLFW window handle, which can be used with glimagesink.
You can't get references to any GLFW objects through that API. This is by design because, as the comment you quoted says, you can't have multiple copies of GLFW within the same process. GLFW is statically linked into the Linux Flutter embedding, so you can't use GLFW in the runner or a plugin.
Implementing a video player should be done using the texture APIs, which will be added for GLFW in this PR.

Unity3d Steamworks is not initialized

I am doing a unity project for Steam. So I downloaded and added SteamWorks.net to the project created an empty object and attached the steam manager code to that. And for the achievements, in the script, import steam using
'using Steamworks;'
And set achievements using
SteamUserStats.SetAchievement();
SteamUserStats.StoreStats();
Now when I run the code I am getting an error
'Steamworks is not initialized".
how to fix this
When testing make sure the steam_appid.txt is in the folder. SteamManager monobehaviour will initialize API on awake.
Also this worked for me and I felt kind of dumb but it's important. Double check to make sure your steam app is currently logged in. If your turned on your computer and it logged you out or if there was an update or something that requires you to log in than it wont work and it'll throw that error. Otherwise you should be good if you listened to the other answer as well.

Access the OpenVR chaperone (Play area boundary box) without having SteamVR

I am trying to get access to the bounding box/Chaperone of my VR project without relying on SteamVR. I am trying to build a framework that works as native as possible to Unity.
In SteamVR one would write:
Valve.VR.OpenVR.Chaperone.ForceBoundsVisible(true);
// or
Valve.VR.OpenVR.Chaperone.ForceBoundsVisible(False);
My question is how can I do something similar to this with just the OpenVR package and not the SteamVR plugin.
thanks
You can use OpenVR SDK.
If you are using C#, there is a wrapper lacated at headers\openvr_api.cs.
At first you have to load library (openvr_api.dll) and init it like this:
var error = EVRInitError.None;
OpenVR.Init(ref error, EVRApplicationType.VRApplication_Background)
Then simply use it the same way
OpenVR.Chaperone.ForceBoundsVisible(true);
You can also read chaperone_info.vrchap and steamvr.vrsettings from config folder of Steam. These json files contain information about all universes collision bounds.

Can both image target and object target be added one single database in unity vuforia?

I am developing an android app where I have to train my app to recognize two images and four objects.I created one single database where I added all the images and objects target in vuforia developer site and created the unity package. Now neither image nor object is getting recognized.
Probably the problem is the same for objects and images.
I think you should share some more info about what your doing as well as some meaningful code implementing it.
W/O that, I would suggest:
verify that the database and trackables are loaded and active # runtime
if so, see in console that the trackables are tracked by Vuforia
if so, verify the code enabling your augmentations
Please confirm whether have run trough these steps already and what results you got. I can share some code and further tips once the issue is a little but more specific.
Regards