コード例 #1
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.PropertyField(displaySchema, new GUIContent("XML Schema", "Do not modify this unless you know what you're doing"));
        EditorGUILayout.PropertyField(xmlFilename, new GUIContent("XML filename", "The XML file with the display specifications"));
        EditorGUILayout.PropertyField(loadFromFileInEditor, new GUIContent("Load from File in Editor", "Load the information from the xml file while in editor mode."));

        EditorGUILayout.PropertyField(resolutionX, new GUIContent("Resolution X", "The pixel width of the display"));
        EditorGUILayout.PropertyField(resolutionY, new GUIContent("Resolution Y", "The pixel height of the display"));

        EditorGUILayout.PropertyField(isStereo, new GUIContent("Stereo Display", "Is this display stereo?"));
        if (isStereo.boolValue)
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(eyeSeparation, new GUIContent("Eye Separation", "Eye separation for the stereo image"));
            EditorGUILayout.PropertyField(stereoType, new GUIContent("Stereo Type", "The type of stereo to use"));
            EditorGUILayout.PropertyField(useDoubleTheSpace, new GUIContent("Double the Space used", "Calculate the total resolution of the display based on stereo type. \nSideBySide: Double horizontal resolution \nTopAndBottom: Double vertical resolution."));
            EditorGUI.indentLevel--;
        }

        EditorGUILayout.PropertyField(camera, new GUIContent("Attached Camera", "The RUISCamera that renders to this display"));



        EditorGUILayout.PropertyField(enableOculusRift, new GUIContent("Enable Oculus Rift", "Is this display an Oculus Rift?"));

        // TODO: Depends on OVR version
        EditorGUI.indentLevel++;
        GUI.enabled = enableOculusRift.boolValue;
        EditorGUILayout.PropertyField(oculusLowPersistence, new GUIContent("Low Persistence", "Low persistence reduces pixel blur. Try disabling this option if "
                                                                           + "the Oculus Rift view suffers from 'judder' when rotating your head. NOTE: Disabling "
                                                                           + "this option might cause issues with Oculus runtime 0.4.4 if you're using DX11!"));
        EditorGUILayout.PropertyField(oculusMirrorMode, new GUIContent("Mirror Mode", "Draw the Oculus viewports also to the main display when Direct Display Mode "
                                                                       + "(Direct HMD Access) is enabled from the Oculus Configuration Utility. This setting has no "
                                                                       + "effect when your application is playing inside the Unity Editor."));
        if (enableOculusRift.boolValue && EditorApplication.isPlaying)
        {
            if (previousOculusLowPersistenceValue != oculusLowPersistence.boolValue && displayManager)
            {
                // Low Persistence value changed, enforce it if application is running in Editor
                displayManager.setOculusLowPersistence(oculusLowPersistence.boolValue);
            }
        }

        EditorGUI.indentLevel--;

        GUI.enabled = !enableOculusRift.boolValue;

        RUISEditorUtility.HorizontalRuler();
        EditorGUILayout.PropertyField(isObliqueFrustum, new GUIContent("Head Tracked CAVE Display", "Should the projection matrix be skewed to use this display "
                                                                       + "as a head tracked CAVE viewport"));

        GUI.enabled = true;

        if (!enableOculusRift.boolValue)
        {
            //disabled for now EditorGUILayout.PropertyField(isKeystoneCorrected, new GUIContent("Keystone Correction", "Should this display be keystone corrected?"));
            if (isObliqueFrustum.boolValue)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(headTracker, new GUIContent("CAVE Head Tracker", "The head tracker object to use for perspective "
                                                                          + "distortion with CAVE-like displays. This is used only if the associated "
                                                                          + "RUISDisplay has 'Head Tracked CAVE Display' enabled."));
                EditorGUILayout.PropertyField(displayWidth, new GUIContent("Display Width", "The real-world width of the display"));
                EditorGUILayout.PropertyField(displayHeight, new GUIContent("Display Height", "The real-world height of the display"));
                EditorGUILayout.PropertyField(displayCenterPosition, new GUIContent("Display Center Position", "The location of the screen center in Unity coordinates"));
                EditorGUILayout.PropertyField(displayNormal, new GUIContent("Display Normal Vector", "The normal vector of the display (will be normalized)"));
                EditorGUILayout.PropertyField(displayUp, new GUIContent("Display Up Vector", "The up vector of the display (will be normalized)"));
                EditorGUI.indentLevel--;
            }
        }
        else
        {
            isObliqueFrustum.boolValue    = false;
            isKeystoneCorrected.boolValue = false;
        }

        previousOculusLowPersistenceValue = oculusLowPersistence.boolValue;

        serializedObject.ApplyModifiedProperties();


        int optimalWidth  = Screen.width - 4;
        int optimalHeight = (int)((float)resolutionY.intValue / resolutionX.intValue * optimalWidth);

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal(GUILayout.Height(optimalHeight));


        if (isStereo.boolValue)
        {
            displayBoxStyle.normal.background = stereoDisplayTexture;
        }
        else
        {
            displayBoxStyle.normal.background = monoDisplayTexture;
        }

        RUISDisplay display   = target as RUISDisplay;
        int         requiredX = display.rawResolutionX;
        int         requiredY = display.rawResolutionY;
        string      boxText   = string.Format("{0}\nTotal required resolution {1}x{2}", target.name, requiredX, requiredY);

        GUILayout.Box(boxText, displayBoxStyle, GUILayout.Width(optimalWidth), GUILayout.Height(optimalHeight));

        EditorGUILayout.EndHorizontal();

        displayManager.CalculateTotalResolution();
        PlayerSettings.defaultScreenWidth  = displayManager.totalRawResolutionX;
        PlayerSettings.defaultScreenHeight = displayManager.totalRawResolutionY;
    }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.PropertyField(displaySchema, new GUIContent("XML Schema", "Do not modify this unless you know what you're doing"));
        EditorGUILayout.PropertyField(xmlFilename, new GUIContent("XML filename", "The XML file with the display specifications"));
        EditorGUILayout.PropertyField(loadFromFileInEditor, new GUIContent("Load from File in Editor", "Load the information from the xml file while in editor mode."));

        EditorGUILayout.PropertyField(resolutionX, new GUIContent("Resolution X", "The pixel width of the display"));
        EditorGUILayout.PropertyField(resolutionY, new GUIContent("Resolution Y", "The pixel height of the display"));

        EditorGUILayout.PropertyField(isStereo, new GUIContent("Stereo Display", "Is this display stereo?"));
        if (isStereo.boolValue)
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(eyeSeparation, new GUIContent("Eye Separation", "Eye separation for the stereo image"));
            EditorGUILayout.PropertyField(stereoType, new GUIContent("Stereo Type", "The type of stereo to use"));
            EditorGUILayout.PropertyField(useDoubleTheSpace, new GUIContent("Double the Space used", "Calculate the total resolution of the display based on stereo type. \nSideBySide: Double horizontal resolution \nTopAndBottom: Double vertical resolution."));
            EditorGUI.indentLevel--;
        }

        EditorGUILayout.PropertyField(camera, new GUIContent("Attached Camera", "The RUISCamera that renders to this display"));



        EditorGUILayout.PropertyField(isHMD, new GUIContent("Enable Oculus Rift", "Is this display an Oculus Rift?"));

        if (!isHMD.boolValue)
        {
            //disabled for now EditorGUILayout.PropertyField(isKeystoneCorrected, new GUIContent("Keystone Correction", "Should this display be keystone corrected?"));

            EditorGUILayout.PropertyField(isObliqueFrustum, new GUIContent("Head Tracked CAVE Display", "Should the projection matrix be skewed to use this display as a head tracked CAVE viewport"));



            if (isObliqueFrustum.boolValue)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(headTracker, new GUIContent("CAVE Head Tracker", "The head tracker object to use for perspective "
                                                                          + "distortion with CAVE-like displays. This is used only if the associated "
                                                                          + "RUISDisplay has 'Head Tracked CAVE Display' enabled."));
                EditorGUILayout.PropertyField(displayWidth, new GUIContent("Display Width", "The real-world width of the display"));
                EditorGUILayout.PropertyField(displayHeight, new GUIContent("Display Height", "The real-world height of the display"));
                EditorGUILayout.PropertyField(displayCenterPosition, new GUIContent("Display Center Position", "The location of the screen center in Unity coordinates"));
                EditorGUILayout.PropertyField(displayNormal, new GUIContent("Display Normal Vector", "The normal vector of the display (will be normalized)"));
                EditorGUILayout.PropertyField(displayUp, new GUIContent("Display Up Vector", "The up vector of the display (will be normalized)"));
                EditorGUI.indentLevel--;
            }
        }
        else
        {
            isObliqueFrustum.boolValue    = false;
            isKeystoneCorrected.boolValue = false;
        }

        serializedObject.ApplyModifiedProperties();


        int optimalWidth  = Screen.width - 4;
        int optimalHeight = (int)((float)resolutionY.intValue / resolutionX.intValue * optimalWidth);

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal(GUILayout.Height(optimalHeight));


        if (isStereo.boolValue)
        {
            displayBoxStyle.normal.background = stereoDisplayTexture;
        }
        else
        {
            displayBoxStyle.normal.background = monoDisplayTexture;
        }

        RUISDisplay display   = target as RUISDisplay;
        int         requiredX = display.rawResolutionX;
        int         requiredY = display.rawResolutionY;
        string      boxText   = string.Format("{0}\nTotal required resolution {1}x{2}", target.name, requiredX, requiredY);

        GUILayout.Box(boxText, displayBoxStyle, GUILayout.Width(optimalWidth), GUILayout.Height(optimalHeight));

        EditorGUILayout.EndHorizontal();

        displayManager.CalculateTotalResolution();
        PlayerSettings.defaultScreenWidth  = displayManager.totalRawResolutionX;
        PlayerSettings.defaultScreenHeight = displayManager.totalRawResolutionY;
    }
