void UpdateChannelPreview(Info info, int i)
        {
            _infos[i] = info;
            var texture  = info.Texture;
            var channel  = info.Channel;
            var isInvert = info.Invert;

            if (texture != null)
            {
                var conf = new TextureCombinerConfiguration(_previwsSize.x, _previwsSize.y);
                conf.Set(texture, channel, TextureChannel.R, isInvert);
                conf.Set(texture, channel, TextureChannel.G, isInvert);
                conf.Set(texture, channel, TextureChannel.B, isInvert);
                conf.Set(texture, channel, TextureChannel.A, isInvert);

                var previewTexture = TextureCombiner.Create(conf);
                info.Preview = previewTexture;
                _infos[i]    = info;
            }
        }
        void Save()
        {
            string savePath = EditorUtility.SaveFilePanel("Save", Application.dataPath, "texture.png", _formats[_textureFormat].ToLowerInvariant());

            if (savePath != string.Empty)
            {
                var config = new TextureCombinerConfiguration(_resultSize.x, _resultSize.y);
                for (int i = 0; i < _infos.Length; i++)
                {
                    var info = _infos[i];
                    if (info.Enabled && info.Texture != null)
                    {
                        config.Set(info.Texture, info.Channel, (TextureChannel)i, info.Invert);
                    }
                }

                if (!_infos[(int)TextureChannel.A].Enabled)
                {
                    config.Set(Texture2D.whiteTexture, TextureChannel.R, TextureChannel.A, 0);
                }

                Texture2D output = TextureCombiner.Create(config);
                if (_textureFormat == 0)
                {
                    File.WriteAllBytes(savePath, output.EncodeToJPG());
                }
                else if (_textureFormat == 1)
                {
                    File.WriteAllBytes(savePath, output.EncodeToPNG());
                }
                else
                {
                    File.WriteAllBytes(savePath, output.EncodeToEXR());
                }

                AssetDatabase.Refresh();
            }
        }
        void UpdatePreview()
        {
            if (!(_previewChannel == (int)PreviewChannel.RGB || _previewChannel == (int)PreviewChannel.RGBA))
            {
                var config = new TextureCombinerConfiguration(_previwsSize.x, _previwsSize.y);
                var info   = _infos[_previewChannel - 2];
                if (info.Enabled)
                {
                    config.Set(info.Texture, info.Channel, info.Channel, info.Invert);
                }
                _preview = TextureCombiner.Internal.Create(config, true);
            }
            else
            {
                var config = new TextureCombinerConfiguration(_previwsSize.x, _previwsSize.y);
                var count  = _infos.Length - _previewChannel;
                for (int i = 0; i < count; i++)
                {
                    var info = _infos[i];
                    if (info.Enabled && info.Texture != null)
                    {
                        config.Set(info.Texture, info.Channel, (TextureChannel)i, info.Invert);
                    }
                }

                if (_previewChannel == (int)PreviewChannel.RGB || !_infos[(int)TextureChannel.A].Enabled)
                {
                    config.A = new TextureInfo
                    {
                        Channel = TextureChannel.R,
                        Texture = Texture2D.whiteTexture
                    };
                }
                _preview = TextureCombiner.Create(config);
            }
        }