void DrawUnpackUI() { EditorGUI.BeginChangeCheck(); { unpackSource = EditorGUILayout.ObjectField("Packed Texture", unpackSource, typeof(Texture2D), true) as Texture2D; } 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); } } PoiHelpers.DrawLine(); EditorGUI.BeginDisabledGroup(!unpackSource); { unpackedName = EditorGUILayout.TextField("File name", unpackedName); EditorGUILayout.Space(); UnpackSize = PoiHelpers.DrawResolutionPicker(UnpackSize, ref unpackSizeIsLinked, ref unpackSizeAutoSelect, SizePresets, SizePresetNames); PoiHelpers.DrawLine(); if (GUILayout.Button("Unpack")) { var output = UnpackTextureToChannels(unpackSource, UnpackSize); string pingPath = null; try { AssetDatabase.StartAssetEditing(); foreach (var kv in output) { if (string.IsNullOrWhiteSpace(pingPath)) { pingPath = $"{savePath}/Unpacked/{unpackedName}_{kv.Key}.png"; } kv.Value?.SaveTextureAsset($"{savePath}/Unpacked/{unpackedName}_{kv.Key}.png", true); } } catch {} finally { AssetDatabase.StopAssetEditing(); } Debug.Log(log_prefix + "Finished unpacking texture at " + pingPath); PoiHelpers.PingAssetAtPath(pingPath); } } EditorGUI.EndDisabledGroup(); PoiHelpers.DrawLine(); }
void DrawUnpackUI() { _scroll = EditorGUILayout.BeginScrollView(_scroll); { EditorGUI.BeginChangeCheck(); { DrawTextureSelector(PACKED_TEXTURE_LABEL, ref unpackSource, ref unpackChan, ref unpackInvert); } 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); } } DrawShowChannelPicker(ref showChannelPicker); } EditorGUILayout.EndScrollView(); EditorGUI.BeginDisabledGroup(!unpackSource); { UnpackSize = DrawTextureSizeSettings(UnpackSize, ref unpackedName, ref unpackSizeIsLinked, ref unpackSizeAutoSelect); if (GUILayout.Button("Unpack", PoiStyles.BigButton)) { DoUnpack(unpackChan); } } EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); }
void DrawPackUI() { EditorGUI.BeginChangeCheck(); { packRed = EditorGUILayout.ObjectField("Red", packRed, typeof(Texture2D), true) as Texture2D; packGreen = EditorGUILayout.ObjectField("Green", packGreen, typeof(Texture2D), true) as Texture2D; packBlue = EditorGUILayout.ObjectField("Blue", packBlue, typeof(Texture2D), true) as Texture2D; packAlpha = EditorGUILayout.ObjectField("Alpha", packAlpha, typeof(Texture2D), true) as Texture2D; } if (EditorGUI.EndChangeCheck() && packSizeAutoSelect) { // Get biggest texture size from selections and make a selection in our sizes list var tempSize = PoiHelpers.GetMaxSizeFromTextures(packRed, packGreen, packBlue, packAlpha); if (tempSize != default) { PackSize = tempSize.ClosestPowerOfTwo(AUTO_SELECT_CEILING); } } PoiHelpers.DrawLine(); bool disabled = new bool[] { packRed, packGreen, packBlue, packAlpha }.Count(b => b) < 2; EditorGUI.BeginDisabledGroup(disabled); { packedName = EditorGUILayout.TextField("File name", packedName); EditorGUILayout.Space(); PackSize = PoiHelpers.DrawResolutionPicker(PackSize, ref packSizeIsLinked, ref packSizeAutoSelect, SizePresets, SizePresetNames); EditorGUILayout.Space(); PoiHelpers.DrawLine(); if (GUILayout.Button("Pack")) { var packResult = PackTexture(PackSize, packRed, packGreen, packBlue, packAlpha); if (packResult) { string path = $"{savePath}/Packed/{packedName}.png"; packResult.SaveTextureAsset(path, true); Debug.Log(log_prefix + "Finished packing texture at " + path); PoiHelpers.PingAssetAtPath(path); } } } PoiHelpers.DrawLine(); }
void DrawPackUI() { _scroll = EditorGUILayout.BeginScrollView(_scroll); { EditorGUI.BeginChangeCheck(); { DrawTextureSelector(RED_TEXTURE_LABEL, ref packRed, ref redTexChan, ref redInvert); DrawTextureSelector(GREEN_TEXTURE_LABEL, ref packGreen, ref greenTexChan, ref greenInvert); DrawTextureSelector(BLUE_TEXTURE_LABEL, ref packBlue, ref blueTexChan, ref blueInvert); DrawTextureSelector(ALPHA_TEXTURE_LABEL, ref packAlpha, ref alphaTexChan, ref alphaInvert); } if (EditorGUI.EndChangeCheck() && packSizeAutoSelect) { // Get biggest texture size from selections and make a selection in our sizes list var tempSize = PoiHelpers.GetMaxSizeFromTextures(packRed, packGreen, packBlue, packAlpha); if (tempSize != default) { PackSize = tempSize.ClosestPowerOfTwo(AUTO_SELECT_CEILING); } } } EditorGUILayout.EndScrollView(); DrawShowChannelPicker(ref showChannelPicker); bool disabled = new bool[] { packRed, packGreen, packBlue, packAlpha }.Count(b => b) < 2; EditorGUI.BeginDisabledGroup(disabled); { PackSize = DrawTextureSizeSettings(PackSize, ref packedName, ref packSizeIsLinked, ref packSizeAutoSelect); if (GUILayout.Button("Pack", PoiStyles.BigButton)) { DoPack(); } EditorGUILayout.Space(); } EditorGUI.EndDisabledGroup(); }
void DrawPackUI() { EditorGUI.BeginChangeCheck(); { DrawTextureSelector("Red", ref packRed, ref redTexChan); DrawTextureSelector("Green", ref packGreen, ref greenTexChan); DrawTextureSelector("Blue", ref packBlue, ref blueTexChan); DrawTextureSelector("Alpha", ref packAlpha, ref alphaTexChan); } if (EditorGUI.EndChangeCheck() && packSizeAutoSelect) { // Get biggest texture size from selections and make a selection in our sizes list var tempSize = PoiHelpers.GetMaxSizeFromTextures(packRed, packGreen, packBlue, packAlpha); if (tempSize != default) { PackSize = tempSize.ClosestPowerOfTwo(AUTO_SELECT_CEILING); } } EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); showChannelPicker = EditorGUILayout.ToggleLeft("Pick source channel", showChannelPicker); EditorGUILayout.EndHorizontal(); bool disabled = new bool[] { packRed, packGreen, packBlue, packAlpha }.Count(b => b) < 2; EditorGUI.BeginDisabledGroup(disabled); { PackSize = DrawTextureSizeSettings(PackSize, ref packedName, ref packSizeIsLinked, ref packSizeAutoSelect); if (GUILayout.Button("Pack", PoiStyles.BigButton)) { DoPack(); } EditorGUILayout.Space(); } EditorGUI.EndDisabledGroup(); }
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(); }