private void ShowLODGUI() { m_ShowSmoothLODOptions.target = m_EnableSmoothLOD.hasMultipleDifferentValues || m_EnableSmoothLOD.boolValue; m_ShowCrossFadeWidthOptions.target = m_AnimateCrossFading.hasMultipleDifferentValues || !m_AnimateCrossFading.boolValue; GUILayout.Label(Styles.LODHeader, EditorStyles.boldLabel); EditorGUILayout.PropertyField(m_EnableSmoothLOD, Styles.SmoothLOD); EditorGUI.indentLevel++; if (EditorGUILayout.BeginFadeGroup(m_ShowSmoothLODOptions.faded)) { EditorGUILayout.PropertyField(m_AnimateCrossFading, Styles.AnimateCrossFading); if (EditorGUILayout.BeginFadeGroup(m_ShowCrossFadeWidthOptions.faded)) { EditorGUILayout.Slider(m_BillboardTransitionCrossFadeWidth, 0.0f, 1.0f, Styles.CrossFadeWidth); EditorGUILayout.Slider(m_FadeOutWidth, 0.0f, 1.0f, Styles.FadeOutWidth); } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.EndFadeGroup(); EditorGUI.indentLevel--; EditorGUILayout.Space(); if (HasSameLODConfig()) { EditorGUILayout.Space(); var area = GUILayoutUtility.GetRect(0, LODGroupGUI.kSliderBarHeight, GUILayout.ExpandWidth(true)); var lods = GetLODInfoArray(area); DrawLODLevelSlider(area, lods); EditorGUILayout.Space(); EditorGUILayout.Space(); if (m_SelectedLODRange != -1 && lods.Count > 0) { EditorGUILayout.LabelField(lods[m_SelectedLODRange].LODName + " Options", EditorStyles.boldLabel); bool isBillboard = (m_SelectedLODRange == lods.Count - 1) && importers.First().hasBillboard; EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("castShadows"), Styles.CastShadows); EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("receiveShadows"), Styles.ReceiveShadows); var useLightProbes = m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("useLightProbes"); EditorGUILayout.PropertyField(useLightProbes, Styles.UseLightProbes); if (!useLightProbes.hasMultipleDifferentValues && useLightProbes.boolValue && isBillboard) { EditorGUILayout.HelpBox("Enabling Light Probe for billboards breaks batched rendering and may cause performance problem.", MessageType.Warning); } // TODO: reflection probe support when PBS is implemented //EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("useReflectionProbes"), Styles.UseReflectionProbes); EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("enableBump"), Styles.EnableBump); EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("enableHue"), Styles.EnableHue); if (m_AllAreV8) { EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("enableSubsurface"), Styles.EnableSubsurface); } int bestWindQuality = importers.Min(im => im.bestWindQuality); if (bestWindQuality > 0) { if (isBillboard) { bestWindQuality = 1; // billboard has only one level of wind quality } EditorGUILayout.Popup( m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("windQuality"), SpeedTreeImporter.windQualityNames.Take(bestWindQuality + 1).Select(s => new GUIContent(s)).ToArray(), Styles.WindQuality); } } } else { if (CanUnifyLODConfig()) { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Rect buttonRect = GUILayoutUtility.GetRect(Styles.ResetLOD, EditorStyles.miniButton); if (GUI.Button(buttonRect, Styles.ResetLOD, EditorStyles.miniButton)) { var dropDownMenu = new GenericMenu(); foreach (var importer in targets.Cast <SpeedTreeImporter>()) { var menuText = String.Format("{0}: {1}", Path.GetFileNameWithoutExtension(importer.assetPath), String.Join(" | ", importer.LODHeights.Select(height => UnityString.Format("{0:0}%", height * 100)).ToArray())); dropDownMenu.AddItem(new GUIContent(menuText), false, OnResetLODMenuClick, importer); } dropDownMenu.DropDown(buttonRect); } EditorGUILayout.EndHorizontal(); } var area = GUILayoutUtility.GetRect(0, LODGroupGUI.kSliderBarHeight, GUILayout.ExpandWidth(true)); if (Event.current.type == EventType.Repaint) { LODGroupGUI.DrawMixedValueLODSlider(area); } } EditorGUILayout.Space(); }
private void ShowLODGUI() { this.m_ShowSmoothLODOptions.target = (this.m_EnableSmoothLOD.hasMultipleDifferentValues || this.m_EnableSmoothLOD.boolValue); this.m_ShowCrossFadeWidthOptions.target = (this.m_AnimateCrossFading.hasMultipleDifferentValues || !this.m_AnimateCrossFading.boolValue); GUILayout.Label(SpeedTreeImporterInspector.Styles.LODHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_EnableSmoothLOD, SpeedTreeImporterInspector.Styles.SmoothLOD, new GUILayoutOption[0]); EditorGUI.indentLevel++; if (EditorGUILayout.BeginFadeGroup(this.m_ShowSmoothLODOptions.faded)) { EditorGUILayout.PropertyField(this.m_AnimateCrossFading, SpeedTreeImporterInspector.Styles.AnimateCrossFading, new GUILayoutOption[0]); if (EditorGUILayout.BeginFadeGroup(this.m_ShowCrossFadeWidthOptions.faded)) { EditorGUILayout.Slider(this.m_BillboardTransitionCrossFadeWidth, 0f, 1f, SpeedTreeImporterInspector.Styles.CrossFadeWidth, new GUILayoutOption[0]); EditorGUILayout.Slider(this.m_FadeOutWidth, 0f, 1f, SpeedTreeImporterInspector.Styles.FadeOutWidth, new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.EndFadeGroup(); EditorGUI.indentLevel--; EditorGUILayout.Space(); if (this.HasSameLODConfig()) { EditorGUILayout.Space(); Rect rect = GUILayoutUtility.GetRect(0f, 30f, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); List <LODGroupGUI.LODInfo> lODInfoArray = this.GetLODInfoArray(rect); this.DrawLODLevelSlider(rect, lODInfoArray); EditorGUILayout.Space(); EditorGUILayout.Space(); if (this.m_SelectedLODRange != -1 && lODInfoArray.Count > 0) { EditorGUILayout.LabelField(lODInfoArray[this.m_SelectedLODRange].LODName + " Options", EditorStyles.boldLabel, new GUILayoutOption[0]); bool flag = this.m_SelectedLODRange == lODInfoArray.Count - 1 && this.importers[0].hasBillboard; EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("castShadows"), SpeedTreeImporterInspector.Styles.CastShadows, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("receiveShadows"), SpeedTreeImporterInspector.Styles.ReceiveShadows, new GUILayoutOption[0]); SerializedProperty serializedProperty = this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("useLightProbes"); EditorGUILayout.PropertyField(serializedProperty, SpeedTreeImporterInspector.Styles.UseLightProbes, new GUILayoutOption[0]); if (!serializedProperty.hasMultipleDifferentValues && serializedProperty.boolValue && flag) { EditorGUILayout.HelpBox("Enabling Light Probe for billboards breaks batched rendering and may cause performance problem.", MessageType.Warning); } EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("enableBump"), SpeedTreeImporterInspector.Styles.EnableBump, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("enableHue"), SpeedTreeImporterInspector.Styles.EnableHue, new GUILayoutOption[0]); int num = this.importers.Min((SpeedTreeImporter im) => im.bestWindQuality); if (num > 0) { if (flag) { num = ((num < 1) ? 0 : 1); } EditorGUILayout.Popup(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("windQuality"), (from s in SpeedTreeImporter.windQualityNames.Take(num + 1) select new GUIContent(s)).ToArray <GUIContent>(), SpeedTreeImporterInspector.Styles.WindQuality, new GUILayoutOption[0]); } } } else { if (this.CanUnifyLODConfig()) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); Rect rect2 = GUILayoutUtility.GetRect(SpeedTreeImporterInspector.Styles.ResetLOD, EditorStyles.miniButton); if (GUI.Button(rect2, SpeedTreeImporterInspector.Styles.ResetLOD, EditorStyles.miniButton)) { GenericMenu genericMenu = new GenericMenu(); foreach (SpeedTreeImporter current in base.targets.Cast <SpeedTreeImporter>()) { string text = string.Format("{0}: {1}", Path.GetFileNameWithoutExtension(current.assetPath), string.Join(" | ", (from height in current.LODHeights select string.Format("{0:0}%", height * 100f)).ToArray <string>())); genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.OnResetLODMenuClick), current); } genericMenu.DropDown(rect2); } EditorGUILayout.EndHorizontal(); } Rect rect3 = GUILayoutUtility.GetRect(0f, 30f, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); if (Event.current.type == EventType.Repaint) { LODGroupGUI.DrawMixedValueLODSlider(rect3); } } EditorGUILayout.Space(); }