Search Unity

[FREE] SJAM Texture Composer v2.0.2 Tool

Discussion in 'Assets and Asset Store' started by SJAM, Oct 24, 2022.

  1. SJAM

    SJAM

    Joined:
    Jan 11, 2009
    Posts:
    729
    1TextureComposer201.jpg

    2TextureComposer201.jpg


    Update 2.0.2 :
    - [Optimisation] Fixed the code that encoded 2 times (Before : TGA + your choice), now the encoding is done only in the requested format.
    - [Maintenance] Cleaning up the code (Removing the rest of the unnecessary code from version 1)
    - [New] Standardized interface with the Pro version.



    What is SJAM Texture Composer ?



    SJAM Texture Composer is an Unity Editor tool and the best friend of those who don't have time to leave Unity to compose or modify a texture for their shaders, so you can :

    - Choose what source texture and its channel for each channels of the Generated Texture.
    - Compose or modify a MaskMap Texture with what you want and on channel you want.
    - Compose a Matellic Texture with its Smoothness on Alpha Channel.
    - Add a Transparency/Specular/Smoothness layer on the Alpha channel of the Albedo texture.
    - And every things you want, because you can get out the generated texture to using out of Unity due to export format (TGA,EXR,PNG,JPG).
    - And I'm sure you will find others stuffs to do with it.


    On top of that, for each channel of generated texture, you have several choices:

    - Choose the Red channel of the source texture
    - Choose the Green channel of the source texture
    - Choose the Blue channel of the source texture
    - Choose the Alpha channel of the source texture
    - Choose and invert the Red channel of the source texture
    - Choose and invert the Green channel of the source texture
    - Choose and invert the Blue channel of the source texture
    - Choose and invert the Alpha channel of the source texture
    - Fill a channel with the value White Value
    - Fill a channel with the value Black Value


    Key features :

    - [New] A new, clearer and easy to use interface (v2).
    - [New] Much faster for processing the generated texture (v2).
    - [New] No longer change the Read/Write state of the original texture (v2).
    - [New] More Possibilities (v2).
    - Increase your workflow.
    - Generate Textures with multiples sources.
    - You can use textures of different sizes, the composer will resize during processing in
    order to always have a flawless generated texture.
    - HDR Textures Compatible (Not with invert option).
    - Export in 4 classic formats (TGA,EXR,PNG,JPG).

    ENJOY !

    - Download the 2 Attached Files or Copy/paste the code below
    - Put this 2 scripts in an "Editor" Folder.
    Find the tool in Menu bar -> Tools -> SJam Texture Composer 2.0.2
    upload_2022-10-24_16-36-45.png


    After the process the generated file will be in this folder : Assets/SJamTextureComposer/YourFile


    SJamAPI.cs

    Code (CSharp):
    1. using System.Collections.Generic;
    2. using System.IO;
    3. using System.Threading.Tasks;
    4. using UnityEditor;
    5. using UnityEngine;
    6.  
    7. namespace SJAM.API
    8. {
    9.     public enum ExportFormat
    10.     {
    11.         TGA,
    12.         EXR,
    13.         PNG,
    14.         JPG
    15.     }
    16.     public enum GetFullChannel
    17.     {
    18.         Red,
    19.         Green,
    20.         Blue,
    21.         Alpha,
    22.         [InspectorName("1 - Red")]
    23.         _1R,
    24.         [InspectorName("1 - Green")]
    25.         _1G,
    26.         [InspectorName("1 - Blue")]
    27.         _1B,
    28.         [InspectorName("1 - Alpha")]
    29.         _1A,
    30.         [InspectorName("1")]
    31.         _1,
    32.         [InspectorName("0")]
    33.         _0
    34.     }
    35.     public enum OutSize
    36.     {
    37.         _32x32,
    38.         _64x64,
    39.         _128x128,
    40.         _256x256,
    41.         _512x512,
    42.         _1024x1024,
    43.         _2048x2048,
    44.         _4096x4096,
    45.         _8192x8192,
    46.         _16384x16384
    47.     }
    48.  
    49.     public static class SJamExtensions
    50.     {
    51.         static public Texture2D[] ChannelsSource = new Texture2D[4];
    52.         static public Texture2D[] oldChannelsSource = new Texture2D[4];
    53.         static public GetFullChannel[] Channels = { GetFullChannel.Red, GetFullChannel.Red, GetFullChannel.Red, GetFullChannel.Red};
    54.         static public bool[] SourceHasAlpha = new bool[4];
    55.         static public Color[] SourceColors = { Color.red, Color.green, Color.blue, Color.white};
    56.         static public ExportFormat OutExport = ExportFormat.TGA;
    57.         static public OutSize Size = OutSize._1024x1024;
    58.         static public Texture2D.EXRFlags ExrOutput = Texture2D.EXRFlags.None;
    59.         static public int JpgCompressionQuality = 100;
    60.         static public string FileName = "NewTexture";
    61.         static public bool sRGB = true;
    62.         static public int outSize;
    63.         static public float[][] colors = new float[4][];
    64.         static public List<string> PathtoDelete = new List<string>();
    65.         static public string SJTCPath = "Assets/SJamTextureComposer/";
    66.         static public string ExclusionFile;
    67.  
    68.         static public void TextureImporterSettings(string path, bool sRGB, ExportFormat format = ExportFormat.TGA)
    69.         {
    70.             TextureImporter TextureI = AssetImporter.GetAtPath(path) as TextureImporter;
    71.             if (!sRGB)
    72.             {
    73.                 TextureI.sRGBTexture = false;
    74.             }
    75.             if(format == ExportFormat.EXR)
    76.             {
    77.                 TextureI.textureCompression = TextureImporterCompression.Uncompressed;
    78.             }
    79.             else
    80.             {
    81.                 TextureI.textureCompression = TextureImporterCompression.CompressedHQ;
    82.             }
    83.  
    84.             TextureI.maxTextureSize = outSize;
    85.  
    86.             RefreshSpecificAssetDataBase(path);
    87.         }
    88.  
    89.         static public async Task SaveTexture()
    90.         {
    91.             string[] decompose = Size.ToString().Split('x');
    92.             outSize = int.Parse(decompose[decompose.Length - 1]);
    93.  
    94.             for (int i = 0; i < 4; i++)
    95.             {
    96.                 colors[i] = ChannelsSource[i].GetChannel((int)Channels[i]);
    97.             }
    98.  
    99.             SaveTextureProcess();
    100.  
    101.             await Task.Yield();
    102.         }
    103.  
    104.         static public void SaveTextureProcess()
    105.         {
    106.             foreach (var item in PathtoDelete)
    107.             {
    108.                 if (File.Exists(item) && item != ExclusionFile)
    109.                 {
    110.                     AssetDatabase.DeleteAsset(item);
    111.                 }
    112.             }
    113.             PathtoDelete.Clear();
    114.  
    115.  
    116.             TextureFormat tf = TextureFormat.ARGB32;
    117.             if(OutExport == ExportFormat.EXR)
    118.             {
    119.                 if(ExrOutput == Texture2D.EXRFlags.OutputAsFloat)
    120.                 {
    121.                     tf = TextureFormat.RGBAFloat;
    122.                 }
    123.                 else
    124.                 {
    125.                     tf = TextureFormat.RGBAHalf;
    126.                 }
    127.             }
    128.             Color[] Tex = new Color[outSize * outSize];
    129.  
    130.             for (int i = 0; i < Tex.Length; i++)
    131.             {
    132.                 Tex[i] = OutExport == ExportFormat.JPG ? new Color(colors[0][i], colors[1][i], colors[2][i]) : new Color(colors[0][i], colors[1][i], colors[2][i], colors[3][i]);
    133.             }
    134.  
    135.             Texture2D outputTexture = new Texture2D(outSize, outSize, tf, false);
    136.             outputTexture.SetPixels(Tex);
    137.  
    138.             EncodeTexture(outputTexture, FileName, JpgCompressionQuality, ExrOutput, sRGB, OutExport);
    139.         }
    140.  
    141.         static public float[] GetChannel(this Texture2D texture, int channelNum)
    142.         {
    143.             Texture2D temp = null;
    144.             bool needToBeResize = false;
    145.             GetFullChannel channel = GetFullChannel.Red;
    146.  
    147.             if (texture != null && channelNum <= 9)
    148.             {
    149.                 channel = (GetFullChannel)channelNum;
    150.                 string tempPath = texture.CopyTextureOnTempTexture(outSize);
    151.                 PathtoDelete.Add(tempPath);
    152.                 temp = (Texture2D)AssetDatabase.LoadAssetAtPath(tempPath, typeof(Texture2D));
    153.                 needToBeResize = (temp.width != outSize || temp.height != outSize);
    154.             }
    155.             else if (texture != null && channelNum > 9)
    156.             {
    157.                 temp = texture;
    158.                 needToBeResize = (temp.width != outSize || temp.height != outSize);
    159.             }
    160.             else if (texture == null)
    161.             {
    162.                 channel = (GetFullChannel)channelNum;
    163.             }
    164.  
    165.             float[] Tex = new float[outSize * outSize];
    166.  
    167.             for (int i = 0; i < outSize; i++)
    168.             {
    169.                 for (int j = 0; j < outSize; j++)
    170.                 {
    171.                     int idx = j * (int)outSize + i;
    172.  
    173.                     if (temp != null)
    174.                     {
    175.                         float f = 0;
    176.                                            
    177.                         switch (channel)
    178.                         {
    179.                             case GetFullChannel.Red:
    180.                                 f = needToBeResize ? temp.GetPixelBilinear(((float)i) / outSize, ((float)j) / outSize).r : temp.GetPixel(i, j).r;
    181.                                 break;
    182.                             case GetFullChannel.Green:
    183.                                 f = needToBeResize ? temp.GetPixelBilinear(((float)i) / outSize, ((float)j) / outSize).g : temp.GetPixel(i, j).g;
    184.                                 break;
    185.                             case GetFullChannel.Blue:
    186.                                 f = needToBeResize ? temp.GetPixelBilinear(((float)i) / outSize, ((float)j) / outSize).b : temp.GetPixel(i, j).b;
    187.                                 break;
    188.                             case GetFullChannel.Alpha:
    189.                                 f = needToBeResize ? temp.GetPixelBilinear(((float)i) / outSize, ((float)j) / outSize).a : temp.GetPixel(i, j).a;
    190.                                 break;
    191.                             case GetFullChannel._1R:
    192.                                 f = 1 - (needToBeResize ? temp.GetPixelBilinear(((float)i) / outSize, ((float)j) / outSize).r : temp.GetPixel(i, j).r);
    193.                                 break;
    194.                             case GetFullChannel._1G:
    195.                                 f = 1 - (needToBeResize ? temp.GetPixelBilinear(((float)i) / outSize, ((float)j) / outSize).g : temp.GetPixel(i, j).g);
    196.                                 break;
    197.                             case GetFullChannel._1B:
    198.                                 f = 1 - (needToBeResize ? temp.GetPixelBilinear(((float)i) / outSize, ((float)j) / outSize).b : temp.GetPixel(i, j).b);
    199.                                 break;
    200.                             case GetFullChannel._1A:
    201.                                 f = 1 - (needToBeResize ? temp.GetPixelBilinear(((float)i) / outSize, ((float)j) / outSize).a : temp.GetPixel(i, j).a);
    202.                                 break;
    203.                             default:
    204.                                 f = (needToBeResize ? temp.GetPixelBilinear(((float)i) / outSize, ((float)j) / outSize).r : temp.GetPixel(i, j).r);
    205.                                 break;
    206.                         }
    207.                         Tex[idx] = f;
    208.                     }
    209.                     else
    210.                     {
    211.                         Tex[idx] = channel == GetFullChannel._1 ? 1 : 0;
    212.                     }
    213.                 }
    214.             }
    215.             return Tex;
    216.         }
    217.  
    218.         public static void EncodeTexture(Texture2D tex, string FileName, int JPGQuality, Texture2D.EXRFlags ExrFormat, bool sRGB, ExportFormat format = ExportFormat.TGA)
    219.         {
    220.             byte[] bytes = null;
    221.             switch (format)
    222.             {
    223.                 case ExportFormat.EXR:
    224.                     bytes = tex.EncodeToEXR(ExrFormat);
    225.                     break;
    226.                 case ExportFormat.PNG:
    227.                     bytes = tex.EncodeToPNG();
    228.                     break;
    229.                 case ExportFormat.JPG:
    230.                     bytes = tex.EncodeToJPG(JPGQuality);
    231.                     break;
    232.                 case ExportFormat.TGA:
    233.                     bytes = tex.EncodeToTGA();
    234.                     break;
    235.             }
    236.  
    237.  
    238.             if (!Directory.Exists(SJTCPath))
    239.             {
    240.                 Directory.CreateDirectory(SJTCPath);
    241.                 AssetDatabase.Refresh();
    242.             }
    243.  
    244.             string PathWithNameAndExtension = CheckFileExist(SJTCPath + FileName + "_SJTC", format.ToString().ToLower());
    245.             File.WriteAllBytes(PathWithNameAndExtension, bytes);
    246.             RefreshSpecificAssetDataBase(PathWithNameAndExtension);
    247.             TextureImporterSettings(PathWithNameAndExtension, sRGB, format);
    248.         }
    249.  
    250.         static void RefreshSpecificAssetDataBase(string path)
    251.         {
    252.             AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
    253.             AssetDatabase.Refresh();
    254.         }
    255.  
    256.         static string CheckFileExist(string PathWithName, string Extension, bool AddExtension = true)
    257.         {
    258.             string Final;
    259.             string numTxt = "";
    260.             int num = 0;
    261.             bool ExportNameSuccess = false;
    262.             do
    263.             {
    264.                 Final = PathWithName + numTxt;
    265.                 if (!File.Exists(Final + "." + Extension))
    266.                 {
    267.                     if (AddExtension)
    268.                     {
    269.                         Final = Final + "." + Extension;
    270.                     }
    271.                     ExportNameSuccess = true;
    272.                 }
    273.                 else
    274.                 {
    275.                     numTxt = num.ToString();
    276.                     num++;
    277.                 }
    278.             } while (!ExportNameSuccess);
    279.  
    280.             return Final;
    281.         }
    282.  
    283.         static public string GetPath(this Texture2D srcTex)
    284.         {
    285.             return AssetDatabase.GetAssetPath(srcTex);
    286.         }
    287.    
    288.         public static bool HasAlphaChannel(this Texture2D Tex)
    289.         {
    290.             string path = Tex.GetPath();
    291.             TextureImporter TextureI = AssetImporter.GetAtPath(path) as TextureImporter;
    292.             return TextureI.DoesSourceTextureHaveAlpha();
    293.         }
    294.  
    295.         static public string CopyTextureOnTempTexture(this Texture2D texture, int size)
    296.         {
    297.             string srcTexturePath = texture.GetPath();
    298.             string tempFolder = SJTCPath + "Temp/";
    299.             if (!Directory.Exists(tempFolder))
    300.             {
    301.                 Directory.CreateDirectory(tempFolder);
    302.                 AssetDatabase.Refresh();
    303.             }
    304.             string destTempFolderName = tempFolder + Path.GetFileName(srcTexturePath);
    305.  
    306.             if (!File.Exists(destTempFolderName))
    307.             {
    308.                 File.Copy(srcTexturePath, destTempFolderName);
    309.                 AssetDatabase.Refresh();
    310.                 TextureImporter textureImporter = AssetImporter.GetAtPath(destTempFolderName) as TextureImporter;
    311.                 textureImporter.maxTextureSize = size;
    312.                 textureImporter.isReadable = true;
    313.                 textureImporter.mipmapEnabled = false;
    314.                 textureImporter.filterMode = FilterMode.Point;
    315.                 textureImporter.alphaSource = TextureImporterAlphaSource.FromInput;
    316.                 textureImporter.npotScale = TextureImporterNPOTScale.None;
    317.                 textureImporter.textureCompression = TextureImporterCompression.Uncompressed;
    318.                 textureImporter.SaveAndReimport();
    319.             }
    320.             return destTempFolderName;
    321.         }
    322.     }
    323. }
    SJamTextureComposerV2.cs
    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3. using SJAM.API;
    4.  
    5. public class SJamTextureComposerV2 : EditorWindow
    6. {
    7.     [MenuItem("Tools/SJAM Texture Composer 2.0.2")]
    8.     static void Initialize()
    9.     {
    10.         SJamTextureComposerV2 window = (SJamTextureComposerV2)EditorWindow.GetWindowWithRect(typeof(SJamTextureComposerV2), new Rect(0, 0, 500, 400), false, "SJAM Texture Composer 2");
    11.         window.Show();
    12.     }
    13.  
    14.     void OnInspectorUpdate()
    15.     {
    16.         Repaint();
    17.     }
    18.     void OnDestroy()
    19.     {
    20.         SJamExtensions.ChannelsSource = new Texture2D[4];
    21.         CheckChange();
    22.     }
    23.  
    24.     void CheckChange()
    25.     {
    26.         for (int i = 0; i < 4; i++)
    27.         {
    28.             if (SJamExtensions.oldChannelsSource[i] != SJamExtensions.ChannelsSource[i])
    29.             {
    30.                 SJamExtensions.oldChannelsSource[i] = SJamExtensions.ChannelsSource[i];
    31.                 if (SJamExtensions.ChannelsSource[i] != null)
    32.                 {
    33.                     SJamExtensions.SourceHasAlpha[i] = SJamExtensions.ChannelsSource[i].HasAlphaChannel();
    34.                 }
    35.             }
    36.         }
    37.     }
    38.  
    39.     void OnGUI()
    40.     {
    41.         GUILayout.Space(15);
    42.         GUILayout.BeginHorizontal();
    43.         GUILayout.FlexibleSpace();
    44.         Color col = GUI.color;
    45.         GUI.color = new Color(0.7843137F, 0.5843138F, 0.1411764F);
    46.         GUILayout.Label("SJAM", EditorStyles.boldLabel, GUILayout.Height(25));
    47.         GUI.color = col;
    48.         GUILayout.Label("Texture Composer v2.0.2", EditorStyles.boldLabel, GUILayout.Height(25));
    49.         GUILayout.FlexibleSpace();
    50.         GUILayout.EndHorizontal();
    51.  
    52.         CheckChange();
    53.         GUILayout.Space(15);
    54.         SourcesTexturesManager();
    55.     }
    56.  
    57.     void SourcesTexturesManager()
    58.     {
    59.         GUILayout.BeginVertical("HelpBox");
    60.         GUILayout.BeginHorizontal();
    61.         Color bg = GUI.backgroundColor;
    62.         for (int i = 0; i < 4; i++)
    63.         {
    64.             bool DontUseTexture = (int)SJamExtensions.Channels[i] > 7 ? true : false;
    65.             bool jpgExport = SJamExtensions.OutExport == ExportFormat.JPG && i == 3;
    66.  
    67.             EditorGUI.BeginDisabledGroup(jpgExport);
    68.             GUI.backgroundColor = Color.black;
    69.             GUILayout.BeginVertical("HelpBox");
    70.             GUI.backgroundColor = bg;
    71.             GUILayout.BeginHorizontal(GUILayout.Width(100));
    72.             GUILayout.FlexibleSpace();
    73.             GUI.backgroundColor = SJamExtensions.SourceColors[i];
    74.             GUILayout.Button("", GUILayout.Width(15), GUILayout.Height(15));
    75.             GUI.backgroundColor = Color.white;
    76.             GUILayout.Label((GetFullChannel)i + "");
    77.             GUILayout.FlexibleSpace();
    78.             GUILayout.EndHorizontal();
    79.  
    80.  
    81.             if ((DontUseTexture || jpgExport) && SJamExtensions.ChannelsSource[i] != null)
    82.             {
    83.                 SJamExtensions.ChannelsSource[i] = null;
    84.             }
    85.             EditorGUI.BeginDisabledGroup(DontUseTexture);
    86.             SJamExtensions.ChannelsSource[i] = (Texture2D)EditorGUILayout.ObjectField(SJamExtensions.ChannelsSource[i], typeof(Texture2D), false, GUILayout.Width(100), GUILayout.Height(100));
    87.             EditorGUI.EndDisabledGroup();
    88.  
    89.  
    90.             GUILayout.BeginHorizontal(GUILayout.Width(100));
    91.             GUILayout.FlexibleSpace();
    92.             GUILayout.Label("Source");
    93.             GUILayout.FlexibleSpace();
    94.             GUILayout.EndHorizontal();
    95.  
    96.             SJamExtensions.Channels[i] = (GetFullChannel)EditorGUILayout.EnumPopup(SJamExtensions.Channels[i], GUILayout.Width(100));
    97.  
    98.             if (SJamExtensions.SourceHasAlpha[i] == false && (SJamExtensions.Channels[i] == GetFullChannel.Alpha || SJamExtensions.Channels[i] == GetFullChannel._1A))
    99.             {
    100.                 SJamExtensions.Channels[i] = GetFullChannel.Red;
    101.             }
    102.  
    103.             if (SJamExtensions.ChannelsSource[i] != null)
    104.             {
    105.                 GUILayout.BeginHorizontal(GUILayout.Width(95));
    106.                 GUILayout.FlexibleSpace();
    107.                 GUILayout.Label(SJamExtensions.ChannelsSource[i].width + " x " + SJamExtensions.ChannelsSource[i].height, EditorStyles.miniLabel);
    108.                 GUILayout.FlexibleSpace();
    109.                 GUILayout.EndHorizontal();
    110.                 GUILayout.BeginHorizontal(GUILayout.Width(95));
    111.                 GUILayout.FlexibleSpace();
    112.                 GUILayout.Label("(" + (SJamExtensions.SourceHasAlpha[i] ? "Alpha Channel)" : "No Alpha)"), EditorStyles.miniLabel);
    113.                 GUILayout.FlexibleSpace();
    114.                 GUILayout.EndHorizontal();
    115.             }
    116.             GUILayout.EndVertical();
    117.             EditorGUI.EndDisabledGroup();
    118.             if (i < 3)
    119.             {
    120.                 GUILayout.FlexibleSpace();
    121.             }
    122.  
    123.         }
    124.         GUILayout.EndHorizontal();
    125.  
    126.         GUILayout.Space(10);
    127.  
    128.         GUILayout.BeginHorizontal();
    129.         SJamExtensions.Size = (OutSize)EditorGUILayout.EnumPopup(SJamExtensions.Size, GUILayout.Width(120));
    130.         GUILayout.FlexibleSpace();
    131.         GUILayout.Label("sRGB");
    132.         SJamExtensions.sRGB = EditorGUILayout.Toggle(SJamExtensions.sRGB, GUILayout.Width(15));
    133.         GUILayout.EndHorizontal();
    134.  
    135.         GUILayout.Space(5);
    136.  
    137.         GUILayout.BeginHorizontal();
    138.         SJamExtensions.FileName = GUILayout.TextField(SJamExtensions.FileName, GUILayout.Width(180));
    139.         GUILayout.Label("_SJTC" + ".");
    140.         SJamExtensions.OutExport = (ExportFormat)EditorGUILayout.EnumPopup(SJamExtensions.OutExport, GUILayout.Width(50));
    141.         GUILayout.FlexibleSpace();
    142.         if (SJamExtensions.OutExport == ExportFormat.EXR)
    143.         {
    144.             SJamExtensions.ExrOutput = (Texture2D.EXRFlags)EditorGUILayout.EnumPopup(SJamExtensions.ExrOutput, GUILayout.Width(200));
    145.         }
    146.         else if (SJamExtensions.OutExport == ExportFormat.JPG)
    147.         {
    148.             SJamExtensions.JpgCompressionQuality = (int)GUILayout.HorizontalSlider(SJamExtensions.JpgCompressionQuality, 0, 100, GUILayout.Width(170));
    149.             GUILayout.Label("" + SJamExtensions.JpgCompressionQuality, GUILayout.Width(30));
    150.         }
    151.         GUILayout.EndHorizontal();
    152.         GUILayout.BeginHorizontal();
    153.         if (SJamExtensions.OutExport == ExportFormat.JPG)
    154.         {
    155.             GUILayout.BeginHorizontal();
    156.             GUILayout.FlexibleSpace();
    157.             GUILayout.Label((SJamExtensions.JpgCompressionQuality < 30 ? "Low Quality" : SJamExtensions.JpgCompressionQuality >= 30 && SJamExtensions.JpgCompressionQuality < 60 ? "Middle Quality" : SJamExtensions.JpgCompressionQuality >= 60 && SJamExtensions.JpgCompressionQuality < 80 ? "High Quality" : "Very High Quality"), EditorStyles.miniBoldLabel);
    158.             GUILayout.EndHorizontal();
    159.         }
    160.         else if (SJamExtensions.OutExport == ExportFormat.EXR)
    161.         {
    162.             string tex = "";
    163.             switch (SJamExtensions.ExrOutput)
    164.             {
    165.                 case Texture2D.EXRFlags.None:
    166.                     tex = "Uncompressed 16-bit float EXR file";
    167.                     break;
    168.                 case Texture2D.EXRFlags.OutputAsFloat:
    169.                     tex = "Uncompressed 32-bit float EXR file (default is 16-bit)";
    170.                     break;
    171.                 case Texture2D.EXRFlags.CompressZIP:
    172.                     tex = "The texture will use the EXR ZIP compression format";
    173.                     break;
    174.                 case Texture2D.EXRFlags.CompressRLE:
    175.                     tex = "The texture will use RLE (similar to Targa RLE compression)";
    176.                     break;
    177.                 case Texture2D.EXRFlags.CompressPIZ:
    178.                     tex = "This is best used for grainy images (Wavelet compression)";
    179.                     break;
    180.             }
    181.             GUILayout.BeginHorizontal();
    182.             GUILayout.FlexibleSpace();
    183.             GUILayout.Label(tex, EditorStyles.miniBoldLabel);
    184.             GUILayout.EndHorizontal();
    185.         }
    186.         else
    187.         {
    188.             GUILayout.Label("No Format Option", EditorStyles.miniBoldLabel);
    189.         }
    190.  
    191.         GUILayout.EndHorizontal();
    192.  
    193.         GUILayout.EndVertical();
    194.         GUILayout.FlexibleSpace();
    195.  
    196.         GUILayout.BeginHorizontal();
    197.         GUILayout.FlexibleSpace();
    198.    
    199.         if (GUILayout.Button("Export Texture", GUILayout.Width(120), GUILayout.Height(30)))
    200.         {
    201.             _ = SJamExtensions.SaveTexture();
    202.         }
    203.         GUILayout.FlexibleSpace();
    204.         GUILayout.EndHorizontal();
    205.  
    206.         GUILayout.FlexibleSpace();
    207.     }
    208. }
     

    Attached Files:

    Last edited: Nov 17, 2022
    Mauri, Ryiah, Stardog and 1 other person like this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    You should toss these up on github to share them... that way:

    a) nobody has to futz around with drag-copy-paste-drag-error stuff in the code windows above
    b) you can trivially keep them up to date without having to hunt down stray forum posts
    c) people can make modifications and submit them for your consideration!

    I share a ton of my stuff via repo and also via gist:

    https://github.com/kurtdekker

    https://gist.github.com/kurtdekker
     
  3. SJAM

    SJAM

    Joined:
    Jan 11, 2009
    Posts:
    729
    Good idea,

    I'll take a look at it when I have time ;)
     
    OCASM likes this.
  4. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    It doesn't do anything when clicking Generate.
     
  5. SJAM

    SJAM

    Joined:
    Jan 11, 2009
    Posts:
    729
    Hi,
    Weird, all the classes I used are compatible with all versions of Unity
    Can you tell me which version of unity you are using?
     
    Last edited: Oct 28, 2022
  6. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,203
    Just be sure to drop an appropriate license into the root folder of any assets you want to share in this manner as by default without a license file any asset uploaded to github is automaticlally under a license that limits the use of the asset to the owner of it.

    https://docs.github.com/en/reposito...mizing-your-repository/licensing-a-repository
     
    SJAM likes this.
  7. SJAM

    SJAM

    Joined:
    Jan 11, 2009
    Posts:
    729
    Thanks for the advice, I use Git, but not for my projects, that's good to know ;)
     
  8. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,006
    Don't you think this post belongs to the "Assets and Asset Store" subforum?
    (index/general)

    The scripting forum is a support forum for issues with scripting. Maybe a moderator could move it? @MelvMay ? (You're the only mod that come to my mind who's actually moving threads regularly :) )
     
  9. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    I don’t think it needs moving. Melv is the only worker. The other dude was mean all the time. All the time. And he was like a really bad google translate. I won’t name drop.

    tool looks good but I am not sure how licensing will work by just specifying a text file disclaimer. Nor if you’d have the team available to pursue breach of usage aka will you realistically be paying a team of people to fine comb all published softwares and games looking for evidence of stealing code? Likelihood is of course no.
     
  10. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,006
    You read the title, right? It says
    [Free]
    . So currently it doesn't look he's trying to make money with this tool. Officially selling assets means you have way more responsibilities
     
  11. SJAM

    SJAM

    Joined:
    Jan 11, 2009
    Posts:
    729
    Nothing to fear...
    Basically, I made this tool for me,to increase my workflow. Like many others.
    All the code is done by me and I offer the script for free and free to use.
    Of course, I wouldn't like anyone to sell it when it's free, but I chose to offer the sources, so enjoy!
    You can modify the source freely, because free of rights.
     
    Last edited: Nov 17, 2022
    Bunny83 likes this.
  12. SJAM

    SJAM

    Joined:
    Jan 11, 2009
    Posts:
    729
    Minor Update of Free Version :

    Update 2.0.2 :
    - [Optimisation] Fixed the code that encoded 2 times (Before : TGA + your choice), now the encoding is done only in the requested format.
    - [Maintenance] Cleaning up the code (Removing the rest of the unnecessary code from version 1)
    - [New] Standardized interface with the Pro version.

    Enjoy !
     
    Last edited: Nov 17, 2022
  13. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    2022.1.16f1
     
  14. SJAM

    SJAM

    Joined:
    Jan 11, 2009
    Posts:
    729
    I haven’t any issue on this version and others of unity

    Make sure that you create a folder with this path and put 2 files on it : Assets/Editor/

    And keep same name of files…
     
    Last edited: Jan 15, 2023