6 Replies Latest reply on Apr 13, 2018 9:29 AM by Intel Corporation

    SDK 2.0 unity build crash in Window

    qwerty.2944

      As you know, to get the proper scene for using Realsense, I clicked the file(:RealSenseTextures.unity) and opened it.@

       

       

      It works very well, in latest unity (x64)

       

      there are some warning message, but it works well.

       

      However, I tried to build,

      it does not work. (Fail to build)

       

       

      How am i supposed to do?

       

       

       

      Thank you in advance.Intel® RealSense Community@

        • 1. Re: SDK 2.0 unity build crash in Window
          MartyG

          Does it make a difference if you use the 'Add open scene' button to add your project's scene file to the build settings?  On my own Unity project I always have my scene in this list.

          • 2. Re: SDK 2.0 unity build crash in Window
            qwerty.2944

             

             

             

             

            it does not work

            • 3. Re: SDK 2.0 unity build crash in Window
              MartyG

              I looked carefully at your case but I do not have SDK 2.0's version of Unity support set up on my own PC so I am unable to run tests.  I apologize and hope a member of Intel's support team can help you with this later.  Good luck!

              • 5. Re: SDK 2.0 unity build crash in Window
                qwerty.2944

                it seems that it is not a fault of Unity's

                 

                in my terms of view,

                 

                the given scene (by Realsense sdk 2.0) is "using UnityEditior"

                so it work well in the test , however, it cannot be built.

                 

                Actually, i removed the code related with unityeditor,  it can be built.

                However, it crash down in a minute.

                 

                Thank you for your advice, I will try it later on.

                • 6. Re: SDK 2.0 unity build crash in Window
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hello qwerty.2944,

                  Building a game app cannot use the UnityEditor namespace. This namespace comes with the UnityEditor.dll assembly that is not shipped (and not compatible) with any build made by Unity. Scripts that use this namespace are only meant to be executed inside Unity Editor.
                  Therefore, need to create a new script in Assets/Editor folder and move below code to that script. Then, the Windows app can be built successfully.
                  -------
                  public class RealSenseDeviceInspectorEditor : Editor
                  {
                      public static void DrawHorizontal(string field, string value)
                      {
                          EditorGUILayout.BeginHorizontal();
                          {
                              EditorGUILayout.LabelField(field, GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                              EditorGUILayout.SelectableLabel(value, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                          }
                          EditorGUILayout.EndHorizontal();
                      }
                      public override void OnInspectorGUI()
                      {
                          RealSenseDeviceInspector deviceInspector = (RealSenseDeviceInspector)target;
                          if (!deviceInspector.streaming)
                              return;

                          EditorGUILayout.Space();
                          var devName = deviceInspector.device.Info[CameraInfo.Name];
                          var devSerial = deviceInspector.device.Info[CameraInfo.SerialNumber];
                          DrawHorizontal("Device", devName);
                          DrawHorizontal("Device S/N", devSerial);
                          EditorGUILayout.Space();
                          foreach (var kvp in deviceInspector.sensors)
                          {
                              string sensorName = kvp.Key;
                              var sensor = kvp.Value;
                              EditorGUILayout.Space();
                              EditorGUILayout.LabelField(sensorName);

                              foreach (var opt in sensor.Options)
                              {
                                  if(opt.IsCheckbox())
                                  {
                                      bool isChecked = Convert.ToBoolean(opt.Value);
                                      if(isChecked != EditorGUILayout.Toggle(opt.Key.ToString(), isChecked))
                                      {
                                          opt.Value = Convert.ToSingle(!isChecked);
                                      }
                                  }
                                  else if(!opt.IsEnum(sensor.Options))
                                  {
                                      if(opt.ReadOnly)
                                      {
                                          EditorGUILayout.BeginHorizontal();
                                          {
                                              EditorGUILayout.LabelField(opt.Key.ToString(), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                                              EditorGUILayout.SelectableLabel(opt.Value.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                                          }
                                          EditorGUILayout.EndHorizontal();
                                      }
                                      else if (opt.IsIntegersOnly())
                                      {
                                          var newVal = EditorGUILayout.IntSlider(opt.Key.ToString(), Convert.ToInt32(opt.Value), Convert.ToInt32(opt.Min), Convert.ToInt32(opt.Max));
                                          if (newVal != Convert.ToInt32(opt.Value))
                                              opt.Value = Convert.ToSingle(newVal);
                                      }
                                      else
                                      {
                                          float newVal = EditorGUILayout.Slider(opt.Key.ToString(), opt.Value, opt.Min, opt.Max);
                                          if (opt.Value != newVal)
                                              opt.Value = newVal;
                                      }
                                  }
                                  else
                                  {
                                      List<string> valuesStrings = new List<string>();
                                      int selected = 0;
                                      int counter = 0;
                                      for (float i = opt.Min; i <= opt.Max; i += opt.Step, counter++)
                                      {
                                          if(Math.Abs(i - opt.Value) < 0.001)
                                              selected = counter;

                                          string label = sensor.Options.OptionValueDescription(opt.Key, i);
                                          valuesStrings.Add(label);
                                      }
                                      var newSelection = EditorGUILayout.Popup(opt.Key.ToString(), selected, valuesStrings.ToArray());
                                      if(newSelection != selected)
                                      {
                                          opt.Value = Convert.ToSingle(newSelection);
                                      }
                                  }

                              }
                          }
                      }
                  }



                  Regards,
                  Jesus G.
                  Intel Customer Support