public override void OnInspectorGUI() { if (CanvasScalerEditor.s_Styles == null) { CanvasScalerEditor.s_Styles = new CanvasScalerEditor.Styles(); } bool flag = true; bool flag2 = false; bool flag3 = (base.target as CanvasScaler).GetComponent <Canvas>().renderMode == RenderMode.WorldSpace; for (int i = 0; i < base.targets.Length; i++) { CanvasScaler canvasScaler = base.targets[i] as CanvasScaler; Canvas component = canvasScaler.GetComponent <Canvas>(); if (!component.isRootCanvas) { flag = false; break; } if ((flag3 && component.renderMode != RenderMode.WorldSpace) || (!flag3 && component.renderMode == RenderMode.WorldSpace)) { flag2 = true; break; } } if (!flag) { EditorGUILayout.HelpBox("Non-root Canvases will not be scaled.", MessageType.Warning); } else { base.serializedObject.Update(); EditorGUI.showMixedValue = flag2; using (new EditorGUI.DisabledScope(flag3 || flag2)) { if (flag3 || flag2) { EditorGUILayout.Popup(CanvasScalerEditor.s_Styles.uiScaleModeContent.text, 0, new string[] { "World" }, new GUILayoutOption[0]); } else { EditorGUILayout.PropertyField(this.m_UiScaleMode, CanvasScalerEditor.s_Styles.uiScaleModeContent, new GUILayoutOption[0]); } } EditorGUI.showMixedValue = false; if (!flag2 && (flag3 || !this.m_UiScaleMode.hasMultipleDifferentValues)) { EditorGUILayout.Space(); if (flag3) { EditorGUILayout.PropertyField(this.m_DynamicPixelsPerUnit, new GUILayoutOption[0]); } else if (this.m_UiScaleMode.enumValueIndex == 0) { EditorGUILayout.PropertyField(this.m_ScaleFactor, new GUILayoutOption[0]); } else if (this.m_UiScaleMode.enumValueIndex == 1) { EditorGUILayout.PropertyField(this.m_ReferenceResolution, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_ScreenMatchMode, new GUILayoutOption[0]); if (this.m_ScreenMatchMode.enumValueIndex == 0 && !this.m_ScreenMatchMode.hasMultipleDifferentValues) { Rect controlRect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight + 12f, new GUILayoutOption[0]); CanvasScalerEditor.DualLabeledSlider(controlRect, this.m_MatchWidthOrHeight, CanvasScalerEditor.s_Styles.matchContent, CanvasScalerEditor.s_Styles.widthContent, CanvasScalerEditor.s_Styles.heightContent); } } else if (this.m_UiScaleMode.enumValueIndex == 2) { EditorGUILayout.PropertyField(this.m_PhysicalUnit, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_FallbackScreenDPI, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_DefaultSpriteDPI, new GUILayoutOption[0]); } EditorGUILayout.PropertyField(this.m_ReferencePixelsPerUnit, new GUILayoutOption[0]); } base.serializedObject.ApplyModifiedProperties(); } }
public override void OnInspectorGUI() { if (CanvasScalerEditor.s_Styles == null) CanvasScalerEditor.s_Styles = new CanvasScalerEditor.Styles(); bool flag1 = true; bool flag2 = false; bool flag3 = (this.target as CanvasScaler).GetComponent<Canvas>().renderMode == UnityEngine.RenderMode.WorldSpace; for (int index = 0; index < this.targets.Length; ++index) { Canvas component = (this.targets[index] as CanvasScaler).GetComponent<Canvas>(); if (!component.isRootCanvas) { flag1 = false; break; } if (flag3 && component.renderMode != UnityEngine.RenderMode.WorldSpace || !flag3 && component.renderMode == UnityEngine.RenderMode.WorldSpace) { flag2 = true; break; } } if (!flag1) { EditorGUILayout.HelpBox("Non-root Canvases will not be scaled.", MessageType.Warning); } else { this.serializedObject.Update(); EditorGUI.showMixedValue = flag2; EditorGUI.BeginDisabledGroup(flag3 || flag2); if (flag3 || flag2) EditorGUILayout.Popup(CanvasScalerEditor.s_Styles.uiScaleModeContent.text, 0, new string[1]{ "World" }, new GUILayoutOption[0]); else EditorGUILayout.PropertyField(this.m_UiScaleMode, CanvasScalerEditor.s_Styles.uiScaleModeContent, new GUILayoutOption[0]); EditorGUI.EndDisabledGroup(); EditorGUI.showMixedValue = false; if (!flag2 && (flag3 || !this.m_UiScaleMode.hasMultipleDifferentValues)) { EditorGUILayout.Space(); if (flag3) EditorGUILayout.PropertyField(this.m_DynamicPixelsPerUnit); else if (this.m_UiScaleMode.enumValueIndex == 0) EditorGUILayout.PropertyField(this.m_ScaleFactor); else if (this.m_UiScaleMode.enumValueIndex == 1) { EditorGUILayout.PropertyField(this.m_ReferenceResolution); EditorGUILayout.PropertyField(this.m_ScreenMatchMode); if (this.m_ScreenMatchMode.enumValueIndex == 0 && !this.m_ScreenMatchMode.hasMultipleDifferentValues) CanvasScalerEditor.DualLabeledSlider(EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight + 12f, new GUILayoutOption[0]), this.m_MatchWidthOrHeight, CanvasScalerEditor.s_Styles.matchContent, CanvasScalerEditor.s_Styles.widthContent, CanvasScalerEditor.s_Styles.heightContent); } else if (this.m_UiScaleMode.enumValueIndex == 2) { EditorGUILayout.PropertyField(this.m_PhysicalUnit); EditorGUILayout.PropertyField(this.m_FallbackScreenDPI); EditorGUILayout.PropertyField(this.m_DefaultSpriteDPI); } EditorGUILayout.PropertyField(this.m_ReferencePixelsPerUnit); } this.serializedObject.ApplyModifiedProperties(); } }