Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            if (extraDataInitializeException != null)
            {
                ShowLoadErrorExceptionGUI(extraDataInitializeException);
                ApplyRevertGUI();
                return;
            }

            extraDataSerializedObject.Update();
            EditorGUI.BeginDisabled(m_ReferenceAsset.objectReferenceValue == null);
            EditorGUILayout.PropertyField(m_UseGUIDs, Styles.useGUID);
            EditorGUI.EndDisabled();

            EditorGUI.BeginChangeCheck();
            var obj = EditorGUILayout.ObjectField(Styles.assemblyDefinition, m_ReferenceAsset.objectReferenceValue, typeof(AssemblyDefinitionAsset), false);

            if (EditorGUI.EndChangeCheck())
            {
                m_ReferenceAsset.objectReferenceValue = obj;
                if (m_ReferenceAsset.objectReferenceValue != null)
                {
                    var data = CustomScriptAssemblyData.FromJson(((AssemblyDefinitionAsset)obj).text);
                    m_ReferenceName.stringValue = data.name;
                }
                else
                {
                    m_ReferenceName.stringValue = string.Empty;
                }
            }

            extraDataSerializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();
        }
        void DrawReferenceListElement(Rect rect, int index, bool selected, bool focused)
        {
            var assemblyDefinitionFile = m_ReferencesList.serializedProperty.GetArrayElementAtIndex(index);
            var nameProp  = assemblyDefinitionFile.FindPropertyRelative("name");
            var assetProp = assemblyDefinitionFile.FindPropertyRelative("asset");

            rect.height -= EditorGUIUtility.standardVerticalSpacing;
            var label = string.IsNullOrEmpty(nameProp.stringValue) ? L10n.Tr("(Missing Reference)") : nameProp.stringValue;

            using (var change = new EditorGUI.ChangeCheckScope())
            {
                EditorGUI.showMixedValue = assetProp.hasMultipleDifferentValues;
                EditorGUI.BeginDisabled(!string.IsNullOrEmpty(nameProp.stringValue) && assetProp.objectReferenceValue == null);
                var obj = EditorGUI.ObjectField(rect, EditorGUI.showMixedValue ? GUIContent.Temp("(Multiple Values)") : GUIContent.Temp(label), assetProp.objectReferenceValue, typeof(AssemblyDefinitionAsset), false);
                EditorGUI.showMixedValue = false;
                EditorGUI.EndDisabled();

                if (change.changed && obj != null)
                {
                    assetProp.objectReferenceValue = obj;
                    var data = CustomScriptAssemblyData.FromJson(((AssemblyDefinitionAsset)assetProp.objectReferenceValue).text);
                    nameProp.stringValue = data.name;
                }
            }
        }
Exemplo n.º 3
0
        protected override bool DrawWizardGUI()
        {
            EditorGUI.BeginChangeCheck();

            bool allowSceneObjects = !EditorUtility.IsPersistent(m_Terrain.terrainData); // sometimes user prefers saving terrainData with the scene file

            m_Tree = (GameObject)EditorGUILayout.ObjectField("Tree Prefab", m_Tree, typeof(GameObject), allowSceneObjects);
            if (m_Tree)
            {
                MeshRenderer meshRenderer = m_Tree.GetComponent <MeshRenderer>();
                if (meshRenderer)
                {
                    EditorGUI.BeginDisabled(true);
                    EditorGUILayout.EnumPopup("Cast Shadows", meshRenderer.shadowCastingMode);
                    EditorGUI.EndDisabled();
                }
            }
            if (!TerrainEditorUtility.IsLODTreePrototype(m_Tree))
            {
                m_BendFactor = EditorGUILayout.FloatField("Bend Factor", m_BendFactor);
            }

            bool changed = EditorGUI.EndChangeCheck();

            if (changed)
            {
                m_IsValidTree = IsValidTree(m_Tree, m_PrototypeIndex, m_Terrain);
            }
            return(changed);
        }
        private void DrawDefineConstraintListElement(Rect rect, int index, bool isactive, bool isfocused)
        {
            var list             = m_DefineConstraints.serializedProperty;
            var defineConstraint = list.GetArrayElementAtIndex(index).FindPropertyRelative("name");

            rect.height -= EditorGUIUtility.standardVerticalSpacing;

            var textFieldRect = new Rect(rect.x, rect.y + 1, rect.width - ReorderableList.Defaults.dragHandleWidth, rect.height);

            var validRect = new Rect(rect.width + ReorderableList.Defaults.dragHandleWidth + 1, rect.y + 1, ReorderableList.Defaults.dragHandleWidth, rect.height);

            string noValue = L10n.Tr("(Missing)");

            var  label = string.IsNullOrEmpty(defineConstraint.stringValue) ? noValue : defineConstraint.stringValue;
            bool mixed = defineConstraint.hasMultipleDifferentValues;

            EditorGUI.showMixedValue = mixed;
            var textFieldValue = EditorGUI.TextField(textFieldRect, mixed ? L10n.Tr("(Multiple Values)") : label);

            EditorGUI.showMixedValue = false;

            if (m_Defines != null)
            {
                EditorGUI.BeginDisabled(true);
                EditorGUI.Toggle(validRect, DefineConstraintsHelper.IsDefineConstraintValid(m_Defines, defineConstraint.stringValue));
                EditorGUI.EndDisabled();
            }

            if (!string.IsNullOrEmpty(textFieldValue) && textFieldValue != noValue)
            {
                defineConstraint.stringValue = textFieldValue;
            }
        }
        private void DrawPrecompiledReferenceListElement(Rect rect, int index, bool isactive, bool isfocused)
        {
            var precompiledReference = m_PrecompiledReferencesList.serializedProperty.GetArrayElementAtIndex(index);
            var nameProp             = precompiledReference.FindPropertyRelative("name");
            var pathProp             = precompiledReference.FindPropertyRelative("path");
            var fileNameProp         = precompiledReference.FindPropertyRelative("fileName");

            rect.height -= EditorGUIUtility.standardVerticalSpacing;
            GUIContent label = GUIContent.Temp(nameProp.stringValue);

            bool mixed = nameProp.hasMultipleDifferentValues;

            EditorGUI.showMixedValue = mixed;

            bool hasValue = !string.IsNullOrEmpty(pathProp.stringValue);

            if (!hasValue)
            {
                m_PrecompileReferenceListEntry.Insert(0, L10n.Tr("None"));

                if (m_PrecompileReferenceListEntry.Count == 1)
                {
                    label = EditorGUIUtility.TrTempContent("No possible references");
                }
                else
                {
                    label = EditorGUIUtility.TrTempContent("None");
                }
            }
            else
            {
                m_PrecompileReferenceListEntry.Insert(0, fileNameProp.stringValue);
            }

            int currentlySelectedIndex = 0;

            EditorGUI.BeginDisabled(!hasValue && !string.IsNullOrEmpty(nameProp.stringValue));
            int selectedIndex = EditorGUI.Popup(rect, label, currentlySelectedIndex, m_PrecompileReferenceListEntry.ToArray());

            EditorGUI.EndDisabled();


            if (selectedIndex > 0)
            {
                var selectedAssemblyName = m_PrecompileReferenceListEntry[selectedIndex];
                var assembly             = m_AssemblyProvider.GetPrecompiledAssemblies(
                    EditorScriptCompilationOptions.BuildingForEditor | EditorScriptCompilationOptions.BuildingWithAsserts,
                    EditorUserBuildSettings.activeBuildTargetGroup,
                    EditorUserBuildSettings.activeBuildTarget)
                                           .First(x => AssetPath.GetFileName(x.Path) == selectedAssemblyName);
                nameProp.stringValue     = selectedAssemblyName;
                pathProp.stringValue     = assembly.Path;
                fileNameProp.stringValue = AssetPath.GetFileName(assembly.Path);
            }

            m_PrecompileReferenceListEntry.RemoveAt(0);

            EditorGUI.showMixedValue = false;
        }
            protected override void EnabledGUI(Rect cellRect, SerializedNodeInfo node, ref RowGUIArgs args)
            {
                var serializedNode = node;

                EditorGUI.BeginDisabled(serializedNode.m_State == SerializedNodeInfo.State.Disabled);
                base.EnabledGUI(cellRect, node, ref args);
                EditorGUI.EndDisabled();
            }
