Issues During Upgrade to vNext Part 2
I have been keeping track of issues upgrading a project to the new MRTK, and to Unity 2018.3.n version. I'm posting it in case it may be of use to anyone.
My first project update notes are here #3596. This is the second project, built with Unity 2017.n and the last production version of the previous MRTK (still HoloToolkit). It is more complex than the previous project with many scenes, UI elements, gesture and voice interactions and much more.
At the end of this process I have a project that mostly works, except for the Manipulation Handler, which I'm still trying to sort out.
UPGRADE STEPS / SCRIPTS
-
Project Creation. This time I started with a new 2018.3.8f1 project. Imported the vNext Beta 2 assets (both Foundation and Examples)
-
Platform Settings. In Build Settings I had to change the Platform to Universal Windows Platform clicked Switch Platform. Then in Player Settings | XR Settings enable Virtual Reality Supported. Other Settings (.NET and IL2CPP) were correctly set to start.
-
Asset Files. From my original project I selected everything from my assets folder (2.3K items) except for the HoloToolkit and the custom UX profiles I had set up for previous UI elements (things like SimpleDialogButtonTextProfile and many more) and copied it into the new project. I am uncertain if Unity Standard Assets have changed for Unity 2018 but I copied them over anyway.
-
Import. Unity updated all the files to the new version. No issues.
-
HoloToolkit. I briefly tried having both old and new MRTK in the same project, which makes sense if you want a sane transition, but it ended up being easier for me to break it all at once and fix it by resolving build errors. YMMV. Deleted all HoloToolkit Using statements:
using HoloToolkit.Unity.InputModule; using HoloToolkit.Unity; et.al.
-
IFocusable Updated. Replaced all instances of IFocusable with IMixedRealityFocusHandler, updated using statements, implemented interface, moved my code, fixed NotImplementedExceptions where interface method not used
-
IInputClickHandler Updated. Replaced all instances of IInputClickHandler with IMixedRealityPointerHandler, updated using statements, implemented interface, moved my code, fixed NotImplementedExceptions where interface method not used
-
IManipulationHandler Updated. Tried various replacements (IMixedRealityGestureHandler
, et.al.) and couldn't get any of them to work. Whether that is my lack of understanding or some other issue I'll test more later. This remains as unresolved and a blocker for this project. -
Singletons! My project made exensive use of the Singleton and SingleInstance classes from the HoloToolkit. The new MRTK has a single Singleton, I believe, but I didn't want to have to rewrite my code to use IOC, so I just copied the classes over to the new project and updated using statements.
The Singleton class also required the GetParentRool method from GameObjectExtensions. This class conflicts with a new version in Microsoft.MixedReality.Toolkit.Core.Extensions which does not have that method, so I created a new static class for just that function and referenced the new class from the Singleton.cs
public static class MoreGameObjectExtensions {
/// <summary>
/// Gets the GameObject's root Parent object.
/// </summary>
/// <param name="child">The GameObject we're trying to find the root parent for.</param>
/// <returns>The Root parent GameObject.</returns>
public static GameObject GetParentRoot(this GameObject child)
{
if (child.transform.parent == null)
{
return child;
}
else
{
return GetParentRoot(child.transform.parent.gameObject);
}
}
}
-
Billboards. The Billboard using statement had to be updated to a new path.
-
TapToPlace. This is missing in the new MRTK. However, as this was an used reference in my project I removed it and moved on. Maybe this functionality has moved to one of the Solvers as seen in the Examples project?
-
SpatialMappingManager. This is also missing but as I wasn't using it I didn't bother sorting out the new MRTK classes for this and just removed it.
-
TextToSpeech. This is also missing (see #3569). I copied the TextToSpeech file over as-is and updated references. It works w/o change.
-
Button. Updated the path to the new button class though this requires lots of changes on the Unity side to get working properly;
-
CompoundButtonText. Updating to new UX buttons I changed these to TextMesh and setting the button .Text == "" field becomes lowercase .text = "";
-
GetColliderBounds. This is a helper method in TransformExtensions and just needed a new using statement using Microsoft.MixedReality.Toolkit.Core.Extensions
-
SpatialSoundSettings and SpatialSoundRoomSizes. This is another file that did not get included in the MRTK v2. So I copied it over and update using statements accordingly.
-
WorldAnchorManager. Seems to be gone. I don't see any replacement. Removed for now.
-
EnsureComponent. Moved to new location, updated using statement.
-
Button.OnStateChanged. Updated the reference from Button to Interactable, and OnStateChanged to SetState and ButtonStateEnum to InteractableStateEnum. We'll see if that works.
-
MixedRealityTeleport. I'm not sure which object in the new system would be a replacement. Since I'm not sure this reference is still needed in my project I removed it until I can test.
UPGRADE STEPS / UNITY
-
Configure Menu Item. This project additively loads the Mixed Reality camera and other required objects from a separate scene. The default objects, cursor, camera and input system are, as expected broken. I attempted to update them using the Menu | Mixed Reality Toolit | Configure. Only the MixedRealityToolKit comes in, not the MixedRealityPlaySpace. Not sure why, so I had to add this by hand. copying from another project.
-
Additive Loading. I decided to follow the current recommendations for multi-scene projects (#3599, #3246, #3261, #3601) and have my initial scene hold the Mixed Reality Toolkit and Playspace and additively load / unload each other scene to it (reversing my current pattern), so this require a little bit of a rewrite but works.
-
Standard Shader. As before, all the materials lost the connection to the Mixed Reality Toolkit/Standard shader and had to be reset.
-
SceneContentAdjuster. Missing. Wasn't sure it was still needed so left it off until I test on a WMR Headset. UPDATE: Definitely needed. Items in HL are placed based on head height. IN WMR they seem to be placed based on floor height? so about 1.8M below the start position on HL. I see there is a task list item for this #3048. I copied the SceneContentAdjuster from HoloToolkit and added it to MRTK.
-
3DTextPrefabs. Recreated and replaced all of these.
-
Speech Input Source. Removed script from the Inspector. Then, using the Mixed Reality Toolkit, I selected the Copy & Customize Option to create a new top level profile. Navigated down and clicked on the </> button to create a local copy of Input System Settings, then did the same for Speech Command Settings. That exposed a list of speech keywords that I could add to and replicate what was originally in Speech Input Source. I also had to set the Action dropdown to Select for each keyword.
-
Speech Input Handler. Pointed to new version. Re-entered keywords. A note in the code says to use Persistent Keywords the gameobject needs to be at the root.
-
Billboard. Updated component references throughout.
-
Buttons and More. Had to replace pretty much every button due to different scripts, themes, etc. I unpacked the MRTK UX Button prefab, re-prefabed it, duplicated the many button themes, modified them and updated the button with the new themes.
-
Layers & Tags. Had to update my Layers and Tags as they are not stored in the Assets folder and so did not import. Copied text from ProjectSettings.TagManager.asset and pasted into the same file in the new project.
-
Camera.main. Had to use FindObjectOfType
and assign to a local variable to get access to the Camera.main from most scenes, as additively loaded scenes don't automatically get access to the camera in the base scene. There may be a better way to do this, but this method worked for me. -
Particles/Additive. This is now "Particles/Priority Additive", so had to be updated in code and also in the Edit | Project Settings | Graphics | Always Include in Project list
= new Material(Shader.Find("Particles/Priority Additive"));
-
Spatial Mesh. When starting the app, the spatial mesh observer was running, covering the room with the mesh lines. I didn't set this and where to turn it off was non-obvious. But, from the Toolkit I created a local MixedRealityRegisteredServiceProvidersProfile and then a MixedRealitySpatialMeshObserverProfile and changed this from Auto start to Manual.
@davidkline-ms @cre8ivepark Would it be possible to mine these summaries for some kind of FAQ documentation? The format would have to be changed but the information itself is gold.
Closing this issue, but posting this in Stack Overflow.
https://stackoverflow.com/questions/55928369/upgrading-from-htk-to-mrtk-v2-rc1/55928452#55928452