Example #1
0
        private void HandlePlatformSettingUI()
        {
            int shownTextureFormatPage  = EditorGUILayout.BeginPlatformGrouping(m_ValidPlatforms.ToArray(), styles.defaultPlatformLabel);
            var defaultPlatformSettings = m_TempPlatformSettings[TextureImporterInspector.s_DefaultPlatformName];

            if (shownTextureFormatPage == -1)
            {
                if (m_TexturePlatformSettingsController.HandleDefaultSettings(defaultPlatformSettings, m_TexturePlatformSettingsView, m_TexturePlatformSettingTextureHelper))
                {
                    for (var i = 0; i < defaultPlatformSettings.Count; ++i)
                    {
                        SpriteAtlas sa = (SpriteAtlas)targets[i];
                        sa.SetPlatformSettings(defaultPlatformSettings[i]);
                    }
                }
            }
            else
            {
                var buildPlatform    = m_ValidPlatforms[shownTextureFormatPage];
                var platformSettings = m_TempPlatformSettings[buildPlatform.name];


                for (var i = 0; i < platformSettings.Count; ++i)
                {
                    var settings = platformSettings[i];
                    if (!settings.overridden)
                    {
                        if (defaultPlatformSettings[0].format == TextureImporterFormat.Automatic)
                        {
                            SpriteAtlas sa = (SpriteAtlas)targets[i];
                            settings.format = (TextureImporterFormat)sa.GetTextureFormat(buildPlatform.defaultTarget);
                        }
                        else
                        {
                            settings.format = defaultPlatformSettings[0].format;
                        }

                        settings.maxTextureSize      = defaultPlatformSettings[0].maxTextureSize;
                        settings.crunchedCompression = defaultPlatformSettings[0].crunchedCompression;
                        settings.compressionQuality  = defaultPlatformSettings[0].compressionQuality;
                    }
                }

                m_TexturePlatformSettingsView.buildPlatformTitle = buildPlatform.title.text;
                if (m_TexturePlatformSettingsController.HandlePlatformSettings(buildPlatform.defaultTarget, platformSettings, m_TexturePlatformSettingsView, m_TexturePlatformSettingTextureHelper))
                {
                    for (var i = 0; i < platformSettings.Count; ++i)
                    {
                        SpriteAtlas sa = (SpriteAtlas)targets[i];
                        sa.SetPlatformSettings(platformSettings[i]);
                    }
                }
            }

            EditorGUILayout.EndPlatformGrouping();
        }
