void OnEnable() { // check for Holoplay if (holoplay == null) { holoplay = GetComponentInParent <Holoplay>(); if (holoplay == null) { enabled = false; Debug.LogWarning("[Holoplay] Simple DOF needs to be on a Holoplay capture's camera"); return; } } passdepthMat = new Material(Shader.Find("Holoplay/DOF/Pass Depth")); boxBlurMat = new Material(Shader.Find("Holoplay/DOF/Box Blur")); finalpassMat = new Material(Shader.Find("Holoplay/DOF/Final Pass")); }
// functions void OnEnable() { cam = GetComponent <Camera>(); cam.hideFlags = HideFlags.HideInInspector; lightfieldMat = new Material(Shader.Find("Holoplay/Lightfield")); SetupQuilt(); quiltRT = new RenderTexture(quiltSettings.quiltWidth, quiltSettings.quiltHeight, 0) { filterMode = FilterMode.Point, hideFlags = HideFlags.DontSave }; instance = this; // most recently enabled Capture set as instance // lightfield camera (only does blitting of the quilt into a lightfield) var lightfieldCamGO = new GameObject(lightfieldCamName); lightfieldCamGO.hideFlags = HideFlags.HideAndDontSave; lightfieldCamGO.transform.SetParent(transform); var lightfieldPost = lightfieldCamGO.AddComponent <LightfieldPostProcess>(); lightfieldPost.holoplay = this; lightfieldCam = lightfieldCamGO.AddComponent <Camera>(); #if UNITY_2017_3_OR_NEWER lightfieldCam.allowDynamicResolution = false; #endif lightfieldCam.allowHDR = false; lightfieldCam.allowMSAA = false; lightfieldCam.cullingMask = 0; lightfieldCam.clearFlags = CameraClearFlags.Nothing; // load calibration loadResults = ReloadCalibration(); if (!loadResults.calibrationFound) { Debug.Log("[Holoplay] Attempting to load calibration, but none found!"); } if (!loadResults.lkgDisplayFound) { Debug.Log("[Holoplay] No LKG display detected"); } Screen.SetResolution(cal.screenWidth, cal.screenHeight, true); // call initialization event if (onHoloplayReady != null) { onHoloplayReady.Invoke(loadResults); } }
// functions void OnEnable() { #if UNITY_POST_PROCESSING_STACK_V2 PostProcessLayer postLayer = GetComponent <PostProcessLayer>(); if (postLayer != null && postLayer.enabled) { postProcessCam = GetComponent <Camera>(); postProcessCam.hideFlags = HideFlags.HideInInspector; var camGO = new GameObject(postProcessCamName); camGO.hideFlags = HideFlags.HideAndDontSave; camGO.transform.SetParent(transform); camGO.transform.localPosition = Vector3.zero; camGO.transform.localRotation = Quaternion.identity; cam = camGO.AddComponent <Camera>(); cam.CopyFrom(postProcessCam); Debug.Log("set up cam"); } else #endif { cam = GetComponent <Camera>(); //Debug.Log("set up cam"+cam.projectionMatrix); cam.hideFlags = HideFlags.HideInInspector; } lightfieldMat = new Material(Shader.Find("Holoplay/Lightfield")); instance = this; // most recently enabled Capture set as instance // lightfield camera (only does blitting of the quilt into a lightfield) var lightfieldCamGO = new GameObject(lightfieldCamName); lightfieldCamGO.hideFlags = HideFlags.HideAndDontSave; lightfieldCamGO.transform.SetParent(transform); var lightfieldPost = lightfieldCamGO.AddComponent <LightfieldPostProcess>(); lightfieldPost.holoplay = this; lightfieldCam = lightfieldCamGO.AddComponent <Camera>(); #if UNITY_2017_3_OR_NEWER lightfieldCam.allowDynamicResolution = false; #endif lightfieldCam.allowHDR = false; lightfieldCam.allowMSAA = false; lightfieldCam.cullingMask = 0; lightfieldCam.clearFlags = CameraClearFlags.Nothing; #if !UNITY_EDITOR if (instance == null) { Debug.Log("empty when running"); } #endif ReloadCalibration(); // // load calibration // if (!loadResults.calibrationFound) // Debug.Log("[HoloPlay] Attempting to load calibration, but none found!"); // if (!loadResults.lkgDisplayFound) // Debug.Log("[HoloPlay] No LKG display detected"); // setup the window to play on the looking glass Screen.SetResolution(cal.screenWidth, cal.screenHeight, true); #if UNITY_2019_3_OR_NEWER if (!Application.isEditor && targetDisplay == 0) { #if UNITY_STANDALONE_OSX targetDisplay = PluginCore.GetLKGunityIndex(targetLKG); lightfieldCam.targetDisplay = targetDisplay; Display.displays[targetDisplay].Activate(); #else Display.displays[targetDisplay].Activate(0, 0, 0); #if UNITY_STANDALONE_WIN Display.displays[targetDisplay].SetParams( cal.screenWidth, cal.screenHeight, cal.xpos, cal.ypos ); // Debug.Debug.LogFormat("{0}, {1}, {2}, {3}", cal.screenWidth, cal.screenHeight, // cal.xpos, cal.ypos) #endif #endif } #endif // setup the quilt SetupQuilt(); // call initialization event if (onHoloplayReady != null) { onHoloplayReady.Invoke(loadResults); } }
public override void OnInspectorGUI() { // psuedo custom inspector SerializedProperty prop = serializedObject.GetIterator(); Holoplay hp = (Holoplay)target; // account for the first prop being the script bool firstProp = true; GUI.enabled = false; if (prop.NextVisible(true)) { do { // sections if (!advanced.DoSection(prop)) { continue; } if (!quilt.DoSection(prop)) { continue; } if (!gizmo.DoSection(prop)) { continue; } if (!events.DoSection(prop)) { continue; } if (!optimization.DoSection(prop)) { continue; } // skip custom quilt settings if preset not set to custom if (prop.name == "customQuiltSettings" && hp.quiltPreset != Quilt.Preset.Custom) { var qs = Quilt.GetPreset(hp.quiltPreset); EditorGUILayout.LabelField("Quilt Size: ", qs.quiltWidth + " x " + qs.quiltHeight); EditorGUILayout.LabelField("View Size: ", qs.viewWidth + " x " + qs.viewHeight); EditorGUILayout.LabelField("Tiling: ", qs.viewColumns + " x " + qs.viewRows); EditorGUILayout.LabelField("Views Total: ", "" + qs.numViews); continue; } // don't let quiltRT be editable if (prop.name == "quiltRT") { GUI.enabled = false; EditorGUILayout.PropertyField(prop, true); GUI.enabled = true; continue; } // target display if (prop.name == "targetDisplay") { DisplayTarget dt = (DisplayTarget)hp.targetDisplay; EditorGUI.BeginChangeCheck(); dt = (DisplayTarget)EditorGUILayout.EnumPopup("Target Display", dt); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(hp, "Change Target Display"); hp.targetDisplay = (int)dt; Preview.HandlePreview(false); } continue; } // if all's normal, just draw the property like normal EditorGUILayout.PropertyField(prop, true); // after script name, re-enable GUI if (firstProp) { // version EditorGUILayout.LabelField("Version", Holoplay.version.ToString() + Holoplay.versionLabel, EditorStyles.miniLabel); // re-enable gui and continue GUI.enabled = true; firstProp = false; } }while (prop.NextVisible(false)); } // because it's the last section and doesn't get closed out automatically, force this section to end optimization.ForceEnd(); serializedObject.ApplyModifiedProperties(); // toggle preview button if (GUILayout.Button(Preview.togglePreviewShortcut)) { Preview.HandlePreview(); } // reload calibration button if (GUILayout.Button("Reload Calibration")) { hp.ReloadCalibration(); int calibrationCount = Plugin.CalibrationCount(); string logStr = calibrationCount == 0 ? "[HoloPlay] No calibration found" : string.Format("[HoloPlay] Calibration reloaded! Found {0} calibrations", calibrationCount); Debug.Log(logStr); } // version // var versionStyle = new GUIStyle(EditorStyles.miniLabel); // EditorGUILayout.LabelField("Version", Holoplay.Version.AsString, versionStyle); }
// functions void OnEnable() { #if UNITY_POST_PROCESSING_STACK_V2 PostProcessLayer postLayer = GetComponent <PostProcessLayer>(); if (postLayer != null && postLayer.enabled) { postProcessCam = GetComponent <Camera>(); postProcessCam.hideFlags = HideFlags.HideInInspector; var camGO = new GameObject(postProcessCamName); camGO.hideFlags = HideFlags.HideAndDontSave; camGO.transform.SetParent(transform); camGO.transform.localPosition = Vector3.zero; camGO.transform.localRotation = Quaternion.identity; cam = camGO.AddComponent <Camera>(); cam.CopyFrom(postProcessCam); } else #endif { cam = GetComponent <Camera>(); cam.hideFlags = HideFlags.HideInInspector; } lightfieldMat = new Material(Shader.Find("Holoplay/Lightfield")); instance = this; // most recently enabled Capture set as instance // lightfield camera (only does blitting of the quilt into a lightfield) var lightfieldCamGO = new GameObject(lightfieldCamName); lightfieldCamGO.hideFlags = HideFlags.HideAndDontSave; lightfieldCamGO.transform.SetParent(transform); var lightfieldPost = lightfieldCamGO.AddComponent <LightfieldPostProcess>(); lightfieldPost.holoplay = this; lightfieldCam = lightfieldCamGO.AddComponent <Camera>(); #if UNITY_2017_3_OR_NEWER lightfieldCam.allowDynamicResolution = false; #endif lightfieldCam.allowHDR = false; lightfieldCam.allowMSAA = false; lightfieldCam.cullingMask = 0; lightfieldCam.clearFlags = CameraClearFlags.Nothing; // load calibration loadResults = ReloadCalibration(); if (!loadResults.calibrationFound) { Debug.Log("[Holoplay] Attempting to load calibration, but none found!"); } if (!loadResults.lkgDisplayFound) { Debug.Log("[Holoplay] No LKG display detected"); } // setup the window to play on the looking glass Screen.SetResolution(cal.screenWidth, cal.screenHeight, true); // setup the quilt SetupQuilt(); // call initialization event if (onHoloplayReady != null) { onHoloplayReady.Invoke(loadResults); } }