Reputation: 1492
I have a networked Unity project using HLAPI from which I need to build:
I have three specialized scenes, one for each of these roles, and a base scene that only loads one of them at run-time depending on a role setting.
Here is the problem from there. I have scripts, including the HoloToolkit from Microsoft, referenced in the Hololens client scene using classes in namespaces UnityEngine.VR.WSA
and UnityEngine.VR.WSA.Ipnut
. That compiles just fine for the WSA platform. But, when the time comes to build the desktop client and the desktop server, all those scripts fail to compile as if those namespaces did not exist.
Here is an example:
Assets/HoloToolkit/Input/Scripts/GestureManager.cs(139,17): error CS0246: The type or namespace name `GestureRecognizer' could not be found. Are you missing an assembly reference?
GestureRecognizer
is in UnityEngine.VR.WSA.Input
. I would have thought that the backend would be smart enough to simply throw NotSupported exceptions at run-time if any class in those namespaces would be called under PC standalone platform (and I am smart enough not to call anything from them when role = desktop client or desktop server) but it simply does not compile so I am really stuck. Does anyone know any solution to this without rewriting everything with UNITY_WSA
or UNITY_STANDALONE
preprocessor flags to insert everywhere even in 3rd party imported assets?
I was on Unity 5.4 beta for Hololens and this was no problem, at all. Then I migrated to 5.6 and this became one.
Upvotes: 0
Views: 2653
Reputation: 125275
You should have considered this even before making your app. Some APIs are not available between Windows standalone and Windows Store build. It's even worst wne Hololens is involved.
Your example of why preprocessor solution is not acceptable is not good.
Preprocessor directive is the way to solve this. You don't have to wrap it around the place the class
is declared. Just wrap it around the places you imported the name space. For example,
#if UNITY_WSA
using UnityEngine.VR.WSA;
#endif
Also, to make this really easy for you, you should not access the API from the UnityEngine.VR.WSA
namespace directly from your other classes.
Build a wrapper class that wraps around all those input from the UnityEngine.VR.WSA
namespace then then use #if UNITY_WSA
inside that class. By doing this, you will only need to have #if UNITY_WSA
in one class instead of all the classes that reference any API from the UnityEngine.VR.WSA
namespace.
It is easier to manage. To access the inputs from the UnityEngine.VR.WSA
namespace, you use that wrapper. Remember to only wrap around the API's that you need.
Upvotes: 1