Example #2
0
            public override void OnGUI(string searchContext)
            {
                var rect = EditorGUILayout.BeginVertical();

                EditorGUIUtility.labelWidth = rect.width / 2;

                int selectedPlatform = EditorGUILayout.BeginPlatformGrouping(validPlatforms, null);

                // During a build and other cases, the settings object can become invalid, if it does, we re-build it for the current platform
                // this fixes the settings failing to save if modified after a build has finished, and the settings were still open
                if (!m_PlatformSettings[selectedPlatform].isValid)
                {
                    var platformFields = typeof(BurstPlatformAotSettings).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
                    InitialiseSettingsForPlatform(selectedPlatform, platformFields);
                }

                var selectedTarget = validPlatforms[selectedPlatform].defaultTarget;

                if (validPlatforms[selectedPlatform].targetGroup == BuildTargetGroup.Standalone)
                {
                    selectedTarget = EditorUserBuildSettings.selectedStandaloneTarget;
                }

                if (validPlatforms[selectedPlatform].targetGroup == BuildTargetGroup.Standalone)
                {
                    // Note burst treats Windows and Windows32 as the same target from a settings point of view (same for linux)
                    // So we only display the standalone platform
                    EditorGUILayout.LabelField(EditorGUIUtility.TrTextContent("Target Platform", "Shows the currently selected standalone build target, can be switched in the Build Settings dialog"), EditorGUIUtility.TrTextContent(FetchStandaloneTargetName()));
                }

                for (int i = 0; i < m_PlatformProperties[selectedPlatform].Length; i++)
                {
                    if (m_PlatformVisibility[selectedPlatform][i](selectedTarget))
                    {
                        EditorGUILayout.PropertyField(m_PlatformProperties[selectedPlatform][i], m_PlatformToolTips[selectedPlatform][i]);
                    }
                }

                EditorGUILayout.EndPlatformGrouping();

                EditorGUILayout.EndVertical();

                if (m_PlatformSettings[selectedPlatform].hasModifiedProperties)
                {
                    m_PlatformSettings[selectedPlatform].ApplyModifiedPropertiesWithoutUndo();
                    ((BurstPlatformAotSettings)m_PlatformSettings[selectedPlatform].targetObject).Save(selectedTarget);
                }
            }
        private void HandlePlatformSettingUI()
        {
            int shownTextureFormatPage = EditorGUILayout.BeginPlatformGrouping(m_ValidPlatforms.ToArray(), s_Styles.defaultPlatformLabel);

            if (shownTextureFormatPage == -1)
            {
                var platformSettings = m_TempPlatformSettings[TextureImporterInspector.s_DefaultPlatformName];
                if (m_TexturePlatformSettingsController.HandleDefaultSettings(platformSettings, m_TexturePlatformSettingsView))
                {
                    for (var i = 0; i < platformSettings.Count; ++i)
                    {
                        SpriteAtlas sa = (SpriteAtlas)targets[i];
                        sa.SetPlatformSettings(platformSettings[i]);
                    }
                }
            }
            else
            {
                var buildPlatform    = m_ValidPlatforms[shownTextureFormatPage];
                var platformSettings = m_TempPlatformSettings[buildPlatform.name];


                // Predetermine format if overridden is unchecked
                for (var i = 0; i < platformSettings.Count; ++i)
                {
                    var settings = platformSettings[i];
                    if (!settings.overridden)
                    {
                        SpriteAtlas sa = (SpriteAtlas)targets[i];
                        settings.format = (TextureImporterFormat)sa.GetTextureFormat(buildPlatform.defaultTarget);
                    }
                }

                m_TexturePlatformSettingsView.buildPlatformTitle = buildPlatform.title.text;
                if (m_TexturePlatformSettingsController.HandlePlatformSettings(buildPlatform.defaultTarget, platformSettings, m_TexturePlatformSettingsView, m_TexturePlatformSettingTextureHelper))
                {
                    for (var i = 0; i < platformSettings.Count; ++i)
                    {
                        SpriteAtlas sa = (SpriteAtlas)targets[i];
                        sa.SetPlatformSettings(platformSettings[i]);
                    }
                }
            }

            EditorGUILayout.EndPlatformGrouping();
        }
