/// public override void OnInspectorGUI() { serializedObject.Update(); RoveEnvironment rove_environment = (RoveEnvironment)target; m_dark_style.normal.textColor = Color.white; m_dark_style.normal.background = m_bg; m_dark_style.fontSize = 12; m_dark_style.alignment = TextAnchor.MiddleLeft; EditorGUILayout.BeginVertical("box"); { EditorGUILayout.BeginVertical(m_dark_style); { GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); { int logo_width = 256; int logo_height = 64; GUILayout.Space((EditorGUIUtility.currentViewWidth / 2) - (logo_width / 2) - 10); EditorGUILayout.LabelField(new GUIContent(m_logo), GUILayout.Width(logo_width), GUILayout.Height(logo_height)); EditorGUILayout.EndHorizontal(); } GUILayout.Space(10); m_dark_style.normal.background = m_gbg; EditorGUILayout.BeginVertical(m_dark_style); { m_dark_style.fontSize = 17; m_dark_style.alignment = TextAnchor.MiddleCenter; EditorGUILayout.LabelField("Environment", m_dark_style); m_dark_style.fontSize = 12; m_dark_style.alignment = TextAnchor.MiddleLeft; EditorGUILayout.EndVertical(); } m_dark_style.normal.background = m_bg; EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); } EditorGUILayout.BeginVertical(m_dark_style); { GUILayout.Space(20); EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUI.BeginChangeCheck(); { EditorGUILayout.LabelField("Type: ", m_dark_style); mp_type.intValue = EditorGUILayout.Popup(mp_type.intValue, m_available_environments); if (Application.isPlaying && EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); serializedObject.Update(); rove_environment.SetType((uint)mp_type.intValue); if ((uint)mp_type.intValue == RoveEnvironment.TYPE_MAP) { rove_environment.SetEnvironmentMap( (Texture2D)mp_environment_map.objectReferenceValue); rove_environment.SetMapProperties(mp_map_intensity.floatValue, mp_map_rotation.floatValue); } } } EditorGUILayout.EndHorizontal(); } GUILayout.Space(20); EditorGUILayout.BeginVertical("box"); { if (mp_type.intValue == RoveEnvironment.TYPE_MAP) { EditorGUILayout.BeginHorizontal(m_dark_style); { m_dark_style.normal.background = m_wbg; EditorGUILayout.BeginVertical(m_dark_style); { EditorGUI.BeginChangeCheck(); { mp_environment_map.objectReferenceValue = EditorGUILayout.ObjectField( mp_environment_map.objectReferenceValue, typeof(Texture2D), false, GUILayout.MaxWidth(30.0f)); if (Application.isPlaying && EditorGUI.EndChangeCheck()) { rove_environment.SetEnvironmentMap( (Texture2D)mp_environment_map.objectReferenceValue); } } EditorGUILayout.EndVertical(); } m_dark_style.normal.background = m_bg; EditorGUILayout.LabelField("HDR Texture (RGBAHalf)", m_dark_style, GUILayout.MaxWidth(70.0f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } } EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUILayout.BeginVertical(m_dark_style); { if (mp_type.intValue == RoveEnvironment.TYPE_SKY) { EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUILayout.LabelField("Sky Intensity: ", m_dark_style, GUILayout.MaxWidth(80.0f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUILayout.LabelField("Sun Intensity: ", m_dark_style, GUILayout.MaxWidth(80.0f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUILayout.LabelField("Color: ", m_dark_style, GUILayout.MaxWidth(80.0f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); } else { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUILayout.LabelField("Intensity: ", m_dark_style, GUILayout.MaxWidth(80.0f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUILayout.LabelField("Rotation: ", m_dark_style, GUILayout.MaxWidth(80.0f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } /// EditorGUILayout.BeginVertical(m_dark_style); { if (mp_type.intValue == RoveEnvironment.TYPE_SKY) { EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUI.BeginChangeCheck(); { mp_sky_intensity.floatValue = EditorGUILayout.Slider(mp_sky_intensity.floatValue, 0.0f, 10.0f); if (Application.isPlaying && EditorGUI.EndChangeCheck()) { rove_environment.SetSkyIntensity(mp_sky_intensity.floatValue); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUI.BeginChangeCheck(); { mp_sun_intensity.floatValue = EditorGUILayout.Slider(mp_sun_intensity.floatValue, 0.0f, 2.0f); if (Application.isPlaying && EditorGUI.EndChangeCheck()) { rove_environment.SetSunIntensity(mp_sun_intensity.floatValue); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUI.BeginChangeCheck(); { mp_sun_color.colorValue = EditorGUILayout.ColorField(mp_sun_color.colorValue, GUILayout.MaxWidth(50.0f)); if (Application.isPlaying && EditorGUI.EndChangeCheck()) { rove_environment.SetSunColor(mp_sun_color.colorValue); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUI.BeginChangeCheck(); { mp_map_intensity.floatValue = EditorGUILayout.Slider(mp_map_intensity.floatValue, 0.0f, 10.0f); if (Application.isPlaying && EditorGUI.EndChangeCheck()) { rove_environment.SetMapProperties(mp_map_intensity.floatValue, mp_map_rotation.floatValue); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUI.BeginChangeCheck(); { mp_map_rotation.floatValue = EditorGUILayout.Slider(mp_map_rotation.floatValue, -1.0f, 1.0f); if (Application.isPlaying && EditorGUI.EndChangeCheck()) { rove_environment.SetMapProperties(mp_map_intensity.floatValue, mp_map_rotation.floatValue); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); } serializedObject.ApplyModifiedProperties(); }
/// IEnumerator SetupRove() { yield return(new WaitForEndOfFrame()); m_last_screen_size = new Vector2(Screen.width, Screen.height); string data_path = Application.dataPath + "/Rove/Data"; string log_path = data_path + "/rove.log"; bool valid_log_file = false; try { File.WriteAllText(log_path, "Test write to log."); valid_log_file = true; } catch { valid_log_file = false; } if (!valid_log_file) { Debug.LogError("Rove: Unable to write to log file at: " + log_path + "."); Destroy(this); yield return(null); } m_target_width = Screen.width >> m_target_downsample; m_target_height = Screen.height >> m_target_downsample; #if (UNITY_EDITOR) if (PlayerSettings.colorSpace != ColorSpace.Gamma) { Debug.LogWarning("Rove: Gamma color space is recommended."); } #endif m_target = new Texture2D(m_target_width, m_target_height, TextureFormat.ARGB32, false, true); m_target.filterMode = FilterMode.Bilinear; IntPtr native_tex = m_target.GetNativeTexturePtr(); m_target_material = (Material)Resources.Load("RoveTargetMaterial"); m_target_material.SetTexture("target", m_target); #if ((!ROVE_FORCE_GL) && (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)) IntPtr d3d11_device = RoveInternal.RoveUnityGetD3D11Device(); if (d3d11_device == IntPtr.Zero) { Debug.LogError("Failed to get D3D11 device."); Destroy(this); yield return(null); } RoveInternal.SetD3D11Device(d3d11_device); #endif GL.IssuePluginEvent(RoveInternal.Setup(data_path, m_use_multi_device, m_use_integrated_device, m_optimization_level, native_tex), 0); yield return(new WaitForEndOfFrame()); if (RoveInternal.GetLock() == LOCKED) { Debug.LogError("Rove: Failed setup; check 'Rove/Data/rove.log' " + "for details."); Destroy(this); yield return(null); } else { // Additional resize fixes bug on some Linux drivers. m_target.Resize(m_target_width, m_target_height); m_target.Apply(); native_tex = m_target.GetNativeTexturePtr(); GL.IssuePluginEvent(RoveInternal.Resize(native_tex), 0); yield return(new WaitForEndOfFrame()); if (RoveInternal.GetLock() == LOCKED) { Debug.LogError("Rove: Failed to resize; check 'Rove/Data/rove.log' " + "for details."); Destroy(this); yield return(null); } Color[] black_pixels = new Color[m_target_width * m_target_height]; for (uint p = 0; p < m_target_width * m_target_height; ++p) { black_pixels[p] = Color.black; } m_target.SetPixels(black_pixels); m_target.Apply(); m_system_info.m_thread_count = RoveInternal.GetThreadCount(); m_system_info.m_compute_api = RoveInternal.GetComputeAPI(); m_system_info.m_device_count = RoveInternal.GetDeviceCount(); m_system_info.m_device_names = new string[m_system_info.m_device_count]; for (uint d = 0; d < m_system_info.m_device_count; ++d) { m_system_info.m_device_names[d] = Marshal.PtrToStringAnsi(RoveInternal.GetDeviceName(d)); } } m_rove_camera = GetAPIComponent <RoveCamera>(); if (!m_rove_camera) { Debug.LogError("Rove: Could not find an active RoveCamera component."); Destroy(this); yield return(null); } m_rove_environment = GetAPIComponent <RoveEnvironment>(); if (!m_rove_environment) { Debug.LogError("Rove: Could not find an active RoveEnvironment component."); Destroy(this); yield return(null); } SetMaxBounces(m_max_bounces); SetSamplesPerFrame(m_samples_per_frame); m_rove_camera.SetCameraApertureSize(m_rove_camera.m_aperture_size); m_rove_camera.SetCameraFocalDepth(m_rove_camera.m_focal_depth); m_rove_camera.SetImageProperties(m_rove_camera.m_tonemap, m_rove_camera.m_gamma, m_rove_camera.m_exposure, m_rove_camera.m_contrast, m_rove_camera.m_saturation, m_rove_camera.m_brightness); m_rove_environment.SetType(m_rove_environment.m_type); if (m_rove_environment.m_type == RoveEnvironment.TYPE_MAP) { m_rove_environment.SetEnvironmentMap(m_rove_environment.m_environment_map); m_rove_environment.SetMapProperties(m_rove_environment.m_map_intensity, m_rove_environment.m_map_rotation); } m_setup_success = true; }