/// This method creates the inspector when the program is running. In this mode we
    /// only show information on what is initialized, valid etc. but allow no changes.
    protected void RunInspector()
    {
        // for easy access to the object
        OpenNISettingsManager OpenNISettings = target as OpenNISettingsManager;

        // basic test. If the object is invalid, nothing else matters.
        if (OpenNISettings.Valid == false)
        {
            EditorGUILayout.LabelField("NI was not initialized and therefore everything is invalid!", "");
            return;
        }
        // show the mirror capability (global one from the context). Note, we can change the mirroring (To
        // allow showing mirrored/unmirrored viewers in realtime) but this should NOT be used except for that
        // purpose
        OpenNISettings.Mirror = EditorGUILayout.Toggle("Mirror behavior ", OpenNISettings.Mirror);

        // show image generator status
        string str = "Not used";

        if (OpenNISettings.m_useImageGenerator)
        {
            str = OpenNISettings.ImageValid ? "Valid" : "Invalid";
        }
        EditorGUILayout.LabelField("Image Generator:", str);

        EditorGUILayout.Space();

        // show user and skeleton control status
        if (OpenNISettings.m_useSkeleton)
        {
            str = OpenNISettings.UserSkeletonValid ? "user and skeleton control is Valid" : "user and skeleton control is Invalid";
            m_userAndSkeletonControlFoldout = EditorGUILayout.Foldout(m_userAndSkeletonControlFoldout, str);
            if (m_userAndSkeletonControlFoldout && OpenNISettings.UserSkeletonValid)
            {
                EditorGUI.indentLevel += 2;
                IList <int> users = OpenNISettings.UserGenrator.Users;
                EditorGUILayout.LabelField("Identified " + users.Count + " users", "");
                for (int i = 0; i < users.Count; i++)
                {
                    int userID = OpenNISettings.UserGenrator.GetNIUserId(users[i]);
                    NIUserAndSkeleton.CalibrationState state = OpenNISettings.UserGenrator.GetUserCalibrationState(userID);
                    Vector3 center = OpenNISettings.UserGenrator.GetUserCenterOfMass(userID);
                    EditorGUILayout.LabelField("User:"******"" + i);
                    EditorGUI.indentLevel += 2;
                    EditorGUILayout.LabelField("user id:", "" + userID);
                    EditorGUILayout.LabelField("unique id:", "" + users[i]);
                    EditorGUILayout.LabelField("calibration state:", "" + state);
                    EditorGUILayout.LabelField("center of mass:", "" + center);
                    EditorGUI.indentLevel -= 2;
                }
                EditorGUILayout.Space();
                OpenNISettings.SmoothFactor = EditorGUILayout.FloatField("Smoothing factor:", OpenNISettings.SmoothFactor);
                EditorGUI.indentLevel      -= 2;
            }
        }
        else
        {
            EditorGUILayout.LabelField("user and skeleton control:", "Not used");
        }
        EditorGUILayout.Space();
    }
    /// mono-behavior GUI drawing
    void OnGUI()
    {
        Rect posToPut = m_placeToDraw;

        switch (m_snap)
        {
        case NIMapViewerBaseUtility.ScreenSnap.UpperRightCorner:
        {
            posToPut.x = Screen.width - m_placeToDraw.x - m_placeToDraw.width;
            break;
        }

        case NIMapViewerBaseUtility.ScreenSnap.LowerLeftCorner:
        {
            posToPut.y = Screen.height - m_placeToDraw.y - m_placeToDraw.height;
            break;
        }

        case NIMapViewerBaseUtility.ScreenSnap.LowerRightCorner:
        {
            posToPut.x = Screen.width - m_placeToDraw.x - m_placeToDraw.width;
            posToPut.y = Screen.height - m_placeToDraw.y - m_placeToDraw.height;
            break;
        }
        }
        GUI.BeginGroup(posToPut);
        GUI.Box(new Rect(0, 0, m_placeToDraw.width, m_placeToDraw.height), "Users Radar");


        if (m_context.Valid == false || m_context.UserSkeletonValid == false)
        {
            GUI.EndGroup();
            return;
        }

        IList <int> users = m_context.UserGenrator.Users;

        foreach (int uniqueID in users)
        {
            int userId = m_context.UserGenrator.GetNIUserId(uniqueID);
            // normalize the center of mass to radar dimensions
            Vector3 com           = m_context.UserGenrator.GetUserCenterOfMass(userId);
            Vector2 radarPosition = new Vector2(com.x / m_radarRealWorldDimensions.x, -com.z / m_radarRealWorldDimensions.y);

            // X axis: 0 in real world is actually 0.5 in radar units (middle of field of view)
            radarPosition.x += 0.5f;

            // clamp
            radarPosition.x = Mathf.Clamp(radarPosition.x, 0.0f, 1.0f);
            radarPosition.y = Mathf.Clamp(radarPosition.y, 0.0f, 1.0f);

            // we always want the radar to mirror the view, even if the depth doesn't
            if (!m_context.Mirror)
            {
                radarPosition.x = 1.0f - radarPosition.x;
            }

            // draw the user
            Color newColor = m_UncalibratedUserColor;
            NIUserAndSkeleton.CalibrationState state = m_context.UserGenrator.GetUserCalibrationState(userId);
            if (state == NIUserAndSkeleton.CalibrationState.calibrating)
            {
                newColor = m_CalibratingColor;
            }
            else if (state == NIUserAndSkeleton.CalibrationState.calibrated)
            {
                newColor = m_CalibratedColor;
            }
            m_texture.SetPixel(0, 0, newColor);
            m_texture.Apply();
            m_style.normal.background = m_texture;
            GUI.Box(new Rect(radarPosition.x * m_placeToDraw.width - 10, radarPosition.y * m_placeToDraw.height - 10, 20, 20), userId.ToString(), m_style);
        }
        GUI.EndGroup();
    }