microsoft / RoomAliveToolkit

Other
714 stars 191 forks source link

Cannot Build in Unity 2017.1.1f1 #75

Open reillydonovan opened 6 years ago

reillydonovan commented 6 years ago

Hi, when trying to build in Unity 2017.1.1f1 I am returned the following, Assets/RoomAliveToolkit/Scripts/RATSceneSetup.cs(3,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?

Any suggestions on how to properly build to a .exe for a room alive scene in Unity 2017?

Thanks!

-Reilly

thundercarrot commented 6 years ago

I'm not sure why we're seeing this issue only now, but it does make sense that you wouldn't have access to the UnityEditor namespace in a build. See https://answers.unity.com/questions/316805/unityeditor-namespace-not-found.html for example.

Can you try putting that file in the Editor folder and see if that fixes it?

I may not have time soon to take a look myself.

jjhartmann commented 6 years ago

I came across this same issue, and the fix was to wrap the UnityEditor code in a macro.

In RATSceneSetup.cs

Line: 3

#if UNITY_EDITOR
using UnityEditor;
#endif

and lines: 37-41

#if UNITY_EDITOR
        public void LoadDefault3DModels()
        {
            kinectModel = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/RoomAliveToolkit/Models/Kinect.obj");
            projectorModel = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/RoomAliveToolkit/Models/Projector.obj");
        }
#endif

In UnityUtilities.cs

Move line 81:

[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]

between the line "#if UNITY_EDITOR" and before the class:

public class ReadOnlyDrawer : PropertyDrawer