Example #4
0
            public override void OnGUI(string searchContext)
            {
                EditorGUILayout.BeginVertical();

                int selectedPlatform = EditorGUILayout.BeginPlatformGrouping(validPlatforms, null);

                for (int i = 0; i < m_PlatformProperties[selectedPlatform].Length; i++)
                {
                    EditorGUILayout.PropertyField(m_PlatformProperties[selectedPlatform][i], m_PlatformToolTips[selectedPlatform][i]);
                }

                EditorGUILayout.EndPlatformGrouping();

                EditorGUILayout.EndVertical();

                if (m_PlatformSettings[selectedPlatform].hasModifiedProperties)
                {
                    m_PlatformSettings[selectedPlatform].ApplyModifiedPropertiesWithoutUndo();
                    ((BurstPlatformAotSettings)m_PlatformSettings[selectedPlatform].targetObject).Save(validPlatforms[selectedPlatform].defaultTarget);
                }
            }
        private void HandlePlatformSettingUI()
        {
            int shownTextureFormatPage = EditorGUILayout.BeginPlatformGrouping(m_ValidPlatforms.ToArray(), s_Styles.defaultPlatformLabel);

            if (shownTextureFormatPage == -1)
            {
                List <TextureImporterPlatformSettings> platformSettings = m_TempPlatformSettings[kDefaultPlatformName];
                List <TextureImporterPlatformSettings> newSettings      = new List <TextureImporterPlatformSettings>(platformSettings.Count);
                for (var i = 0; i < platformSettings.Count; ++i)
                {
                    TextureImporterPlatformSettings settings = new TextureImporterPlatformSettings();
                    platformSettings[i].CopyTo(settings);
                    newSettings.Add(settings);
                }

                if (m_TexturePlatformSettingsController.HandleDefaultSettings(newSettings, m_TexturePlatformSettingsView))
                {
                    for (var i = 0; i < newSettings.Count; ++i)
                    {
                        if (platformSettings[i].maxTextureSize != newSettings[i].maxTextureSize)
                        {
                            m_MaxTextureSize.intValue = newSettings[i].maxTextureSize;
                        }
                        if (platformSettings[i].textureCompression != newSettings[i].textureCompression)
                        {
                            m_TextureCompression.enumValueIndex = (int)newSettings[i].textureCompression;
                        }
                        if (platformSettings[i].crunchedCompression != newSettings[i].crunchedCompression)
                        {
                            m_UseCrunchedCompression.boolValue = newSettings[i].crunchedCompression;
                        }
                        if (platformSettings[i].compressionQuality != newSettings[i].compressionQuality)
                        {
                            m_CompressionQuality.intValue = newSettings[i].compressionQuality;
                        }

                        newSettings[i].CopyTo(platformSettings[i]);
                    }
                }
            }
            else
            {
                BuildPlatform buildPlatform = m_ValidPlatforms[shownTextureFormatPage];
                List <TextureImporterPlatformSettings> platformSettings = m_TempPlatformSettings[buildPlatform.name];

                // Predetermine format if overridden is unchecked
                for (var i = 0; i < platformSettings.Count; ++i)
                {
                    var settings = platformSettings[i];
                    if (!settings.overridden)
                    {
                        SpriteAtlas sa = (SpriteAtlas)targets[i];
                        settings.format = sa.FormatDetermineByAtlasSettings(buildPlatform.defaultTarget);
                    }
                }

                m_TexturePlatformSettingsView.buildPlatformTitle = buildPlatform.title.text;
                if (m_TexturePlatformSettingsController.HandlePlatformSettings(buildPlatform.defaultTarget, platformSettings, m_TexturePlatformSettingsView, m_TexturePlatformSettingTextureHelper))
                {
                    for (var i = 0; i < platformSettings.Count; ++i)
                    {
                        SpriteAtlas sa = (SpriteAtlas)targets[i];
                        sa.SetPlatformSettings(platformSettings[i]);
                    }
                }
            }

            EditorGUILayout.EndPlatformGrouping();
        }
