예제 #1
0
        void DoUnpack(TextureChannel singleChannel = TextureChannel.RGBA)
        {
            if (!PackerShadersExist)
            {
                return;
            }

            var channelTextures = new Dictionary <string, Texture2D>();

            if (singleChannel == TextureChannel.RGBA)
            {
                channelTextures = PoiHelpers.UnpackTextureToChannels(unpackSource, unpackInvert, UnpackSize);
            }
            else
            {
                channelTextures[singleChannel.ToString().ToLower()] = unpackSource.GetChannelAsTexture(singleChannel, unpackInvert, UnpackSize);
            }


            string pingPath = null;

            pingPath = SaveTextures(channelTextures, pingPath);

            Debug.Log(LOG_PREFIX + "Finished unpacking texture at " + pingPath);
            PoiHelpers.PingAssetAtPath(pingPath);
        }
예제 #2
0
        void DrawUnpackUI()
        {
            EditorGUI.BeginChangeCheck();
            {
                DrawTextureSelector("Packed Texture", ref unpackSource);
            }
            if (EditorGUI.EndChangeCheck() && unpackSizeAutoSelect)
            {
                // Get biggest texture size from selections and make a selection in our sizes list
                var tempSize = PoiHelpers.GetMaxSizeFromTextures(unpackSource);
                if (tempSize != default)
                {
                    UnpackSize = tempSize.ClosestPowerOfTwo(AUTO_SELECT_CEILING);
                }
            }

            EditorGUI.BeginDisabledGroup(!unpackSource);
            {
                UnpackSize = DrawTextureSizeSettings(UnpackSize, ref unpackedName, ref unpackSizeIsLinked, ref unpackSizeAutoSelect);

                if (GUILayout.Button("Unpack", PoiStyles.BigButton))
                {
                    if (PackerShadersExist)
                    {
                        var    channelTextures = PoiHelpers.UnpackTextureToChannels(unpackSource, UnpackSize);
                        string pingPath        = null;
                        pingPath = SaveTextures(channelTextures, pingPath);

                        Debug.Log(LOG_PREFIX + "Finished unpacking texture at " + pingPath);
                        PoiHelpers.PingAssetAtPath(pingPath);
                    }
                }
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();
        }