public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(networkManager))); //special handling for old machine names: SerializedProperty oldMachineName = serializedObject.FindProperty(nameof(oldHeadMachine)); SerializedProperty machineName = serializedObject.FindProperty(nameof(headMachineAsset)); MachineName.DrawDeprecatedMachineName(oldMachineName, machineName, "HeadMachine"); EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(serverAddress))); EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(serverPort))); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.Update(); //draw manager SerializedProperty manager = serializedObject.FindProperty(nameof(PhysicalDisplay.manager)); //cache original manager in case it changes PhysicalDisplayManager oldManager = manager.objectReferenceValue as PhysicalDisplayManager; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(manager); bool managerChanged = EditorGUI.EndChangeCheck(); PhysicalDisplayManager newManager = manager.objectReferenceValue as PhysicalDisplayManager; //draw machine name (only if there is no manager) SerializedProperty oldMachineName = serializedObject.FindProperty(nameof(PhysicalDisplay.oldMachineName)); SerializedProperty machineNameAsset = serializedObject.FindProperty(nameof(PhysicalDisplay.machineNameAsset)); if (!newManager) { MachineName.DrawDeprecatedMachineName(oldMachineName, machineNameAsset, "Machine Name"); } //draw display width, height SerializedProperty width = serializedObject.FindProperty(nameof(PhysicalDisplay.width)); SerializedProperty height = serializedObject.FindProperty(nameof(PhysicalDisplay.height)); EditorGUILayout.PropertyField(width); EditorGUILayout.PropertyField(height); //draw head configuration SerializedProperty head = serializedObject.FindProperty(nameof(PhysicalDisplay.head)); EditorGUILayout.PropertyField(head); //draw XR camera settings toggle SerializedProperty useXRCameras = serializedObject.FindProperty(nameof(PhysicalDisplay.useXRCameras)); GUIContent useXRCameras_content = new GUIContent(text: "Use XR Cameras (Quad Buffer)", tooltip: "Whether the cameras associated with this display should output to an XR device (such as headset or quad-buffered stereo 3D display).\n" + "If you do post processing on the cameras (such as a PhysicalDisplayCalibration) set this to false.\n" + "This is probably also unnecessary if using a Dual-Pipe 3D display."); EditorGUILayout.PropertyField(useXRCameras, useXRCameras_content); //draw render texture settings toggle SerializedProperty useRenderTextures = serializedObject.FindProperty(nameof(PhysicalDisplay.useRenderTextures)); GUIContent useRenderTextures_content = new GUIContent(text: "Use Render Textures", tooltip: "Render to render textures instead of screen, for post processing"); EditorGUILayout.PropertyField(useRenderTextures, useRenderTextures_content); //draw render texture settings if render textures are enabled SerializedProperty renderTextureSize = serializedObject.FindProperty(nameof(PhysicalDisplay.renderTextureSize)); if (useRenderTextures.boolValue) { EditorGUILayout.PropertyField(renderTextureSize); } //draw exclusive fullscreen toggle if render textures are disabled and there is no manager SerializedProperty exclusiveFullscreen = serializedObject.FindProperty(nameof(PhysicalDisplay.exclusiveFullscreen)); SerializedProperty display = serializedObject.FindProperty(nameof(PhysicalDisplay.display)); if (!useRenderTextures.boolValue && !newManager) { GUIContent exclusiveFullscreen_content = new GUIContent(text: "Use Specific Display"); EditorGUILayout.PropertyField(exclusiveFullscreen, exclusiveFullscreen_content); //draw display if exclusive fullscreen is enabled if (exclusiveFullscreen.boolValue) { EditorGUILayout.PropertyField(display); } } //force exclusive fullscreen mode off if there is a manager if (newManager && exclusiveFullscreen.boolValue) { exclusiveFullscreen.boolValue = false; } //draw 3D settings SerializedProperty is3D = serializedObject.FindProperty(nameof(PhysicalDisplay.is3D)); SerializedProperty dualPipe = serializedObject.FindProperty(nameof(PhysicalDisplay.dualPipe)); SerializedProperty dualInstance = serializedObject.FindProperty(nameof(PhysicalDisplay.dualInstance)); SerializedProperty windowBounds = serializedObject.FindProperty(nameof(PhysicalDisplay.windowBounds)); EditorGUILayout.PropertyField(is3D); if (is3D.boolValue) { //draw dual pipe toggle EditorGUILayout.PropertyField(dualPipe); if (dualPipe.boolValue) { //draw dual pipe settings SerializedProperty leftViewport = serializedObject.FindProperty(nameof(PhysicalDisplay.leftViewport)); SerializedProperty rightViewport = serializedObject.FindProperty(nameof(PhysicalDisplay.rightViewport)); EditorGUILayout.PropertyField(dualInstance); if (!exclusiveFullscreen.boolValue && !dualInstance.boolValue) { //3D, dual pipe, and single instance EditorGUILayout.PropertyField(windowBounds); } EditorGUILayout.PropertyField(leftViewport); EditorGUILayout.PropertyField(rightViewport); } else { //draw window settings EditorGUILayout.PropertyField(windowBounds); if (dualInstance.boolValue) { dualInstance.boolValue = false; } } } else { //draw window settings EditorGUILayout.PropertyField(windowBounds); if (dualPipe.boolValue) { dualPipe.boolValue = false; } if (dualInstance.boolValue) { dualInstance.boolValue = false; } } //draw settings toggle SerializedProperty loadSettingsAtRuntime = serializedObject.FindProperty(nameof(PhysicalDisplay.loadSettingsAtRuntime)); SerializedProperty serializedLocation = serializedObject.FindProperty(nameof(PhysicalDisplay.serializedLocation)); EditorGUILayout.PropertyField(loadSettingsAtRuntime); if (loadSettingsAtRuntime.boolValue) { EditorGUILayout.PropertyField(serializedLocation); } //done with serialized properties serializedObject.ApplyModifiedProperties(); //update manager if it changed PhysicalDisplay physicalDisplay = target as PhysicalDisplay; if (managerChanged) { PhysicalDisplayManager.SetManager(physicalDisplay, oldManager, newManager); } //JSON buttons if (GUILayout.Button("Export Display Settings to JSON")) { string path = EditorUtility.SaveFilePanel("Export Settings", "./", "settings.json", "json"); if (!string.IsNullOrEmpty(path)) { physicalDisplay.TryToSerialize(path); } } if (GUILayout.Button("Import Display Settings from JSON")) { string path = EditorUtility.SaveFilePanel("Import Settings", "./", "settings.json", "json"); if (!string.IsNullOrEmpty(path)) { physicalDisplay.TryToDeSerialize(path); } } }
public override void OnInspectorGUI() { serializedObject.Update(); //draw machine name SerializedProperty oldMachineName = serializedObject.FindProperty(nameof(PhysicalDisplayManager.oldMachineName)); SerializedProperty machineNameAsset = serializedObject.FindProperty(nameof(PhysicalDisplayManager.machineNameAsset)); MachineName.DrawDeprecatedMachineName(oldMachineName, machineNameAsset, "Machine Name"); //draw display settings SerializedProperty fullscreen = serializedObject.FindProperty(nameof(PhysicalDisplayManager.fullscreen)); EditorGUILayout.PropertyField(fullscreen); if (fullscreen.boolValue) { SerializedProperty displayNumber = serializedObject.FindProperty(nameof(PhysicalDisplayManager.displayNumber)); EditorGUILayout.PropertyField(displayNumber); } SerializedProperty displayResolution = serializedObject.FindProperty(nameof(PhysicalDisplayManager.displayResolution)); EditorGUILayout.PropertyField(displayResolution); serializedObject.ApplyModifiedProperties(); //draw buttons PhysicalDisplayManager physicalDisplayManager = target as PhysicalDisplayManager; if (GUILayout.Button("Assign Children To This Manager")) { foreach (Transform child in physicalDisplayManager.transform) { PhysicalDisplay childPD = child.GetComponent <PhysicalDisplay>(); if (childPD) { SetManager(childPD, childPD.manager, physicalDisplayManager, undoName: "Assign Children to Manager"); } } } //draw displays GUILayout.Label("Associated Displays:"); for (int i = 0; i < physicalDisplayManager.displays.Count; i++) { PhysicalDisplay pd = physicalDisplayManager.displays[i]; pd = EditorGUILayout.ObjectField(pd, typeof(PhysicalDisplay), true) as PhysicalDisplay; //remove any displays that are null if (!pd) { Undo.SetCurrentGroupName("Remove Display"); PhysicalDisplay physicalDisplay = physicalDisplayManager.displays[i]; Undo.RecordObject(physicalDisplay, string.Empty); if (physicalDisplay.manager == physicalDisplayManager) { physicalDisplay.manager = null; EditorUtility.SetDirty(physicalDisplay); } Undo.RecordObject(physicalDisplayManager, string.Empty); physicalDisplayManager.displays.RemoveAt(i); EditorUtility.SetDirty(physicalDisplayManager); Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); i--; } } //draw field to add displays PhysicalDisplay addedPD = EditorGUILayout.ObjectField("Add Display", null, typeof(PhysicalDisplay), true) as PhysicalDisplay; if (addedPD) { SetManager(addedPD, addedPD.manager, physicalDisplayManager, undoName: "Add Display"); } }