void LoadSettingsChildren_h(GameObject it = null) { if (it == null) { it = gameObject; } for (int i = 0; i < it.transform.childCount; i++) { GameObject child = it.transform.GetChild(i).gameObject; PhysicalDisplay physicalDisplay = GetComponent <PhysicalDisplay>(); if (physicalDisplay) { physicalDisplay.TryToDeSerialize(settingsToLoad); } LoadSettingsChildren_h(child); } }
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); } } }