Example #1
0
        public override void OnInspectorGUI()
        {
            SpriteAtlasInspector.s_Styles = (SpriteAtlasInspector.s_Styles ?? new SpriteAtlasInspector.Styles());
            base.serializedObject.Update();
            this.HandleCommonSettingUI();
            GUILayout.Space(5f);
            if (this.AllTargetsAreVariant())
            {
                this.HandleVariantSettingUI();
            }
            else if (this.AllTargetsAreMaster())
            {
                this.HandleMasterSettingUI();
            }
            GUILayout.Space(5f);
            this.HandleTextureSettingUI();
            GUILayout.Space(5f);
            if (base.targets.Length == 1 && this.AllTargetsAreMaster())
            {
                this.HandlePackableListUI();
            }
            bool flag = EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnlyAtlas || EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOnAtlas;

            if (flag)
            {
                if (GUILayout.Button(SpriteAtlasInspector.s_Styles.packButton, new GUILayoutOption[]
                {
                    GUILayout.ExpandWidth(false)
                }))
                {
                    SpriteAtlas[] array = new SpriteAtlas[base.targets.Length];
                    for (int i = 0; i < array.Length; i++)
                    {
                        array[i] = (SpriteAtlas)base.targets[i];
                    }
                    SpriteAtlasUtility.PackAtlases(array, EditorUserBuildSettings.activeBuildTarget);
                    this.SyncPlatformSettings();
                    GUIUtility.ExitGUI();
                }
            }
            else
            {
                EditorGUILayout.HelpBox(SpriteAtlasInspector.s_Styles.disabledPackLabel.text, MessageType.Info);
            }
            base.serializedObject.ApplyModifiedProperties();
        }
        protected void PackPreviewGUI()
        {
            EditorGUILayout.Space();

            using (new GUILayout.HorizontalScope())
            {
                using (new EditorGUI.DisabledScope(!HasModified() || !IsValidAtlas()))
                {
                    GUILayout.FlexibleSpace();

                    if (GUILayout.Button("Pack Preview"))
                    {
                        GUI.FocusControl(null);
                        SpriteAtlasUtility.EnableV2Import(true);
                        SaveChanges();
                        SpriteAtlasUtility.EnableV2Import(false);
                    }
                }
            }
        }
Example #3
0
        public override void OnInspectorGUI()
        {
            // Ensure changes done through script are reflected immediately in Inspector by Syncing m_TempPlatformSettings with Actual Settings.
            SyncPlatformSettings();

            serializedObject.Update();

            HandleCommonSettingUI();

            GUILayout.Space(EditorGUI.kSpacing);

            if (AllTargetsAreVariant())
            {
                HandleVariantSettingUI();
            }
            else if (AllTargetsAreMaster())
            {
                HandleMasterSettingUI();
            }

            GUILayout.Space(EditorGUI.kSpacing);

            HandleTextureSettingUI();

            GUILayout.Space(EditorGUI.kSpacing);

            // Only show the packable object list when:
            // - This is a master atlas.
            // - It is not currently selecting multiple atlases.
            if (targets.Length == 1 && AllTargetsAreMaster())
            {
                HandlePackableListUI();
            }

            bool spriteAtlasPackignEnabled = (EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnlyAtlas ||
                                              EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOnAtlas || EditorSettings.spritePackerMode == SpritePackerMode.SpriteAtlasV2);

            if (spriteAtlasPackignEnabled)
            {
                if (GUILayout.Button(styles.packButton, GUILayout.ExpandWidth(false)))
                {
                    SpriteAtlas[] spriteAtlases = new SpriteAtlas[targets.Length];
                    for (int i = 0; i < spriteAtlases.Length; ++i)
                    {
                        spriteAtlases[i] = (SpriteAtlas)targets[i];
                    }

                    SpriteAtlasUtility.PackAtlases(spriteAtlases, EditorUserBuildSettings.activeBuildTarget);

                    // Packing an atlas might change platform settings in the process, reinitialize
                    SyncPlatformSettings();

                    GUIUtility.ExitGUI();
                }
            }
            else
            {
                if (GUILayout.Button(styles.disabledPackLabel, EditorStyles.helpBox))
                {
                    SettingsService.OpenProjectSettings("Project/Editor");
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            s_Styles = s_Styles ?? new Styles();

            serializedObject.Update();

            HandleCommonSettingUI();

            GUILayout.Space(EditorGUI.kSpacing);

            if (AllTargetsAreVariant())
            {
                HandleVariantSettingUI();
            }
            else if (AllTargetsAreMaster())
            {
                HandleMasterSettingUI();
            }

            GUILayout.Space(EditorGUI.kSpacing);

            HandleTextureSettingUI();

            GUILayout.Space(EditorGUI.kSpacing);

            // Only show the packable object list when:
            // - This is a master atlas.
            // - It is not currently selecting multiple atlases.
            if (targets.Length == 1 && AllTargetsAreMaster())
            {
                HandlePackableListUI();
            }

            bool spriteAtlasPackignEnabled = (EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnlyAtlas ||
                                              EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOnAtlas);

            if (spriteAtlasPackignEnabled)
            {
                if (GUILayout.Button(s_Styles.packButton, GUILayout.ExpandWidth(false)))
                {
                    SpriteAtlas[] spriteAtlases = new SpriteAtlas[targets.Length];
                    for (int i = 0; i < spriteAtlases.Length; ++i)
                    {
                        spriteAtlases[i] = (SpriteAtlas)targets[i];
                    }

                    SpriteAtlasUtility.PackAtlases(spriteAtlases, EditorUserBuildSettings.activeBuildTarget);

                    // Packing an atlas might change platform settings in the process, reinitialize
                    SyncPlatformSettings();

                    GUIUtility.ExitGUI();
                }
            }
            else
            {
                EditorGUILayout.HelpBox(s_Styles.disabledPackLabel.text, MessageType.Info);
            }

            serializedObject.ApplyModifiedProperties();
        }