Exemplo n.º 7
0
        void OnGUI()
        {
            GUILayout.Space(5);
            Event evt      = Event.current;
            bool  hitEnter = evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter);

            GUI.SetNextControlName("m_PreferencesName");
            EditorGUI.BeginChangeCheck();
            s_LayoutName = EditorGUILayout.TextField(s_LayoutName);
            if (EditorGUI.EndChangeCheck())
            {
                UpdateCurrentInvalidChars();
            }

            if (!m_DidFocus)
            {
                m_DidFocus = true;
                EditorGUI.FocusTextInControl("m_PreferencesName");
            }

            if (s_CurrentInvalidChars.Length != 0)
            {
                EditorGUILayout.HelpBox(string.Format(s_InvalidCharsFormatString, s_CurrentInvalidChars), MessageType.Warning);
                minSize = new Vector2(k_Width, k_Height + k_HelpBoxHeight);
            }
            else
            {
                minSize = new Vector2(k_Width, k_Height);
            }

            bool canSaveLayout = s_LayoutName.Length > 0 && s_CurrentInvalidChars.Length == 0;

            EditorGUI.BeginDisabled(!canSaveLayout);

            if (GUILayout.Button("Save") || hitEnter && canSaveLayout)
            {
                Close();

                if (!Directory.Exists(WindowLayout.layoutsModePreferencesPath))
                {
                    Directory.CreateDirectory(WindowLayout.layoutsModePreferencesPath);
                }

                string path = Path.Combine(WindowLayout.layoutsModePreferencesPath, s_LayoutName + ".wlt");
                Toolbar.lastLoadedLayoutName = s_LayoutName;
                WindowLayout.SaveWindowLayout(path);
                WindowLayout.ReloadWindowLayoutMenu();
                EditorUtility.Internal_UpdateAllMenus();
                ShortcutIntegration.instance.RebuildShortcuts();
                GUIUtility.ExitGUI();
            }
            else
            {
                m_DidFocus = false;
            }

            EditorGUI.EndDisabled();
        }
Exemplo n.º 8
0
        protected override bool DrawWizardGUI()
        {
            EditorGUI.BeginChangeCheck();

            m_DetailPrefab        = EditorGUILayout.ObjectField("Detail Prefab", m_DetailPrefab, typeof(GameObject), !TerrainDataIsPersistent) as GameObject;
            GUI.enabled           = terrainData.detailScatterMode == DetailScatterMode.CoverageMode;
            m_DetailDensity       = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.detailDensity, m_DetailDensity, 0, 3);
            GUI.enabled           = true;
            m_AlignToGround       = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.alignToGround, m_AlignToGround, 0, 100);
            m_PositionOrderliness = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.positionOrderliness, m_PositionOrderliness, 0, 100);
            m_MinWidth            = EditorGUILayout.FloatField("Min Width", m_MinWidth);
            m_MaxWidth            = EditorGUILayout.FloatField("Max Width", m_MaxWidth);
            m_MinHeight           = EditorGUILayout.FloatField("Min Height", m_MinHeight);
            m_MaxHeight           = EditorGUILayout.FloatField("Max Height", m_MaxHeight);
            m_NoiseSeed           = EditorGUILayout.IntField(DetailWizardSharedStyles.Instance.noiseSeed, m_NoiseSeed);
            m_NoiseSpread         = EditorGUILayout.FloatField(DetailWizardSharedStyles.Instance.noiseSpread, m_NoiseSpread);
            m_HoleEdgePadding     = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.holeEdgePadding, m_HoleEdgePadding, 0, 100);

            GUI.enabled     = terrainData.detailScatterMode == DetailScatterMode.CoverageMode;
            m_DetailDensity = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.detailDensity, m_DetailDensity, 0, 5);
            GUI.enabled     = true;

            if (!m_UseInstancing)
            {
                m_HealthyColor = EditorGUILayout.ColorField("Healthy Color", m_HealthyColor);
                m_DryColor     = EditorGUILayout.ColorField("Dry Color", m_DryColor);
            }

            if (m_UseInstancing)
            {
                EditorGUI.BeginDisabled(true);
                EditorGUILayout.EnumPopup("Render Mode", TerrainDetailMeshRenderMode.VertexLit);
                EditorGUI.EndDisabled();
            }
            else
            {
                m_RenderMode = (TerrainDetailMeshRenderMode)EditorGUILayout.EnumPopup("Render Mode", m_RenderMode);
            }

            m_UseInstancing = EditorGUILayout.Toggle("Use GPU Instancing", m_UseInstancing);
            if (m_UseInstancing)
            {
                EditorGUILayout.HelpBox("Using GPU Instancing would enable using the Material you set on the prefab.", MessageType.Info);
            }

            m_UseDensityScaling = EditorGUILayout.Toggle(DetailWizardSharedStyles.Instance.useDensityScaling, m_UseDensityScaling);

            if (!DetailPrototype.IsModeSupportedByRenderPipeline(ComputeRenderMode(), m_UseInstancing, out var message))
            {
                EditorGUILayout.LabelField(EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(MessageType.Error)), DetailWizardSharedStyles.Instance.helpBoxBig);
            }

            return(EditorGUI.EndChangeCheck());
        }
        public void HandleWindowDecorationStart(Rect windowPosition)
        {
            bool hasTitleBar = (windowPosition.y == 0 && (showMode != ShowMode.Utility && showMode != ShowMode.MainWindow) && !isPopup);

            if (!hasTitleBar)
            {
                return;
            }

            bool hasWindowButtons = Mathf.Abs(windowPosition.xMax - position.width) < 2;

            if (hasWindowButtons)
            {
                GUIStyle min          = Styles.buttonMin;
                GUIStyle close        = Styles.buttonClose;
                GUIStyle maxOrRestore = maximized ? Styles.buttonRestore : Styles.buttonMax;

                if (macEditor && (GUIView.focusedView == null || GUIView.focusedView.window != this))
                {
                    close = min = maxOrRestore = Styles.buttonInactive;
                }

                BeginTitleBarButtons(windowPosition);
                if (TitleBarButton(close))
                {
                    Close();
                    GUIUtility.ExitGUI();
                }

                if (macEditor && TitleBarButton(min))
                {
                    Minimize();
                }

                var canMaximize = m_MaxSize.x == 0 || m_MaxSize.y == 0 || m_MaxSize.x >= Screen.currentResolution.width || m_MaxSize.y >= Screen.currentResolution.height;
                EditorGUI.BeginDisabled(!canMaximize);
                if (TitleBarButton(maxOrRestore))
                {
                    ToggleMaximize();
                }
                EditorGUI.EndDisabled();
            }

            DragTitleBar(new Rect(0, 0, position.width, kTitleHeight));
        }
