Beispiel #1
0
    public override void OnInspectorGUI()
    {
        PhysicalDisplayManager manager = target as PhysicalDisplayManager;

        manager.machineName       = EditorGUILayout.TextField("Machine Name", manager.machineName);
        manager.displayNumber     = EditorGUILayout.IntField("Display Number", manager.displayNumber);
        manager.displayResolution = EditorGUILayout.Vector2IntField("Resolution", manager.displayResolution);
        if (GUILayout.Button("Assign children to this manager"))
        {
            foreach (Transform child in manager.transform)
            {
                PhysicalDisplay disp = child.GetComponent <PhysicalDisplay>();
                if (disp != null)
                {
                    if (disp.manager != null)
                    {
                        disp.manager.displays.Remove(disp);
                    }
                    disp.manager = manager;
                    EditorUtility.SetDirty(disp);
                    if (!manager.displays.Contains(disp))
                    {
                        manager.displays.Add(disp);
                    }
                }
            }
        }
        GUILayout.Label("Associated displays:");
        for (int i = 0; i < manager.displays.Count; i++)
        {
            if (EditorGUILayout.ObjectField(manager.displays[i], typeof(PhysicalDisplay)) == null)
            {
                manager.displays.RemoveAt(i);
                i--;
            }
        }

        PhysicalDisplay addedDisp = (PhysicalDisplay)EditorGUILayout.ObjectField("Add Display", null, typeof(PhysicalDisplay));

        if (addedDisp != null)
        {
            if (addedDisp.manager != null)
            {
                addedDisp.manager.displays.Remove(addedDisp);
            }
            addedDisp.manager = manager;
            if (!manager.displays.Contains(addedDisp))
            {
                manager.displays.Add(addedDisp);
            }
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(manager);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
    }
Beispiel #2
0
    //public List<string> CleanSettings() {
    //    List<string> changedSettings = new List<string>();
    //    //clear all viewport stuff if using a certain display
    //    //or if using render textures for post processing
    //    if (exclusiveFullscreen) {

    //    }
    //    return changedSettings;
    //}

    void SetSettings(Settings settings)
    {
        manager     = settings.manager;
        head        = settings.head;
        machineName = settings.machineName;
        width       = settings.width;
        height      = settings.height;

        useXRCameras      = settings.useXRCameras;
        useRenderTextures = settings.useRenderTextures;
        renderTextureSize = settings.renderTextureSize;

        is3D = settings.is3D;
        exclusiveFullscreen = settings.exclusiveFullscreen;
        display             = settings.display;
        dualPipe            = settings.dualPipe;
        dualInstance        = settings.dualInstance;
        windowBounds        = settings.windowBounds;
        leftViewport        = settings.leftViewport;
        rightViewport       = settings.rightViewport;
    }
Beispiel #3
0
    public override void OnInspectorGUI()
    {
        PhysicalDisplay display = target as PhysicalDisplay;

        PhysicalDisplayManager newMan = (PhysicalDisplayManager)EditorGUILayout.ObjectField("Manager", display.manager, typeof(PhysicalDisplayManager), true);

        if (newMan != display.manager)
        {
            if (newMan != null)
            {
                newMan.displays.Add(display);
            }
            if (display.manager != null)
            {
                display.manager.displays.Remove(display);
            }
        }
        display.manager = newMan;

        if (newMan == null)
        {
            display.machineName = EditorGUILayout.TextField("Machine Name", display.machineName);
        }
        display.width  = EditorGUILayout.FloatField("Physical Width", display.width);
        display.height = EditorGUILayout.FloatField("Physical Height", display.height);
        display.head   = (HeadConfiguration)EditorGUILayout.ObjectField("Head", display.head, typeof(HeadConfiguration), true);

        display.useXRCameras = EditorGUILayout.Toggle(new GUIContent(
                                                          "Use XR Cameras (Quad Buffer)",
                                                          @"Whether the cameras associated with this display should output to an XR device (such as headset or quad-buffered stereo 3D display)
            If you do post processing on the cameras (such as a PhysicalDisplayCalibration) set this to false
            This is probably also unnecessary if using a Dual-Pipe 3D display"
                                                          ), display.useXRCameras
                                                      );
        display.useRenderTextures = EditorGUILayout.Toggle(new GUIContent("Use Render Textures", "Render to render textures instead of screen, for post processing"), display.useRenderTextures);
        if (display.useRenderTextures)
        {
            display.renderTextureSize = EditorGUILayout.Vector2IntField("Render Texture Size", display.renderTextureSize);
        }

        if (!display.useRenderTextures && display.manager == null)
        {
            if (display.exclusiveFullscreen = EditorGUILayout.Toggle("Use Specific Display", display.exclusiveFullscreen))
            {
                display.display = EditorGUILayout.IntField("Display", display.display);
            }
        }
        if (display.manager != null)
        {
            display.exclusiveFullscreen = false;
        }

        if (display.is3D = EditorGUILayout.Toggle("Is 3D", display.is3D))
        {
            if (display.dualPipe = EditorGUILayout.Toggle(new GUIContent("Dual Pipe", "Does the display use a dual pipe setup?"), display.dualPipe))
            {
                if (!display.exclusiveFullscreen && !(display.dualInstance = EditorGUILayout.Toggle(new GUIContent("Dual Instance", "Use one instance of Unity for each eye?"), display.dualInstance)))
                {
                    //3d, dual pipe, single instance
                    display.windowBounds = EditorGUILayout.RectIntField(new GUIContent("Viewport Rect", "Where the window will be positioned on the screen"), display.windowBounds);
                }
                display.leftViewport  = EditorGUILayout.RectIntField("Left Viewport", display.leftViewport);
                display.rightViewport = EditorGUILayout.RectIntField("Right Viewport", display.rightViewport);
            }
            else
            {
                display.windowBounds = EditorGUILayout.RectIntField(new GUIContent("Viewport Rect", "Where the window will be positioned on the screen"), display.windowBounds);
                display.dualInstance = false;
            }
        }
        else
        {
            display.windowBounds = EditorGUILayout.RectIntField(new GUIContent("Viewport Rect", "Where the window will be positioned on the screen"), display.windowBounds);
            display.dualPipe     = false;
            display.dualInstance = false;
        }

        List <string> errors = display.GetSettingsErrors();

        if (errors.Count != 0)
        {
            GUIStyle style = new GUIStyle();
            style.richText = true;
            EditorGUILayout.LabelField("<color=red>This PhysicalDisplay has some incompatible or invalid settings, behavior may be undefined!</color>", style);
        }
        foreach (string error in errors)
        {
            GUIStyle style = new GUIStyle();
            style.richText = true;
            EditorGUILayout.LabelField("<color=red>" + error + "</color>", style);
        }


        if (display.loadSettingsAtRuntime = EditorGUILayout.Toggle("Load Settings At Runtime", display.loadSettingsAtRuntime))
        {
            display.serializedLocation = EditorGUILayout.TextField(display.serializedLocation);
        }
        if (GUILayout.Button("Export Display Settings to JSON"))
        {
            string path = EditorUtility.SaveFilePanel("Export Settings", "./", "settings.json", "json");
            if (path != null)
            {
                display.TryToSerialize(path);
            }
        }
        if (GUILayout.Button("Import Display Settings from JSON"))
        {
            string path = EditorUtility.SaveFilePanel("Import Settings", "./", "settings.json", "json");
            if (path != null)
            {
                display.TryToDeSerialize(path);
            }
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(display);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
    }