コード例 #3
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        displayManagerLink.Update();

        EditorGUILayout.PropertyField(displays, true);

        EditorGUILayout.Space();

        //if there is only one display we want to give the user the opportunity to set fullscreen
        if (displays.arraySize == 1)
        {
//			allowResolutionDialog.boolValue = EditorGUILayout.Toggle(new GUIContent(  "Allow Resolution Dialog", "Enables the Resolution Dialog when your "
//			                                                                        + "standalone build starts if you have only one RUISDisplay. NOTE: In "
//			                                                                        + "all other cases the 'Display Resolution Dialog' setting in Unity's "
//			                                                                        + "Player Settings will be overriden with false. In those cases RUIS "
//			                                                                        + "will attempt to force the standalone game window to have the total "
//			                                                                        + "resolution that is the sum of your RUISDisplays arranged side-by-side."),
//			                                                         allowResolutionDialog.boolValue);
//            if (allowResolutionDialog.boolValue)
//            {
//                PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Enabled;
//            }
//            else
//            {
//                PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
//            }
        }
        else
        {
            EditorStyles.textField.wordWrap = true;
            EditorGUILayout.TextArea("Below configuration has multiple RUISDisplays. 'Display Resolution Dialog' setting is automatically disabled "
                                     + "in Unity's Player Settings.", GUILayout.Height(60));

            PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
//            allowResolutionDialog.boolValue = false;
        }

        if (GUILayout.Button("Add Display"))
        {
            displays.arraySize++;
            SerializedProperty newDisplayProperty = displays.GetArrayElementAtIndex(displays.arraySize - 1);
            GameObject         newDisplay         = Instantiate(displayPrefab) as GameObject;
            newDisplay.name = "NewDisplay";
            newDisplay.GetComponent <RUISDisplay>().xmlFilename = newDisplay.name + displays.arraySize + ".xml";
            newDisplay.transform.parent             = (target as RUISDisplayManager).transform;
            newDisplayProperty.objectReferenceValue = newDisplay;
        }

        EditorGUILayout.Space();

        int removeIndex = -1;

        for (int i = 0; i < displays.arraySize; i++)
        {
            //DisplayEditor(displays.GetArrayElementAtIndex(i));
            EditorGUILayout.BeginHorizontal();
            //EditorGUILayout.PropertyField(displays.GetArrayElementAtIndex(i));

            RUISDisplay display = displays.GetArrayElementAtIndex(i).objectReferenceValue as RUISDisplay;
            if (display == null)
            {
                continue;
            }
            EditorGUILayout.LabelField(string.Format("{0} ({1}x{2})", display.name, display.resolutionX, display.resolutionY));

            if (displays.arraySize > 1)
            {
                if (GUILayout.Button("Move Up", GUILayout.ExpandWidth(false)))
                {
                    MoveUp(i);
                }

                if (GUILayout.Button("Move Down", GUILayout.ExpandWidth(false)))
                {
                    MoveDown(i);
                }
            }

            if (GUILayout.Button("Delete", GUILayout.ExpandWidth(false)))
            {
                if (EditorUtility.DisplayDialog("Confirm deletion", "Are you sure you want to delete this display?", "Delete", "Cancel"))
                {
                    removeIndex = i;
                }
            }

            EditorGUILayout.EndHorizontal();
        }

        if (removeIndex != -1)
        {
            for (int i = removeIndex + 1; i < displays.arraySize; i++)
            {
                MoveUp(i);
            }
            displays.DeleteArrayElementAtIndex(displays.arraySize - 1);
            displays.arraySize--;
        }

        RUISDisplayManager displayManager = target as RUISDisplayManager;

        displayManager.CalculateTotalResolution();
        PlayerSettings.defaultScreenWidth  = displayManager.totalRawResolutionX;
        PlayerSettings.defaultScreenHeight = displayManager.totalRawResolutionY;

        //stuff for drawing the display boxes
        int optimalWidth  = Screen.width - displayManager.displays.Count;
        int optimalHeight = (int)((float)displayManager.totalResolutionY / displayManager.totalResolutionX * optimalWidth);

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal(GUILayout.Width(Screen.width), GUILayout.Height(optimalHeight));

        foreach (RUISDisplay display in displayManager.displays)
        {
            if (display.isStereo)
            {
                displayBoxStyle.normal.background = stereoDisplayTexture;
            }
            else
            {
                displayBoxStyle.normal.background = monoDisplayTexture;
            }
            GUILayout.Box(display.name, displayBoxStyle, GUILayout.Width(((float)display.resolutionX / displayManager.totalResolutionX) * optimalWidth), GUILayout.Height(optimalHeight * (float)display.resolutionY / displayManager.totalResolutionY));
        }

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Display With RUIS Menu:");
        guiDisplayChoices = new List <string>();
        for (int i = 0; i < displayManager.displays.Count; ++i)
        {
            guiDisplayChoices.Add(i + " " + displayManager.displays[i].name);
        }
        //MonoBehaviour.print(guiDisplayChoiceLink + ":" + guiDisplayChoices.Count);
        if (guiDisplayChoiceLink.intValue >= guiDisplayChoices.Count)
        {
            guiDisplayChoiceLink.intValue = 0;
        }
        guiDisplayChoiceLink.intValue = EditorGUILayout.Popup(guiDisplayChoiceLink.intValue, guiDisplayChoices.ToArray());
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.PropertyField(ruisMenuPrefab);



        EditorGUILayout.LabelField("RUIS Menu Local Coordinates:");
        EditorGUILayout.PropertyField(guiX, new GUIContent("X", "X-offset from camera"));
        EditorGUILayout.PropertyField(guiY, new GUIContent("Y", "Y-offset from camera"));
        EditorGUILayout.PropertyField(guiZ, new GUIContent("Z", "Z-offset from camera"));

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("RUIS Menu Scale:");
        EditorGUILayout.PropertyField(guiScaleX, new GUIContent("X-scale", "Scales menu horizontally"));
        EditorGUILayout.PropertyField(guiScaleY, new GUIContent("Y-scale", "Scales menu vertically"));
        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(hideMouseOnPlay, new GUIContent("Hide Mouse On Play", "Operating system mouse cursor will be hidden"));
        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(menuCursorPrefab, new GUIContent("Menu Cursor Prefab", "The prefab that will be instantiated when RUIS Menu is "
                                                                       + "invoked (ESC key)"));
        menuLayer.intValue = EditorGUILayout.LayerField(new GUIContent("Menu Layer", "RUIS Menu mouse cursor ray is cast against objects on this layer only"), menuLayer.intValue);


        serializedObject.ApplyModifiedProperties();
        displayManagerLink.ApplyModifiedProperties();


        //remove all child displays that aren't in the list anymore
        RUISDisplay displayToDestroy = null;

        foreach (RUISDisplay display in displayManager.GetComponentsInChildren <RUISDisplay>())
        {
            if (!displayManager.displays.Contains(display))
            {
                displayToDestroy = display;
            }
        }
        if (displayToDestroy)
        {
            DestroyImmediate(displayToDestroy.gameObject);
        }
    }
