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

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.

Related

Unity3D Hololens access Windows.Storage.KnownFolders

I need to access the PicturesLibrary fodler on the Hololens.
Docs state that you can do that by "Windows.Storage.PicturesLibrary"
But I can not import the namespace "Windows" in my Unity project because its not included in UWP, also it should be possible.
I am using the Unity3D 2019.2 with .net 4.x
How can I load pictures from the folder the right way with the HoloLens?
I tried some examples from similar questions but none of them worked, like eg.g:
#if !UNITY_EDITOR && UNITY_WINRT_10_0
return Windows.Storage.KnownFolders.PicturesLibrary.Path;
#else
#crani have you set the UWP App Capability declaration for PicturesLibrary access?
note that the docs mention that the capability provides access to "enumerate" the files in the library. Path is typically going to be an empty string for any of the KnowFolder types.
You will need to do something like this:
StorageFolder picturesFolder = KnownFolders.PicturesLibrary;
IReadOnlyList<StorageFile> pictures = await picturesFolder.GetFilesAsync();
So if you wrap something similar in an #if directive you should be able to access the files, but the path is abstracted from the app as a storage folder.

Unity3D AssetDatabase.LoadAssetAtPath() vs Resource.Load()

My partner in game dev are looking at Unity. I dynamically loaded an asset using Resource.Load() and he used AssetDatabase.LoadAssetAtPath(). They both seem to work so which one should be used? Why have 2 different ways to dynamically load assets?
AssetDatabase.LoadAssetAtPath() vs Resource.Load() ...They both
seem to work so which one should be used?
None of them.
Your partner will end up with a game that he cannot build because he used AssetDatabase.LoadAssetAtPath(). The AssetDatabase.LoadAssetAtPath() function came from the UnityEditor namespace which is only used to make Editor plugins. It won't work outside the Editor and it won't even let you build your game at-all.
You using Resource.Load is fine but Resource.Load requires the use of the Resources folder which is known to cause slow down loading time of the game.
AssetBundles is the recommended way. You can put those files in the StreamingAssets folder then use the WWW or AssetBundle API to load it during run-time. You can learn more about how to use AssetBundles here

javascript error airconsole generator and unity

Hi I am making a game on unity with airconsole and when I try to import the airconsole controls github repo to my unity project I get a lot of javascript errors, so I can't use the controller generator and it hinders me, A LOT.
Thanks in advance, you would save my skin.
Your HTML, CSS and JavaScript files, as well as all additional resources your controller will need (images etc.), need to be in Assets/WebGLTemplates/AirConsole so Unity will not try to compile them into C# or UnityScript.
Your controller HTML file itself can be somewhere else in the project, the file within Assets/WebGLTemplates/AirConsole will be updated automatically to match it as long as it is linked in the AirConsole Object in your scene.
If you add the plugin including example scenes into an empty project, you will see a working folder structure.
Edit/Update: in case you are getting errors along the lines of The type or namespace name 'ILGenerator' could not be found (or the same but with DynamicMethod) please see details on Reddit or StackOverflow.
Essentially: you have to set API Compatibility level o 4.x in your Player Settings for your selected platform.

Unity3d protect code

We have a code in a unity3d game that we wish to protect from decompilation(will be published in ios,android,webgl and unity plugin). How should we protect it? Should we write that part of code as unmanaged plugin(c++)?
It's not possible to release software that can't be reverse-engineered.
This is POSIBLE. Some packages have standart unity packager format. So.. If you use dynamic assets or if you use CodeContainers you need to protect your code.
So what you shoud do:
If you use dynamic assets packages: Make dll's from code or make one controller class.
If you use CodeConainers (JS) make main C# controller. After this you can extends classes or simply call methods.
PS: If you want to secure not code assets, you need make binary encoding. And when you load level or prefab you just decode this asset and use.
You could use obfuscation techniques, which allows you to protect your package from reverse engineering, but just from those, who is not VERY (i am talking about high-level reverse engineers, who could decompile your code and deal with ASM or could decompile your iOS/Android project) interested, in any case for Unity, iOS
You can obfuscate the your source code using the Remiix Obfuscator plugin in unity asset store.
It's free and easy to use and support many platform of build on unity(android, ios).

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

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.