Example #6
0
        private void HandlePlatformSettingUI()
        {
            int num = EditorGUILayout.BeginPlatformGrouping(this.m_ValidPlatforms.ToArray(), SpriteAtlasInspector.s_Styles.defaultPlatformLabel);

            if (num == -1)
            {
                List <TextureImporterPlatformSettings> list  = this.m_TempPlatformSettings[this.kDefaultPlatformName];
                List <TextureImporterPlatformSettings> list2 = new List <TextureImporterPlatformSettings>(list.Count);
                for (int i = 0; i < list.Count; i++)
                {
                    TextureImporterPlatformSettings textureImporterPlatformSettings = new TextureImporterPlatformSettings();
                    list[i].CopyTo(textureImporterPlatformSettings);
                    list2.Add(textureImporterPlatformSettings);
                }
                if (this.m_TexturePlatformSettingsController.HandleDefaultSettings(list2, this.m_TexturePlatformSettingsView))
                {
                    for (int j = 0; j < list2.Count; j++)
                    {
                        if (list[j].maxTextureSize != list2[j].maxTextureSize)
                        {
                            this.m_MaxTextureSize.intValue = list2[j].maxTextureSize;
                        }
                        if (list[j].textureCompression != list2[j].textureCompression)
                        {
                            this.m_TextureCompression.enumValueIndex = (int)list2[j].textureCompression;
                        }
                        if (list[j].crunchedCompression != list2[j].crunchedCompression)
                        {
                            this.m_UseCrunchedCompression.boolValue = list2[j].crunchedCompression;
                        }
                        if (list[j].compressionQuality != list2[j].compressionQuality)
                        {
                            this.m_CompressionQuality.intValue = list2[j].compressionQuality;
                        }
                        list2[j].CopyTo(list[j]);
                    }
                }
            }
            else
            {
                BuildPlatform buildPlatform = this.m_ValidPlatforms[num];
                List <TextureImporterPlatformSettings> list3 = this.m_TempPlatformSettings[buildPlatform.name];
                for (int k = 0; k < list3.Count; k++)
                {
                    TextureImporterPlatformSettings textureImporterPlatformSettings2 = list3[k];
                    if (!textureImporterPlatformSettings2.overridden)
                    {
                        SpriteAtlas spriteAtlas = (SpriteAtlas)base.targets[k];
                        textureImporterPlatformSettings2.format = spriteAtlas.FormatDetermineByAtlasSettings(buildPlatform.defaultTarget);
                    }
                }
                this.m_TexturePlatformSettingsView.buildPlatformTitle = buildPlatform.title.text;
                if (this.m_TexturePlatformSettingsController.HandlePlatformSettings(buildPlatform.defaultTarget, list3, this.m_TexturePlatformSettingsView, this.m_TexturePlatformSettingTextureHelper))
                {
                    for (int l = 0; l < list3.Count; l++)
                    {
                        SpriteAtlas spriteAtlas2 = (SpriteAtlas)base.targets[l];
                        spriteAtlas2.SetPlatformSettings(list3[l]);
                    }
                }
            }
            EditorGUILayout.EndPlatformGrouping();
        }
        private void HandlePlatformSettingUI(string secondaryTextureName)
        {
            int  shownTextureFormatPage       = EditorGUILayout.BeginPlatformGrouping(m_ValidPlatforms.ToArray(), styles.defaultPlatformLabel);
            var  defaultPlatformSettings      = m_TempPlatformSettings[TextureImporterInspector.s_DefaultPlatformName];
            bool isSecondary                  = secondaryTextureName != null;
            ITexturePlatformSettingsView view = isSecondary ? m_SecondaryTexturePlatformSettingsView : m_TexturePlatformSettingsView;

            if (shownTextureFormatPage == -1)
            {
                if (m_TexturePlatformSettingsController.HandleDefaultSettings(defaultPlatformSettings, m_TexturePlatformSettingsView, m_TexturePlatformSettingTextureHelper))
                {
                    for (var i = 0; i < defaultPlatformSettings.Count; ++i)
                    {
                        if (isSecondary)
                        {
                            spriteAtlasAsset.SetSecondaryPlatformSettings(defaultPlatformSettings[i], secondaryTextureName);
                        }
                        else
                        {
                            spriteAtlasAsset.SetPlatformSettings(defaultPlatformSettings[i]);
                        }
                    }
                    m_HasChanged = true;
                }
            }
            else
            {
                var buildPlatform    = m_ValidPlatforms[shownTextureFormatPage];
                var platformSettings = m_TempPlatformSettings[buildPlatform.name];


                for (var i = 0; i < platformSettings.Count; ++i)
                {
                    var settings = platformSettings[i];
                    if (!settings.overridden)
                    {
                        if (defaultPlatformSettings[0].format == TextureImporterFormat.Automatic)
                        {
                            settings.format = (TextureImporterFormat)spriteAtlasAsset.GetTextureFormat(buildPlatform.defaultTarget);
                        }
                        else
                        {
                            settings.format = defaultPlatformSettings[0].format;
                        }

                        settings.maxTextureSize      = defaultPlatformSettings[0].maxTextureSize;
                        settings.crunchedCompression = defaultPlatformSettings[0].crunchedCompression;
                        settings.compressionQuality  = defaultPlatformSettings[0].compressionQuality;
                    }
                }

                m_TexturePlatformSettingsView.buildPlatformTitle = buildPlatform.title.text;
                if (m_TexturePlatformSettingsController.HandlePlatformSettings(buildPlatform.defaultTarget, platformSettings, m_TexturePlatformSettingsView, m_TexturePlatformSettingTextureHelper))
                {
                    for (var i = 0; i < platformSettings.Count; ++i)
                    {
                        if (isSecondary)
                        {
                            spriteAtlasAsset.SetSecondaryPlatformSettings(platformSettings[i], secondaryTextureName);
                        }
                        else
                        {
                            spriteAtlasAsset.SetPlatformSettings(platformSettings[i]);
                        }
                    }
                    m_HasChanged = true;
                }
            }

            EditorGUILayout.EndPlatformGrouping();
        }