コード例 #4
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.PropertyField(displays, true);

        EditorGUILayout.Space();

        //if there is only one display we want to give the user the opportunity to set fullscreen
        if (displays.arraySize == 1)
        {
            allowResolutionDialog.boolValue = EditorGUILayout.Toggle(new GUIContent("Allow resolution dialog", "Allow the usage of the resolution dialog"), allowResolutionDialog.boolValue);
            if (allowResolutionDialog.boolValue)
            {
                PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Enabled;
            }
            else
            {
                PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
            }
        }
        else
        {
            PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
            allowResolutionDialog.boolValue        = false;
        }

        if (GUILayout.Button("Add display"))
        {
            displays.arraySize++;
            SerializedProperty newDisplayProperty = displays.GetArrayElementAtIndex(displays.arraySize - 1);
            GameObject         newDisplay         = Instantiate(displayPrefab) as GameObject;
            newDisplay.name = "NewDisplay";
            newDisplay.GetComponent <RUISDisplay>().xmlFilename = newDisplay.name + displays.arraySize + ".xml";
            newDisplay.transform.parent             = (target as RUISDisplayManager).transform;
            newDisplayProperty.objectReferenceValue = newDisplay;
        }

        EditorGUILayout.Space();

        int removeIndex = -1;

        for (int i = 0; i < displays.arraySize; i++)
        {
            //DisplayEditor(displays.GetArrayElementAtIndex(i));
            EditorGUILayout.BeginHorizontal();
            //EditorGUILayout.PropertyField(displays.GetArrayElementAtIndex(i));

            RUISDisplay display = displays.GetArrayElementAtIndex(i).objectReferenceValue as RUISDisplay;
            if (display == null)
            {
                continue;
            }
            EditorGUILayout.LabelField(string.Format("{0} ({1}x{2})", display.name, display.resolutionX, display.resolutionY));

            if (displays.arraySize > 1)
            {
                if (GUILayout.Button("Move up", GUILayout.ExpandWidth(false)))
                {
                    MoveUp(i);
                }

                if (GUILayout.Button("Move down", GUILayout.ExpandWidth(false)))
                {
                    MoveDown(i);
                }
            }

            if (GUILayout.Button("Delete", GUILayout.ExpandWidth(false)))
            {
                if (EditorUtility.DisplayDialog("Confirm deletion", "Are you sure you want to delete this display?", "Delete", "Cancel"))
                {
                    removeIndex = i;
                }
            }

            EditorGUILayout.EndHorizontal();
        }

        if (removeIndex != -1)
        {
            for (int i = removeIndex + 1; i < displays.arraySize; i++)
            {
                MoveUp(i);
            }
            displays.DeleteArrayElementAtIndex(displays.arraySize - 1);
            displays.arraySize--;
        }

        RUISDisplayManager displayManager = target as RUISDisplayManager;

        displayManager.CalculateTotalResolution();
        PlayerSettings.defaultScreenWidth  = displayManager.totalRawResolutionX;
        PlayerSettings.defaultScreenHeight = displayManager.totalRawResolutionY;

        //stuff for drawing the display boxes
        int optimalWidth  = Screen.width - displayManager.displays.Count;
        int optimalHeight = (int)((float)displayManager.totalResolutionY / displayManager.totalResolutionX * optimalWidth);

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal(GUILayout.Width(Screen.width), GUILayout.Height(optimalHeight));

        foreach (RUISDisplay display in displayManager.displays)
        {
            if (display.isStereo)
            {
                displayBoxStyle.normal.background = stereoDisplayTexture;
            }
            else
            {
                displayBoxStyle.normal.background = monoDisplayTexture;
            }
            GUILayout.Box(display.name, displayBoxStyle, GUILayout.Width(((float)display.resolutionX / displayManager.totalResolutionX) * optimalWidth), GUILayout.Height(optimalHeight * (float)display.resolutionY / displayManager.totalResolutionY));
        }

        EditorGUILayout.EndHorizontal();

        serializedObject.ApplyModifiedProperties();

        //remove all child displays that aren't in the list anymore
        RUISDisplay displayToDestroy = null;

        foreach (RUISDisplay display in displayManager.GetComponentsInChildren <RUISDisplay>())
        {
            if (!displayManager.displays.Contains(display))
            {
                displayToDestroy = display;
            }
        }
        if (displayToDestroy)
        {
            DestroyImmediate(displayToDestroy.gameObject);
        }
    }