Example #1
0
        /// <summary>
        /// Display the texture section.
        /// </summary>
        private void DisplayTextureSettingsSection()
        {
            _showTextureSettings = EditorGUILayout.Foldout(_showTextureSettings, "Texture Atlas Settings:");
            if (_showTextureSettings)
            {
                if (_superCombiner._combiningState == SuperCombiner.CombineStatesList.Uncombined)
                {
                    GUI.enabled = true;
                }
                else
                {
                    GUI.enabled = false;
                }

                //GUILayout.Label ("Texture Atlas", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                GUILayout.Label("The first _material found in all game objects to combine will be used as a reference for the combined _material.", EditorStyles.wordWrappedMiniLabel);

                // Atlas Texture Size choice
                _superCombiner._textureAtlasSize = EditorGUILayout.IntPopup("Texture Atlas size", _superCombiner._textureAtlasSize, _TextureAtlasSizesNames.ToArray(), _TextureAtlasSizes.ToArray(), GUILayout.ExpandWidth(true));

                _showAdditionalParameters = EditorGUILayout.Foldout(_showAdditionalParameters, "Additional parameters");
                if (_showAdditionalParameters)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    // Multi materials group
                    DisplayMultiMaterialSettingsSection();

                    // Custom Shader propertues
                    EditorGUILayout.PropertyField(_customShaderProperties, new GUIContent("Custom shader properties", "Super Combiner uses the list of texture properties from standard shader. If you are using custom shader with different texture properties, add their exact name in the list."), true);

                    // Tiling factor
                    _superCombiner._tilingFactor = EditorGUILayout.Slider(new GUIContent("tiling factor", "Apply a tiling factor on the textures. This may be helpfull if you observe strange artifacts after combining materials with heightmap"), _superCombiner._tilingFactor, 1, 2, GUILayout.ExpandWidth(true));

                    //Atlas Padding
                    _superCombiner._atlasPadding = EditorGUILayout.IntField(new GUIContent("padding", "Padding between textures in the atlas"), _superCombiner._atlasPadding, GUILayout.ExpandWidth(true));

                    // Force UV to [0, 1] mode
                    //_superCombiner._forceUVTo0_1 = EditorGUILayout.Toggle(new GUIContent("Force UV to [0,1]", "Only consider UV that are in [0, 1] range so that textures won't be tiled in the atlas"), _superCombiner._forceUVTo0_1);

                    EditorGUILayout.EndVertical();
                }

                if (_superCombiner._combiningState == SuperCombiner.CombineStatesList.Uncombined)
                {
                    if (GUILayout.Button(new GUIContent("Create atlas texture", "This will combine materials and create the atlas texture(s) only. This is usefull to check if atlas texture(s) are correct without having to combine meshes which is time consuming. When materials have been combined, you'll need to hit 'Combine' button to finish the process and combine meshes."), GUILayout.MinHeight(20)))
                    {
                        _superCombiner.FindMeshesToCombine();
                        //_superCombiner.InitializeMultipleMaterialElements();
                        _superCombiner.CombineMaterials(_superCombiner._meshList, _superCombiner._skinnedMeshList);
                    }
                }
                else if (_superCombiner._combiningState == SuperCombiner.CombineStatesList.CombinedMaterials)
                {
                    GUI.enabled = true;
                    if (GUILayout.Button("Uncombine materials", GUILayout.MinHeight(20)))
                    {
                        _superCombiner.UnCombine();
                    }
                }

                EditorGUILayout.EndVertical();
                GUI.enabled = true;
            }
        }