Exemplo n.º 10
0
            public void DrawProjection()
            {
                ProjectionType projectionType = orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective;

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = orthographic.hasMultipleDifferentValues;
                projectionType           = (ProjectionType)EditorGUILayout.EnumPopup(Styles.projection, projectionType);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    orthographic.boolValue = (projectionType == ProjectionType.Orthographic);
                }

                if (!orthographic.hasMultipleDifferentValues)
                {
                    if (projectionType == ProjectionType.Orthographic)
                    {
                        EditorGUILayout.PropertyField(orthographicSize, Styles.size);
                    }
                    else
                    {
                        float fovCurrentValue;
                        bool  multipleDifferentFovValues = false;
                        bool  isPhysicalCamera           = projectionMatrixMode.intValue == (int)Camera.ProjectionMatrixMode.PhysicalPropertiesBased;

                        var rect       = EditorGUILayout.GetControlRect();
                        var guiContent = EditorGUI.BeginProperty(rect, Styles.FOVAxisMode, fovAxisMode);
                        EditorGUI.showMixedValue = fovAxisMode.hasMultipleDifferentValues;

                        EditorGUI.BeginChangeCheck();
                        var fovAxisNewVal = (int)(Camera.FieldOfViewAxis)EditorGUI.EnumPopup(rect, guiContent, (Camera.FieldOfViewAxis)fovAxisMode.intValue);
                        if (EditorGUI.EndChangeCheck())
                        {
                            fovAxisMode.intValue = fovAxisNewVal;
                        }
                        EditorGUI.EndProperty();

                        bool fovAxisVertical = fovAxisMode.intValue == 0;

                        if (!fovAxisVertical && !fovAxisMode.hasMultipleDifferentValues)
                        {
                            var   targets     = m_SerializedObject.targetObjects;
                            var   camera0     = targets[0] as Camera;
                            float aspectRatio = isPhysicalCamera ? sensorSize.vector2Value.x / sensorSize.vector2Value.y : camera0.aspect;
                            // camera.aspect is not serialized so we have to check all targets.
                            fovCurrentValue = Camera.VerticalToHorizontalFieldOfView(camera0.fieldOfView, aspectRatio);
                            if (m_SerializedObject.targetObjectsCount > 1)
                            {
                                foreach (Camera camera in targets)
                                {
                                    if (camera.fieldOfView != fovCurrentValue)
                                    {
                                        multipleDifferentFovValues = true;
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            fovCurrentValue            = verticalFOV.floatValue;
                            multipleDifferentFovValues = fovAxisMode.hasMultipleDifferentValues;
                        }

                        EditorGUI.showMixedValue = multipleDifferentFovValues;
                        var content = EditorGUI.BeginProperty(EditorGUILayout.BeginHorizontal(), Styles.fieldOfView, verticalFOV);
                        EditorGUI.BeginDisabled(projectionMatrixMode.hasMultipleDifferentValues || isPhysicalCamera && (sensorSize.hasMultipleDifferentValues || fovAxisMode.hasMultipleDifferentValues));
                        EditorGUI.BeginChangeCheck();
                        var fovNewValue = EditorGUILayout.Slider(content, fovCurrentValue, 0.00001f, 179f);
                        var fovChanged  = EditorGUI.EndChangeCheck();
                        EditorGUI.EndDisabled();
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.EndProperty();
                        EditorGUI.showMixedValue = false;

                        content = EditorGUI.BeginProperty(EditorGUILayout.BeginHorizontal(), Styles.physicalCamera, projectionMatrixMode);
                        EditorGUI.showMixedValue = projectionMatrixMode.hasMultipleDifferentValues;

                        EditorGUI.BeginChangeCheck();
                        isPhysicalCamera = EditorGUILayout.Toggle(content, isPhysicalCamera);
                        if (EditorGUI.EndChangeCheck())
                        {
                            projectionMatrixMode.intValue = isPhysicalCamera ? (int)Camera.ProjectionMatrixMode.PhysicalPropertiesBased : (int)Camera.ProjectionMatrixMode.Implicit;
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.EndProperty();

                        EditorGUI.showMixedValue = false;
                        if (isPhysicalCamera && !projectionMatrixMode.hasMultipleDifferentValues)
                        {
                            using (new EditorGUI.IndentLevelScope())
                            {
                                using (var horizontal = new EditorGUILayout.HorizontalScope())
                                    using (new EditorGUI.PropertyScope(horizontal.rect, Styles.focalLength, focalLength))
                                        using (var checkScope = new EditorGUI.ChangeCheckScope())
                                        {
                                            EditorGUI.showMixedValue = focalLength.hasMultipleDifferentValues;
                                            float sensorLength   = fovAxisVertical ? sensorSize.vector2Value.y : sensorSize.vector2Value.x;
                                            float focalLengthVal = fovChanged ? Camera.FieldOfViewToFocalLength(fovNewValue, sensorLength) : focalLength.floatValue;
                                            focalLengthVal = EditorGUILayout.FloatField(Styles.focalLength, focalLengthVal);
                                            if (checkScope.changed || fovChanged)
                                            {
                                                focalLength.floatValue = focalLengthVal;
                                            }
                                        }

                                EditorGUI.showMixedValue = sensorSize.hasMultipleDifferentValues;
                                EditorGUI.BeginChangeCheck();
                                int filmGateIndex = Array.IndexOf(k_ApertureFormatValues, new Vector2((float)Math.Round(sensorSize.vector2Value.x, 3), (float)Math.Round(sensorSize.vector2Value.y, 3)));
                                if (filmGateIndex == -1)
                                {
                                    filmGateIndex = EditorGUILayout.Popup(Styles.cameraType, k_ApertureFormatNames.Length - 1, k_ApertureFormatNames);
                                }
                                else
                                {
                                    filmGateIndex = EditorGUILayout.Popup(Styles.cameraType, filmGateIndex, k_ApertureFormatNames);
                                }
                                EditorGUI.showMixedValue = false;
                                if (EditorGUI.EndChangeCheck() && filmGateIndex < k_ApertureFormatValues.Length)
                                {
                                    sensorSize.vector2Value = k_ApertureFormatValues[filmGateIndex];
                                }

                                EditorGUILayout.PropertyField(sensorSize, Styles.sensorSize);

                                EditorGUILayout.PropertyField(lensShift, Styles.lensShift);

                                using (var horizontal = new EditorGUILayout.HorizontalScope())
                                    using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, Styles.gateFit, gateFit))
                                        using (var checkScope = new EditorGUI.ChangeCheckScope())
                                        {
                                            int gateValue = (int)(Camera.GateFitMode)EditorGUILayout.EnumPopup(propertyScope.content, (Camera.GateFitMode)gateFit.intValue);
                                            if (checkScope.changed)
                                            {
                                                gateFit.intValue = gateValue;
                                            }
                                        }
                            }
                        }
                        else if (fovChanged)
                        {
                            verticalFOV.floatValue = fovAxisVertical ? fovNewValue : Camera.HorizontalToVerticalFieldOfView(fovNewValue, (m_SerializedObject.targetObjects[0] as Camera).aspect);
                        }
                        EditorGUILayout.Space();
                    }
                }
            }
Exemplo n.º 11
0
        private void DrawToolbar()
        {
            if (m_IsMultiEditing)
            {
                EditorGUILayout.HelpBox(s_Styles.disabledEditMessage, MessageType.Info);
            }

            EditorGUI.BeginDisabled(m_IsMultiEditing);
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditMode.DoInspectorToolbar(s_Styles.sceneViewEditModes, s_Styles.toolContents, GetBounds, this);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            // Tools box
            GUILayout.BeginVertical(EditorStyles.helpBox);
            string helpText = Styles.baseSceneEditingToolText;

            if (sceneViewEditing)
            {
                int index = ArrayUtility.IndexOf(s_Styles.sceneViewEditModes, EditMode.editMode);
                if (index >= 0)
                {
                    helpText = s_Styles.toolNames[index].text;
                }
            }

            GUILayout.Label(helpText, s_Styles.richTextMiniLabel);
            GUILayout.EndVertical();

            // Editing mode toolbar
            if (sceneViewEditing)
            {
                switch (EditMode.editMode)
                {
                case EditMode.SceneViewEditMode.LineRendererEdit:
                    DrawEditPointTools();
                    break;

                case EditMode.SceneViewEditMode.LineRendererCreate:
                    CreatePointTools();
                    break;
                }
            }
            if (!sceneViewEditing)
            {
                EditorGUI.BeginChangeCheck();
                showSimplifyPreview = EditorGUILayout.Toggle(s_Styles.simplifyPreview, showSimplifyPreview);
                EditorGUILayout.BeginHorizontal();
                simplifyTolerance = Mathf.Max(0, EditorGUILayout.FloatField(s_Styles.tolerance, simplifyTolerance));
                if (GUILayout.Button(s_Styles.simplify, EditorStyles.miniButton))
                {
                    SimplifyPoints();
                }
                if (EditorGUI.EndChangeCheck())
                {
                    ResetSimplifyPreview();
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }
            EditorGUILayout.Space();
            EditorGUI.EndDisabled();
        }
Exemplo n.º 12
0
        protected virtual LightingExplorerTableColumn[] Get2DLightColumns()
        {
            return(new[]
            {
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, Styles.Enabled, "m_Enabled", 50),              // 0: Enabled
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Name, Styles.Name, null, 200),                           // 1: Name
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Enum, Styles.Type, "m_LightType", 100, (r, prop, dep) => // 2
                {
                    if (prop != null)
                    {
                        if (prop.intValue != (int)Light2DType.Parametric)
                        {
                            EditorGUI.BeginProperty(r, GUIContent.none, prop);
                            EditorGUI.BeginChangeCheck();
                            int lightType = EditorGUI.IntPopup(r, prop.intValue - 1, Styles.Light2DTypeTitles, Styles.Light2DTypeValues);
                            if (EditorGUI.EndChangeCheck())
                            {
                                prop.intValue = lightType + 1;
                            }
                            EditorGUI.EndProperty();
                        }
                        else
                        {
                            EditorGUI.LabelField(r, Styles.Light2DParametric);
                        }
                    }
                }),                                                                                                                         // 2: LightType
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Color, Styles.Color, "m_Color", 100, (r, prop, dep) => // 3
                {
                    if (prop != null)
                    {
                        EditorGUI.PropertyField(r, prop, GUIContent.none);
                    }
                }),                                                                                                                                                 // 3: Color
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Custom, Styles.LightCookieSprite, "m_LightCookieSprite", 70, (r, prop, dep) => // 4
                {
                    if (prop != null)
                    {
                        var hasSpriteField = dep.Length > 0 && (dep[0].enumValueIndex == (int)Light2DType.Sprite);
                        if (hasSpriteField)
                        {
                            EditorGUI.BeginProperty(r, GUIContent.none, prop);
                            EditorGUI.BeginChangeCheck();
                            var sprite = EditorGUI.ObjectField(r, prop.objectReferenceValue, typeof(Sprite), false);
                            if (EditorGUI.EndChangeCheck())
                            {
                                prop.objectReferenceValue = sprite;
                            }
                            EditorGUI.EndProperty();
                        }
                    }
                }, null, null, new[] { 2 }),                                                                                                       // 4: Sprite
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, Styles.Intensity, "m_Intensity", 60, (r, prop, dep) => // 5
                {
                    if (prop != null)
                    {
                        EditorGUI.BeginProperty(r, GUIContent.none, prop);
                        EditorGUI.BeginChangeCheck();
                        var intensity = EditorGUI.FloatField(r, prop.floatValue);
                        if (EditorGUI.EndChangeCheck())
                        {
                            prop.floatValue = intensity < 0f ? 0f : intensity;
                        }
                        EditorGUI.EndProperty();
                    }
                }),                                                                                                                                          // 5: Intensity
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, Styles.FallOff, "m_ShapeLightFalloffSize", 60, (r, prop, dep) => // 6
                {
                    if (prop != null)
                    {
                        var hasFalloff = dep.Length > 0 && (dep[0].enumValueIndex == (int)Light2DType.Freeform);
                        if (hasFalloff)
                        {
                            EditorGUI.BeginProperty(r, GUIContent.none, prop);
                            EditorGUI.BeginChangeCheck();
                            var falloff = EditorGUI.FloatField(r, prop.floatValue);
                            if (EditorGUI.EndChangeCheck())
                            {
                                prop.floatValue = falloff < 0f ? 0f : falloff;
                            }
                            EditorGUI.EndProperty();
                        }
                    }
                }, null, null, new[] { 2 }),                                                                                                                     // 6: Falloff
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, Styles.FallOffStrength, "m_FalloffIntensity", 120, (r, prop, dep) => // 7
                {
                    if (prop != null)
                    {
                        var hasFalloff = dep.Length > 0 && (dep[0].enumValueIndex == (int)Light2DType.Freeform || dep[0].enumValueIndex == (int)Light2DType.Point);
                        if (hasFalloff)
                        {
                            EditorGUI.BeginProperty(r, GUIContent.none, prop);
                            EditorGUI.BeginChangeCheck();
                            var newValue = EditorGUI.Slider(r, prop.floatValue, 0f, 1f);
                            if (EditorGUI.EndChangeCheck())
                            {
                                prop.floatValue = Mathf.Clamp01(newValue);
                            }
                            EditorGUI.EndProperty();
                        }
                    }
                }, null, null, new[] { 2 }),                                                                                                         // 7: Falloff intensity
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Name, Styles.TargetSortingLayer, "m_ApplyToSortingLayers", 120, // 8
                                                (r, prop, dep) =>
                {
                    if (prop != null && prop.isArray)
                    {
                        var allSortingLayers = SortingLayer.layers;

                        var propArraySize = prop.arraySize;
                        if (propArraySize == allSortingLayers.Length)
                        {
                            EditorGUI.LabelField(r, Styles.All);
                        }
                        else if (propArraySize == 1)
                        {
                            EditorGUI.LabelField(r, SortingLayer.IDToName(prop.GetArrayElementAtIndex(0).intValue));
                        }
                        else if (propArraySize == 0)
                        {
                            EditorGUI.LabelField(r, Styles.None);
                        }
                        else
                        {
                            EditorGUI.LabelField(r, Styles.Mixed);
                        }
                    }
                }),                                                                                                                                                           // 8: Target Sorting Layer
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Custom, Styles.ShadowIntensityEnabled, "m_ShadowIntensityEnabled", 50, (r, prop, dep) => // 9
                {
                    if (prop != null)
                    {
                        var hasShadow = dep.Length > 0 && (dep[0].enumValueIndex != (int)Light2DType.Global);
                        if (hasShadow)
                        {
                            float off = Mathf.Max(0.0f, ((r.width / 2) - 8));
                            r.x += off;
                            r.width -= off;
                            EditorGUI.PropertyField(r, prop, GUIContent.none);
                        }
                    }
                }, null, null, new[] { 2 }),                                                                                                                     // 9: Shadow Intensity Enabled
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Custom, Styles.ShadowIntensity, "m_ShadowIntensity", 140, (r, prop, dep) => // 10
                {
                    if (prop != null)
                    {
                        var hasShadow = dep.Length > 0 && (dep[0].enumValueIndex != (int)Light2DType.Global);
                        if (hasShadow)
                        {
                            var shadowIntensityEnabled = dep[1].boolValue;

                            EditorGUI.BeginDisabled(!shadowIntensityEnabled);
                            EditorGUI.BeginChangeCheck();
                            var shadowIntensityProp = dep[0].serializedObject.FindProperty("m_ShadowIntensity");

                            var newShadowIntensity = EditorGUI.Slider(r, shadowIntensityProp.floatValue, 0f, 1f);
                            if (EditorGUI.EndChangeCheck())
                            {
                                shadowIntensityProp.floatValue = Mathf.Clamp01(newShadowIntensity);
                            }

                            EditorGUI.EndDisabled();
                        }
                    }
                }, null, null, new[] { 2, 9 }) // 10: Shadow Intensity
            });
        }
            public void DrawProjection()
            {
                ProjectionType projectionType = orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective;

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = orthographic.hasMultipleDifferentValues;
                projectionType           = (ProjectionType)EditorGUILayout.EnumPopup(Styles.projection, projectionType);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    orthographic.boolValue = (projectionType == ProjectionType.Orthographic);
                }

                if (!orthographic.hasMultipleDifferentValues)
                {
                    if (projectionType == ProjectionType.Orthographic)
                    {
                        EditorGUILayout.PropertyField(orthographicSize, Styles.size);
                    }
                    else
                    {
                        bool isPhysicalCamera = projectionMatrixMode.intValue == (int)Camera.ProjectionMatrixMode.PhysicalPropertiesBased;

                        GUIContent content = EditorGUI.BeginProperty(EditorGUILayout.BeginHorizontal(), Styles.fieldOfView, fieldOfView);
                        EditorGUI.BeginDisabled(projectionMatrixMode.hasMultipleDifferentValues || isPhysicalCamera && (focalLength.hasMultipleDifferentValues || sensorSize.hasMultipleDifferentValues));
                        EditorGUI.BeginChangeCheck();
                        float fovNewValue = EditorGUILayout.Slider(content, fieldOfView.floatValue, 1f, 179f);
                        bool  fovChanged  = EditorGUI.EndChangeCheck();
                        EditorGUI.EndDisabled();
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.EndProperty();

                        content = EditorGUI.BeginProperty(EditorGUILayout.BeginHorizontal(), Styles.physicalCamera, projectionMatrixMode);
                        EditorGUI.showMixedValue = projectionMatrixMode.hasMultipleDifferentValues;

                        EditorGUI.BeginChangeCheck();
                        isPhysicalCamera = EditorGUILayout.Toggle(content, isPhysicalCamera);
                        if (EditorGUI.EndChangeCheck())
                        {
                            projectionMatrixMode.intValue = isPhysicalCamera ? (int)Camera.ProjectionMatrixMode.PhysicalPropertiesBased : (int)Camera.ProjectionMatrixMode.Implicit;
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.EndProperty();

                        EditorGUI.showMixedValue = false;
                        if (isPhysicalCamera && !projectionMatrixMode.hasMultipleDifferentValues)
                        {
                            using (new EditorGUI.IndentLevelScope())
                            {
                                EditorGUI.showMixedValue = sensorSize.hasMultipleDifferentValues;
                                EditorGUI.BeginChangeCheck();
                                int filmGateIndex = Array.IndexOf(k_ApertureFormats, new Vector2((float)Math.Round(sensorSize.vector2Value.x, 3), (float)Math.Round(sensorSize.vector2Value.y, 3)));
                                if (filmGateIndex == -1)
                                {
                                    filmGateIndex = EditorGUILayout.Popup(Styles.cameraType, k_ApertureFormatNames.Length - 1, k_ApertureFormatNames);
                                }
                                else
                                {
                                    filmGateIndex = EditorGUILayout.Popup(Styles.cameraType, filmGateIndex, k_ApertureFormatNames);
                                }
                                EditorGUI.showMixedValue = false;
                                if (EditorGUI.EndChangeCheck() && filmGateIndex < k_ApertureFormats.Length)
                                {
                                    sensorSize.vector2Value = k_ApertureFormats[filmGateIndex];
                                }

                                EditorGUI.BeginChangeCheck();
                                EditorGUI.showMixedValue = focalLength.hasMultipleDifferentValues;

                                float focalLengthVal = fovChanged ? sensorSize.vector2Value.y * .5f / Mathf.Tan(Mathf.Deg2Rad * fovNewValue * .5f) : focalLength.floatValue;
                                focalLengthVal           = EditorGUILayout.FloatField(Styles.focalLength, focalLengthVal);
                                EditorGUI.showMixedValue = false;
                                if (EditorGUI.EndChangeCheck() || fovChanged)
                                {
                                    focalLength.floatValue = focalLengthVal;
                                }

                                EditorGUILayout.PropertyField(sensorSize, Styles.sensorSize);

                                EditorGUILayout.PropertyField(lensShift, Styles.lensShift);
                            }
                        }
                        else if (fovChanged)
                        {
                            fieldOfView.floatValue = fovNewValue;
                        }
                        EditorGUILayout.Space();
                    }
                }
            }
        public override void OnInspectorGUI()
        {
            if (initializeException != null)
            {
                ShowLoadErrorExceptionGUI(initializeException);
                ApplyRevertGUI();
                return;
            }

            extraDataSerializedObject.Update();

            var platforms = CompilationPipeline.GetAssemblyDefinitionPlatforms();

            using (new EditorGUI.DisabledScope(m_AssetIsReadonly))
            {
                if (targets.Length > 1)
                {
                    if (m_AssetIsReadonly)
                    {
                        EditorGUILayout.LabelField("One of the selected assembly definition files is read-only.");
                    }
                    using (new EditorGUI.DisabledScope(true))
                    {
                        var value = string.Join(", ", extraDataTargets.Select(t => t.name).ToArray());
                        EditorGUILayout.TextField(Styles.name, value, EditorStyles.textField);
                    }
                }
                else
                {
                    if (m_AssetIsReadonly)
                    {
                        EditorGUILayout.LabelField("The selected assembly definition file is read-only.");
                    }
                    EditorGUILayout.PropertyField(m_AssemblyName, Styles.name);
                }

                GUILayout.Label(Styles.generalOptions, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUILayout.PropertyField(m_AllowUnsafeCode, Styles.allowUnsafeCode);
                EditorGUILayout.PropertyField(m_AutoReferenced, Styles.autoReferenced);
                EditorGUILayout.PropertyField(m_NoEngineReferences, Styles.noEngineReferences);
                EditorGUILayout.PropertyField(m_OverrideReferences, Styles.overrideReferences);
                EditorGUILayout.PropertyField(m_RootNamespace, Styles.rootNamespace);

                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(Styles.defineConstraints, EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                if (m_DefineConstraints.serializedProperty.arraySize > 0)
                {
                    var defineConstraintsCompatible = true;

                    var defines = GetDefines();

                    if (defines != null)
                    {
                        for (var i = 0; i < m_DefineConstraints.serializedProperty.arraySize && defineConstraintsCompatible; ++i)
                        {
                            var defineConstraint = m_DefineConstraints.serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative("name").stringValue;

                            if (DefineConstraintsHelper.GetDefineConstraintCompatibility(defines, defineConstraint) != DefineConstraintsHelper.DefineConstraintStatus.Compatible)
                            {
                                defineConstraintsCompatible = false;
                            }
                        }

                        var constraintValidityRect = new Rect(GUILayoutUtility.GetLastRect());
                        constraintValidityRect.x = constraintValidityRect.width - Styles.kValidityIconWidth / 4;
                        var image   = defineConstraintsCompatible ? Styles.validDefineConstraint : Styles.invalidDefineConstraint;
                        var tooltip = Styles.GetTitleTooltipFromDefineConstraintCompatibility(defineConstraintsCompatible);
                        var content = new GUIContent(image, tooltip);

                        constraintValidityRect.width  = Styles.kValidityIconWidth;
                        constraintValidityRect.height = Styles.kValidityIconHeight;
                        EditorGUI.LabelField(constraintValidityRect, content);
                    }
                }

                m_DefineConstraints.DoLayoutList();

                GUILayout.Label(Styles.references, EditorStyles.boldLabel);

                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUI.BeginDisabled(m_ReferencesList.serializedProperty.arraySize == 0);
                EditorGUILayout.PropertyField(m_UseGUIDs, Styles.useGUIDs);
                EditorGUI.EndDisabled();
                EditorGUILayout.EndVertical();

                m_ReferencesList.DoLayoutList();

                if (extraDataTargets.Any(data => ((AssemblyDefinitionState)data).references != null && ((AssemblyDefinitionState)data).references.Any(x => x.asset == null)))
                {
                    EditorGUILayout.HelpBox("The grayed out assembly references are missing and will not be referenced during compilation.", MessageType.Info);
                }

                if (m_OverrideReferences.boolValue && !m_OverrideReferences.hasMultipleDifferentValues)
                {
                    GUILayout.Label(Styles.precompiledReferences, EditorStyles.boldLabel);

                    UpdatePrecompiledReferenceListEntry();
                    m_PrecompiledReferencesList.DoLayoutList();

                    if (extraDataTargets.Any(data => ((AssemblyDefinitionState)data).precompiledReferences.Any(x => string.IsNullOrEmpty(x.path) && !string.IsNullOrEmpty(x.name))))
                    {
                        EditorGUILayout.HelpBox("The grayed out assembly references are missing and will not be referenced during compilation.", MessageType.Info);
                    }
                }

                GUILayout.Label(Styles.platforms, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);

                using (var change = new EditorGUI.ChangeCheckScope())
                {
                    EditorGUILayout.PropertyField(m_CompatibleWithAnyPlatform, Styles.anyPlatform);
                    if (change.changed)
                    {
                        // Invert state include/exclude compatibility of states that have the opposite compatibility,
                        // so all states are either include or exclude.
                        var compatibleWithAny = m_CompatibleWithAnyPlatform.boolValue;
                        var needToSwap        = extraDataTargets.Cast <AssemblyDefinitionState>().Where(p => p.compatibleWithAnyPlatform != compatibleWithAny).ToList();
                        extraDataSerializedObject.ApplyModifiedProperties();
                        foreach (var state in needToSwap)
                        {
                            InversePlatformCompatibility(state);
                        }

                        extraDataSerializedObject.Update();
                    }
                }

                if (!m_CompatibleWithAnyPlatform.hasMultipleDifferentValues)
                {
                    GUILayout.Label(m_CompatibleWithAnyPlatform.boolValue ? Styles.excludePlatforms : Styles.includePlatforms, EditorStyles.boldLabel);

                    for (int i = 0; i < platforms.Length; ++i)
                    {
                        SerializedProperty property;
                        if (i >= m_PlatformCompatibility.arraySize)
                        {
                            m_PlatformCompatibility.arraySize++;
                            property           = m_PlatformCompatibility.GetArrayElementAtIndex(i);
                            property.boolValue = false;
                        }
                        else
                        {
                            property = m_PlatformCompatibility.GetArrayElementAtIndex(i);
                        }

                        EditorGUILayout.PropertyField(property, new GUIContent(platforms[i].DisplayName));
                    }

                    EditorGUILayout.Space();

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(Styles.selectAll))
                    {
                        var prop = m_PlatformCompatibility.GetArrayElementAtIndex(0);
                        var end  = m_PlatformCompatibility.GetEndProperty();
                        do
                        {
                            prop.boolValue = true;
                        }while (prop.Next(false) && !SerializedProperty.EqualContents(prop, end));
                    }

                    if (GUILayout.Button(Styles.deselectAll))
                    {
                        var prop = m_PlatformCompatibility.GetArrayElementAtIndex(0);
                        var end  = m_PlatformCompatibility.GetEndProperty();
                        do
                        {
                            prop.boolValue = false;
                        }while (prop.Next(false) && !SerializedProperty.EqualContents(prop, end));
                    }

                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                EditorGUILayout.BeginVertical(GUI.skin.box);
                GUILayout.Label(Styles.versionDefines, EditorStyles.boldLabel);
                m_VersionDefineList.DoLayoutList();
                EditorGUILayout.EndVertical();
            }

            extraDataSerializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();
        }
Exemplo n.º 15
0
        protected override bool DrawWizardGUI()
        {
            EditorGUI.BeginChangeCheck();

            bool allowSceneObjects = !EditorUtility.IsPersistent(terrain.terrainData); // sometimes user prefers saving terrainData with the scene file

            m_Tree = (GameObject)EditorGUILayout.ObjectField("Tree Prefab", m_Tree, typeof(GameObject), allowSceneObjects);
            if (m_Tree)
            {
                MeshRenderer meshRenderer = m_Tree.GetComponent <MeshRenderer>();
                if (meshRenderer)
                {
                    EditorGUI.BeginDisabled(true);
                    EditorGUILayout.EnumPopup("Cast Shadows", meshRenderer.shadowCastingMode);
                    EditorGUI.EndDisabled();
                }
            }
            if (!TerrainEditorUtility.IsLODTreePrototype(m_Tree))
            {
                m_BendFactor = EditorGUILayout.FloatField("Bend Factor", m_BendFactor);
            }
            else
            {
                EditorGUILayout.BeginHorizontal();

                LODGroup lodGroup = m_Tree.GetComponent <LODGroup>();

                NavMeshLodIndex navMeshLodIndex = NavMeshLodIndex.Custom;
                if (m_NavMeshLod == kNavMeshLodLast)
                {
                    navMeshLodIndex = NavMeshLodIndex.Last;
                }
                else if (m_NavMeshLod == kNavMeshLodFirst)
                {
                    navMeshLodIndex = NavMeshLodIndex.First;
                }

                navMeshLodIndex = (NavMeshLodIndex)EditorGUILayout.EnumPopup("NavMesh LOD Index", navMeshLodIndex, GUILayout.MinWidth(250));

                if (navMeshLodIndex == NavMeshLodIndex.First)
                {
                    m_NavMeshLod = kNavMeshLodFirst;
                }
                else if (navMeshLodIndex == NavMeshLodIndex.Last)
                {
                    m_NavMeshLod = kNavMeshLodLast;
                }
                else
                {
                    m_NavMeshLod = EditorGUILayout.IntSlider(m_NavMeshLod, 0, Mathf.Max(0, lodGroup.lodCount - 1));
                }

                EditorGUILayout.EndHorizontal();
            }

            bool changed = EditorGUI.EndChangeCheck();

            if (changed)
            {
                m_IsValidTree = IsValidTree(m_Tree, m_PrototypeIndex, terrain);
            }
            return(changed);
        }
        public void IconSectionGUI(NamedBuildTarget namedBuildTarget, ISettingEditorExtension settingsExtension, int platformID, int sectionIndex)
        {
            m_SelectedPlatform = platformID;
            if (!m_Owner.BeginSettingsBox(sectionIndex, SettingsContent.iconTitle))
            {
                m_Owner.EndSettingsBox();
                return;
            }

            var platformUsesStandardIcons = true;

            if (settingsExtension != null)
            {
                platformUsesStandardIcons = settingsExtension.UsesStandardIcons();
            }

            if (platformUsesStandardIcons)
            {
                var selectedDefault = (m_SelectedPlatform < 0);
                // Set default platform variables
                BuildPlatform platform = null;
                namedBuildTarget = NamedBuildTarget.Standalone;
                var platformName = "";

                // Override if a platform is selected
                if (!selectedDefault)
                {
                    platform         = m_ValidPlatforms[m_SelectedPlatform];
                    namedBuildTarget = platform.namedBuildTarget;
                    platformName     = platform.name;
                }

                if (namedBuildTarget == NamedBuildTarget.WebGL || namedBuildTarget == NamedBuildTarget.Server)
                {
                    PlayerSettingsEditor.ShowNoSettings();
                    EditorGUILayout.Space();
                }
                else if (namedBuildTarget != NamedBuildTarget.WindowsStoreApps) // UWP does this in its editor extension
                {
                    // Both default icon and Legacy icons are serialized to the same map
                    // That's why m_LegacyPlatformIcons can be excluded in two places (other place in CommonSettings())
                    using (var vertical = new EditorGUILayout.VerticalScope())
                        using (new EditorGUI.PropertyScope(vertical.rect, GUIContent.none, m_LegacyPlatformIcons))
                        {
                            // Get icons and icon sizes for selected platform (or default)
                            var icons   = PlayerSettings.GetPlatformIconsForTargetIcons(platformName, IconKind.Any, m_AllLegacyIcons);
                            var widths  = PlayerSettings.GetIconWidthsForPlatform(platformName, IconKind.Any);
                            var heights = PlayerSettings.GetIconHeightsForPlatform(platformName, IconKind.Any);
                            var kinds   = PlayerSettings.GetIconKindsForPlatform(platformName);

                            var overrideIcons = true;

                            if (!selectedDefault)
                            {
                                // If the list of icons for this platform is not empty (and has the correct size),
                                // consider the icon overridden for this platform
                                EditorGUI.BeginChangeCheck();
                                overrideIcons = (icons.Length == widths.Length);
                                overrideIcons = GUILayout.Toggle(overrideIcons, string.Format(L10n.Tr("Override for {0}"), platform.title.text));
                                EditorGUI.BeginDisabled(!overrideIcons);
                                var changed = EditorGUI.EndChangeCheck();
                                if (changed || (!overrideIcons && icons.Length > 0))
                                {
                                    // Set the list of icons to correct length if overridden, otherwise to an empty list
                                    if (overrideIcons)
                                    {
                                        icons = new Texture2D[widths.Length];
                                    }
                                    else
                                    {
                                        icons = new Texture2D[0];
                                    }

                                    if (changed)
                                    {
                                        SetLegacyPlatformIcons(platformName, icons, IconKind.Any, ref m_AllLegacyIcons);
                                    }
                                }
                            }

                            // Show the icons for this platform (or default)
                            EditorGUI.BeginChangeCheck();
                            for (int i = 0; i < widths.Length; i++)
                            {
                                var previewWidth  = Mathf.Min(kMaxPreviewSize, widths[i]);
                                var previewHeight = (int)((float)heights[i] * previewWidth / widths[i]); // take into account the aspect ratio

                                if (namedBuildTarget == NamedBuildTarget.iOS)
                                {
                                    // Spotlight icons begin with 120 but there are two in the list.
                                    // So check if the next one is 80.
                                    if (kinds[i] == IconKind.Spotlight && kinds[i - 1] != IconKind.Spotlight)
                                    {
                                        var labelRect = GUILayoutUtility.GetRect(EditorGUIUtility.labelWidth, 20);
                                        GUI.Label(new Rect(labelRect.x, labelRect.y, EditorGUIUtility.labelWidth, 20), "Spotlight icons", EditorStyles.boldLabel);
                                    }

                                    if (kinds[i] == IconKind.Settings && kinds[i - 1] != IconKind.Settings)
                                    {
                                        var labelRect = GUILayoutUtility.GetRect(EditorGUIUtility.labelWidth, 20);
                                        GUI.Label(new Rect(labelRect.x, labelRect.y, EditorGUIUtility.labelWidth, 20), "Settings icons", EditorStyles.boldLabel);
                                    }

                                    if (kinds[i] == IconKind.Notification && kinds[i - 1] != IconKind.Notification)
                                    {
                                        var labelRect = GUILayoutUtility.GetRect(EditorGUIUtility.labelWidth, 20);
                                        GUI.Label(new Rect(labelRect.x, labelRect.y, EditorGUIUtility.labelWidth, 20), "Notification icons", EditorStyles.boldLabel);
                                    }

                                    if (kinds[i] == IconKind.Store && kinds[i - 1] != IconKind.Store)
                                    {
                                        var labelRect = GUILayoutUtility.GetRect(EditorGUIUtility.labelWidth, 20);
                                        GUI.Label(new Rect(labelRect.x, labelRect.y, EditorGUIUtility.labelWidth, 20), "App Store icons", EditorStyles.boldLabel);
                                    }
                                }

                                var rect  = GUILayoutUtility.GetRect(kSlotSize, Mathf.Max(kSlotSize, previewHeight) + kIconSpacing);
                                var width = Mathf.Min(rect.width, EditorGUIUtility.labelWidth + 4 + kSlotSize + kIconSpacing + kMaxPreviewSize);

                                // Label
                                var label = widths[i] + "x" + heights[i];
                                GUI.Label(new Rect(rect.x, rect.y, width - kMaxPreviewSize - kSlotSize - 2 * kIconSpacing, 20), label);

                                // Texture slot
                                if (overrideIcons)
                                {
                                    var slotWidth  = kSlotSize;
                                    var slotHeight = (int)((float)heights[i] / widths[i] * kSlotSize); // take into account the aspect ratio
                                    icons[i] = (Texture2D)EditorGUI.ObjectField(
                                        new Rect(rect.x + width - kMaxPreviewSize - kSlotSize - kIconSpacing, rect.y, slotWidth, slotHeight),
                                        icons[i],
                                        typeof(Texture2D),
                                        false);
                                }

                                // Preview
                                var previewRect = new Rect(rect.x + width - kMaxPreviewSize, rect.y, previewWidth, previewHeight);
                                var closestIcon = PlayerSettings.GetPlatformIconForSizeForTargetIcons(platformName, widths[i], heights[i], kinds[i], m_AllLegacyIcons);
                                if (closestIcon != null)
                                {
                                    GUI.DrawTexture(previewRect, closestIcon);
                                }
                                else
                                {
                                    GUI.Box(previewRect, "");
                                }
                            }

                            // Save changes
                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RecordObjects(m_Owner.targets, SettingsContent.undoChangedIconString);
                                SetLegacyPlatformIcons(platformName, icons, IconKind.Any, ref m_AllLegacyIcons);
                            }

                            EditorGUI.EndDisabled();

                            if (namedBuildTarget == NamedBuildTarget.iOS || namedBuildTarget == NamedBuildTarget.tvOS)
                            {
                                EditorGUILayout.PropertyField(m_UIPrerenderedIcon, SettingsContent.UIPrerenderedIcon);
                                EditorGUILayout.Space();
                            }
                        }
                }
            }

            if (settingsExtension != null)
            {
                settingsExtension.IconSectionGUI();
            }

            m_Owner.EndSettingsBox();
        }