Initial Commit

This commit is contained in:
jellejurre
2025-07-19 01:03:02 +02:00
commit e7904e3140
304 changed files with 22521 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 46d12e0502ed1de4fa489dfa786aa027
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,163 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace DreadScripts.TextureUtility
{
[System.Serializable]
public class ChannelTexture
{
public string name;
public Texture2D texture;
public bool invert;
public Color defaultColor;
public ColorMode mode = ColorMode.Red;
public enum ColorMode
{
Red,
Green,
Blue,
Alpha
}
public ChannelTexture(string n, int mode)
{
name = n;
SetMode(mode, true);
if (n == "Alpha")
defaultColor = Color.white;
}
public void SetMode(int i, bool ignoreSave = false)
{
switch (i)
{
case 0:
mode = ColorMode.Red;
break;
case 1:
mode = ColorMode.Green;
break;
case 2:
mode = ColorMode.Blue;
break;
case 3:
mode = ColorMode.Alpha;
break;
}
if (!ignoreSave)
{
EditorPrefs.SetInt("TextureUtilityChannel" + name, i);
}
}
public Texture2D GetChannelColors(int width, int height, out float[] colors, bool unloadTempTexture)
{
Texture2D textureToUse;
if (texture)
textureToUse = texture;
else
{
textureToUse = new Texture2D(1, 1, TextureFormat.RGBA32, false, true);
textureToUse.SetPixel(0, 0, defaultColor);
textureToUse.Apply();
}
Texture2D newTexture = TextureUtility.GetColors(textureToUse, width, height, out Color[] myColors, unloadTempTexture);
colors = myColors.Select(c =>
{
switch (mode)
{
case ColorMode.Red:
return c.r;
case ColorMode.Green:
return c.g;
case ColorMode.Blue:
return c.b;
default:
return c.a;
}
}).ToArray();
if (invert)
{
for (int i = 0; i < colors.Length; i++)
{
colors[i] = 1 - colors[i];
}
}
if (!texture && unloadTempTexture)
Object.DestroyImmediate(textureToUse);
return newTexture;
}
public void DrawGUI()
{
GUIStyle buttonGroupStyle = new GUIStyle(GUI.skin.GetStyle("toolbarbutton")) {padding = new RectOffset(1, 1, 1, 1), margin = new RectOffset(0, 0, 1, 1)};
using (new GUILayout.VerticalScope("box"))
{
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
GUILayout.Label(name, "boldlabel");
GUILayout.FlexibleSpace();
}
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
bool dummy;
EditorGUI.BeginChangeCheck();
dummy = GUILayout.Toggle(mode == ColorMode.Red, "R", buttonGroupStyle, GUILayout.Width(16));
if (EditorGUI.EndChangeCheck())
if (dummy)
SetMode(0);
EditorGUI.BeginChangeCheck();
dummy = GUILayout.Toggle(mode == ColorMode.Green, "G", buttonGroupStyle, GUILayout.Width(16));
if (EditorGUI.EndChangeCheck())
if (dummy)
SetMode(1);
EditorGUI.BeginChangeCheck();
dummy = GUILayout.Toggle(mode == ColorMode.Blue, "B", buttonGroupStyle, GUILayout.Width(16));
if (EditorGUI.EndChangeCheck())
if (dummy)
SetMode(2);
EditorGUI.BeginChangeCheck();
dummy = GUILayout.Toggle(mode == ColorMode.Alpha, "A", buttonGroupStyle, GUILayout.Width(16));
if (EditorGUI.EndChangeCheck())
if (dummy)
SetMode(3);
GUILayout.FlexibleSpace();
}
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
Rect myTextureRect = GUILayoutUtility.GetRect(66, 66);
Rect myColorRect = new Rect(myTextureRect) {x = myTextureRect.x + 1, y = myTextureRect.y + 45, width = 20, height = 20};
if (!texture)
defaultColor = EditorGUI.ColorField(myColorRect, GUIContent.none, defaultColor, false, false, false);
texture = (Texture2D) EditorGUI.ObjectField(myTextureRect, texture, typeof(Texture2D), false);
if (!texture)
defaultColor = EditorGUI.ColorField(myColorRect, GUIContent.none, defaultColor, false, false, false);
GUILayout.FlexibleSpace();
}
invert = GUILayout.Toggle(invert, "Invert", "toolbarbutton");
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 50ad0f4ea47ebb449b51d9cf0321eee8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,373 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace DreadScripts.TextureUtility
{
public class TextureAutoPackerWindow : EditorWindow
{
private static TextureAutoPackerData data;
private static SerializedObject serializedObject;
private static SerializedProperty _active;
private static SerializedProperty _activeModules;
private static UnityEditorInternal.ReorderableList modulesList;
private static Texture2D titleTexture;
[MenuItem("DreadTools/Utility/Texture Auto-Packer")]
public static void ShowWindow()
{
EditorWindow w = GetWindow<TextureAutoPackerWindow>(false, "Texture Auto-Packer", true);
if (!titleTexture)
{
titleTexture = TextureUtility.GetColors((Texture2D)EditorGUIUtility.IconContent("Texture2D Icon").image, 16, 16, out _);
titleTexture.Apply();
}
w.titleContent.image = titleTexture;
}
private void OnEnable()
{
data = TextureAutoPackerData.GetInstance();
serializedObject = new SerializedObject(data);
_active = serializedObject.FindProperty("active");
_activeModules = serializedObject.FindProperty("activeModules");
modulesList = new UnityEditorInternal.ReorderableList(serializedObject, _activeModules, true, true, true, false)
{
drawElementCallback = DrawElement,
drawHeaderCallback = DrawHeader
};
}
private void DrawHeader(Rect rect)
{
EditorGUI.LabelField(rect, "Active Modules");
}
private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
{
if (!(index < _activeModules.arraySize && index >= 0))
return;
rect.y += 2;
rect.height = EditorGUIUtility.singleLineHeight;
if (GUI.Button(new Rect(rect.x, rect.y, 20, rect.height), "X"))
{
_activeModules.DeleteArrayElementAtIndex(index);
return;
}
rect.x += 20;
rect.width -= 20;
_activeModules.GetArrayElementAtIndex(index).objectReferenceValue = (TextureAutoPackerModule)EditorGUI.ObjectField(rect, _activeModules.GetArrayElementAtIndex(index).objectReferenceValue, typeof(TextureAutoPackerModule), false);
}
private void OnGUI()
{
serializedObject.Update();
Color og = GUI.backgroundColor;
GUI.backgroundColor = _active.boolValue ? Color.green : Color.grey;
_active.boolValue = GUILayout.Toggle(_active.boolValue, new GUIContent("Active","Determine whether the Auto-Packer should initiate on texture import"), "Toolbarbutton");
GUI.backgroundColor = og;
EditorGUI.BeginDisabledGroup(!_active.boolValue);
modulesList.DoLayoutList();
if (GUILayout.Button(new GUIContent("Force Check", "Initiate the Auto-Packer without having to trigger a texture import")))
{
TextureAutoPacker.InitiateAutoPacking();
TextureAutoPackerProcessor.OnAutoPackingEnd();
}
EditorGUI.EndDisabledGroup();
serializedObject.ApplyModifiedProperties();
}
}
[CustomEditor(typeof(TextureAutoPackerModule))]
public class TextureAutoPacker : Editor
{
static GUIContent removeIcon;
TextureAutoPackerModule module;
SerializedProperty packingList;
GUIStyle freeButtonStyle;
public override void OnInspectorGUI()
{
freeButtonStyle = new GUIStyle("toolbarbutton") { padding = new RectOffset(1, 1, 1, 1) };
serializedObject.Update();
if (GUILayout.Button(new GUIContent("Add","Create a new Auto-Packed texture"), "toolbarbutton"))
{
module.packedTextures.Add(new AutoPackedTexture());
serializedObject.Update();
}
for (int i = packingList.arraySize - 1; i >= 0; i--)
DrawPackingProperty(i);
serializedObject.ApplyModifiedProperties();
}
private void OnEnable()
{
module = (TextureAutoPackerModule)target;
packingList = serializedObject.FindProperty("packedTextures");
removeIcon = EditorGUIUtility.IconContent("winbtn_win_close");
}
static bool Running;
public static bool InitiateAutoPacking()
{
bool HasPacked=false;
if (Running)
return true;
Running = true;
TextureAutoPackerData data = TextureAutoPackerData.GetInstance();
if (!data.active)
return false;
data.activeModules.ForEach(m =>
{
if (!m)
goto Skip;
SerializedObject module = new SerializedObject(m);
module.Update();
for (int i = 0; i < m.packedTextures.Count; i++)
{
if (m.packedTextures[i].WasModified())
{
HasPacked = true;
string newTexturePath = m.packedTextures[i].Pack();
if (string.IsNullOrEmpty(newTexturePath))
goto Skip;
SerializedProperty packedTexture = module.FindProperty("packedTextures").GetArrayElementAtIndex(i);
SerializedProperty hashes = packedTexture.FindPropertyRelative("channelsHashes");
for (int j = 0; j < 4; j++)
{
hashes.GetArrayElementAtIndex(j).stringValue = string.Empty;
if (m.packedTextures[i].channels[j].texture)
hashes.GetArrayElementAtIndex(j).stringValue = m.packedTextures[i].channels[j].texture.imageContentsHash.ToString();
}
packedTexture.FindPropertyRelative("forceModified").boolValue = false;
AssetDatabase.ImportAsset(newTexturePath, ImportAssetOptions.ForceUpdate);
TextureAutoPackerProcessor.PathToProperty.Add(new System.Tuple<string, SerializedProperty>(newTexturePath, packedTexture.FindPropertyRelative("packed")));
}
}
module.ApplyModifiedPropertiesWithoutUndo();
Skip:;
});
Running = false;
return HasPacked;
}
public void DrawPackingProperty(int index)
{
SerializedProperty t = packingList.GetArrayElementAtIndex(index);
SerializedProperty _name = t.FindPropertyRelative("name");
SerializedProperty _expanded = t.FindPropertyRelative("expanded");
SerializedProperty _channels = t.FindPropertyRelative("channels");
SerializedProperty _packed = t.FindPropertyRelative("packed");
SerializedProperty _encoding = t.FindPropertyRelative("encoding");
SerializedProperty _quality = t.FindPropertyRelative("jpgQuality");
SerializedProperty _modified = t.FindPropertyRelative("forceModified");
AutoPackedTexture autoTexture = ((TextureAutoPackerModule)t.serializedObject.targetObject).packedTextures[index];
using (new GUILayout.VerticalScope("box"))
{
using (new GUILayout.HorizontalScope())
{
using (new GUILayout.HorizontalScope("toolbarbutton", GUILayout.Width(12)))
_expanded.boolValue = GUILayout.Toggle(_expanded.boolValue, GUIContent.none, "foldout", GUILayout.Width(10));
using (new GUILayout.HorizontalScope("toolbarbutton"))
_name.stringValue = EditorGUILayout.TextField(GUIContent.none, _name.stringValue, GUI.skin.label);
if (GUILayout.Button(removeIcon, freeButtonStyle, GUILayout.Width(17)))
{
packingList.DeleteArrayElementAtIndex(index);
return;
}
}
if (_expanded.boolValue)
{
using (new GUILayout.HorizontalScope("box"))
{
_encoding.enumValueIndex = (int)(TextureUtility.TexEncoding)EditorGUILayout.EnumPopup((TextureUtility.TexEncoding)_encoding.enumValueIndex, GUILayout.Width(95));
EditorGUI.BeginDisabledGroup(_encoding.enumValueIndex != 1);
EditorGUIUtility.labelWidth = 50;
_quality.intValue = EditorGUILayout.IntSlider("Quality", _quality.intValue, 1, 100);
EditorGUIUtility.labelWidth = 0;
EditorGUI.EndDisabledGroup();
}
using (new GUILayout.HorizontalScope())
{
for (int i = 0; i < _channels.arraySize; i++)
{
if (DrawChannelProperty(_channels.GetArrayElementAtIndex(i)))
_modified.boolValue = true;
}
GUILayout.Label("", GUI.skin.verticalSlider, GUILayout.Height(133));
using (new GUILayout.VerticalScope("box"))
{
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
GUILayout.Label("Packed", "boldlabel");
GUILayout.FlexibleSpace();
}
GUILayout.Label(GUIContent.none);
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
_packed.objectReferenceValue = (Texture2D)EditorGUILayout.ObjectField("", _packed.objectReferenceValue, typeof(Texture2D), false, GUILayout.Width(66));
GUILayout.FlexibleSpace();
}
using (new GUILayout.HorizontalScope())
{
if (GUILayout.Button("Force Pack", "toolbarbutton"))
{
string newTexturePath = autoTexture.Pack();
if (!string.IsNullOrEmpty(newTexturePath))
{
AssetDatabase.ImportAsset(newTexturePath);
_packed.objectReferenceValue = AssetDatabase.LoadAssetAtPath<Texture2D>(newTexturePath);
}
}
}
}
}
}
}
}
public bool DrawChannelProperty(SerializedProperty channel)
{
bool edited = false;
SerializedProperty _name = channel.FindPropertyRelative("name");
SerializedProperty _texture = channel.FindPropertyRelative("texture");
SerializedProperty _invert = channel.FindPropertyRelative("invert");
SerializedProperty _mode = channel.FindPropertyRelative("mode");
GUIStyle buttonGroupStyle = new GUIStyle(GUI.skin.GetStyle("toolbarbutton")) { padding = new RectOffset(1, 1, 1, 1), margin = new RectOffset(0, 0, 1, 1) };
using (new GUILayout.VerticalScope("box"))
{
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
GUILayout.Label(_name.stringValue, "boldlabel");
GUILayout.FlexibleSpace();
}
using (new GUILayout.HorizontalScope())
{
EditorGUI.BeginChangeCheck();
GUILayout.FlexibleSpace();
bool dummy;
EditorGUI.BeginChangeCheck();
dummy = GUILayout.Toggle(_mode.enumValueIndex == (int)ChannelTexture.ColorMode.Red, "R", buttonGroupStyle, GUILayout.Width(16));
if (EditorGUI.EndChangeCheck())
if (dummy)
_mode.enumValueIndex = 0;
EditorGUI.BeginChangeCheck();
dummy = GUILayout.Toggle(_mode.enumValueIndex == (int)ChannelTexture.ColorMode.Green, "G", buttonGroupStyle, GUILayout.Width(16));
if (EditorGUI.EndChangeCheck())
if (dummy)
_mode.enumValueIndex = 1;
EditorGUI.BeginChangeCheck();
dummy = GUILayout.Toggle(_mode.enumValueIndex == (int)ChannelTexture.ColorMode.Blue, "B", buttonGroupStyle, GUILayout.Width(16));
if (EditorGUI.EndChangeCheck())
if (dummy)
_mode.enumValueIndex = 2;
EditorGUI.BeginChangeCheck();
dummy = GUILayout.Toggle(_mode.enumValueIndex == (int)ChannelTexture.ColorMode.Alpha, "A", buttonGroupStyle, GUILayout.Width(16));
if (EditorGUI.EndChangeCheck())
if (dummy)
_mode.enumValueIndex = 3;
GUILayout.FlexibleSpace();
if (EditorGUI.EndChangeCheck())
if (_texture.objectReferenceValue)
edited = true;
}
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
_texture.objectReferenceValue = (Texture2D)EditorGUILayout.ObjectField("", _texture.objectReferenceValue, typeof(Texture2D), false, GUILayout.Width(66));
GUILayout.FlexibleSpace();
}
EditorGUI.BeginChangeCheck();
_invert.boolValue = GUILayout.Toggle(_invert.boolValue, "Invert", "toolbarbutton");
if (EditorGUI.EndChangeCheck())
if (_texture.objectReferenceValue)
edited = true;
}
return edited;
}
}
public class TextureAutoPackerProcessor : AssetPostprocessor
{
public static List<System.Tuple<string, SerializedProperty>> PathToProperty = new List<System.Tuple<string, SerializedProperty>>();
public static bool TextureImported = false;
void OnPostprocessTexture(Texture2D texture)
{
TextureImported = true;
}
public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
if (TextureImported)
{
TextureImported = false;
if (!TextureAutoPacker.InitiateAutoPacking())
OnAutoPackingEnd();
}
}
public static void OnAutoPackingEnd()
{
PathToProperty.ForEach(t =>
{
t.Item2.serializedObject.Update();
t.Item2.objectReferenceValue = AssetDatabase.LoadAssetAtPath<Texture2D>(t.Item1);
t.Item2.serializedObject.ApplyModifiedPropertiesWithoutUndo();
});
PathToProperty.Clear();
}
}
public abstract class TAPDreadData<T> : ScriptableObject where T : ScriptableObject
{
private static T _instance = null;
private static string _SavePath;
protected static T GetInstance(string SavePath)
{
_SavePath = SavePath;
if (!_instance && Exists())
{
_instance = AssetDatabase.LoadAssetAtPath<T>(SavePath);
}
if (!_instance)
{
_instance = CreateInstance<T>();
string directoryPath = System.IO.Path.GetDirectoryName(SavePath);
if (!System.IO.Directory.Exists(directoryPath))
System.IO.Directory.CreateDirectory(directoryPath);
AssetDatabase.CreateAsset(_instance, _SavePath);
}
return _instance;
}
public static bool Exists()
{
return System.IO.File.Exists(_SavePath);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e8921d280a781e14bae3a414c99945a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DreadScripts.TextureUtility
{
[System.Serializable]
public class TextureAutoPackerData : TAPDreadData<TextureAutoPackerData>
{
public bool active;
public List<TextureAutoPackerModule> activeModules = new List<TextureAutoPackerModule>();
private static readonly string SavePath = "Assets/DreadScripts/Saved Data/Texture Utility/TextureAutoPackerData.asset";
public static TextureAutoPackerData GetInstance()
{
return GetInstance(SavePath);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7ca85679a83ff9c48b424bb5471ad605
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,69 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace DreadScripts.TextureUtility
{
[System.Serializable]
[CreateAssetMenu(fileName = "New Auto-Packer Module", menuName = "DreadScripts/Auto-Packer Module")]
public class TextureAutoPackerModule : ScriptableObject
{
public List<AutoPackedTexture> packedTextures;
public TextureAutoPackerModule()
{
packedTextures = new List<AutoPackedTexture>();
}
}
[System.Serializable]
public class AutoPackedTexture
{
public bool expanded;
public bool forward=true;
public string name;
public ChannelTexture[] channels;
public string[] channelsHashes;
public bool forceModified;
public Texture2D packed;
public TextureUtility.TexEncoding encoding;
public int jpgQuality = 75;
public AutoPackedTexture()
{
name = "New Packed Texture";
channels = new ChannelTexture[] {new ChannelTexture("Red",0), new ChannelTexture("Green", 1), new ChannelTexture("Blue", 2), new ChannelTexture("Alpha", 0) };
channelsHashes = new string[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };
encoding = TextureUtility.TexEncoding.SaveAsPNG;
}
public bool WasModified()
{
if (forceModified)
{
return true;
}
for (int i = 0; i < 4; i++)
{
string textureHash = string.Empty;
if (channels[i].texture)
textureHash = channels[i].texture.imageContentsHash.ToString();
if (textureHash != channelsHashes[i])
return true;
}
return false;
}
public string Pack()
{
string newTexturePath;
if (packed)
newTexturePath = TextureUtility.PackTexture(channels, AssetDatabase.GetAssetPath(packed), packed.width, packed.height, encoding, false, true, false);
else
newTexturePath = TextureUtility.PackTexture(channels, encoding, true, false);
return newTexturePath;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 57dd297cddefa864f9927f223270c5b6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c470de7697213b34496ac48dd23b3be5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
{
"name": "com.dreadscripts.textureutility.Editor",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d5ab47812aae52a4a99db70b474a6420
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

21
TextureUtility/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Dreadrith
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8dd1810bc8cd5a24e8eebb9a23cc8276
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

17
TextureUtility/README.md Normal file
View File

@@ -0,0 +1,17 @@
# Texture Utility
Texture Utility's purpose is to speed up the workflow by negating the need to use other software for mundane texture edits and achieve the desired results directly in Unity.
## Features
- Resize, Rotate, Invert, Saturate, Hueshift and Colorize textures with Support for Masks.
- Quickly Create a Solid or Gradient colored texture.
- Unpack or Pack textures with color channels.
- Includes an Auto-Packing system to automatically pack a texture from its channels.
![image](https://cdn.discordapp.com/attachments/1096062791984619603/1096062792345325588/unknown2.png?ex=66343c45&is=6632eac5&hm=a6d6440039b0832d1ce7054a7c21f2136efec8be5fb9c1cff86f09439908d057&)
Found under DreadTools > Utility > Texture Utility
![image](https://cdn.discordapp.com/attachments/1096062791984619603/1096062916115042344/unknown.png?ex=66343c63&is=6632eae3&hm=ae7d89710dfd9e2d6436eef4a06a6b7b1f6f0cbd4d5f5e1233f6950bbe0a1e3a&)
### Thank you
If you enjoy Texture Utility, please consider [supporting me ♡](https://ko-fi.com/Dreadrith)!

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7b0372979745b6a41813732aab3b0d2b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
Texture Auto-Packer is made to negate the need to have to go through texture packing by automatically detecting channels modifications and update the resulting texture
How Auto-Packer works:
----------------------
Auto-Packer will usually initiate whenever a Texture gets imported, whether it's new, modified or re-imported.
It checks the settings in the Auto-Packer window, and checks for changes in each module, and packs each texture that's marked as modified.
An Auto-Packed Texture is marked as modified when:
- The Channel Textures doesn't match the hash of the textures the last time it got packed.
- The Channel selector was changed
- Invert toggle was clicked.
Module Settings:
----------------
Used to determine what Auto-Packed Textures to check for channel modification
Found under Assets > Create > DreadScripts > Auto-Packer Module
An Auto-Packed Texture consists of 4 Channel Textures (RGBA) and a Packed Texture (Result)
Add: Creates a new Auto-Packed Texture
Save As: Determines the extension of the Packed Texture.
Quality: Only for JPG, determines the quality of the Packed Texture.
RGBA: Determines which channel should be sampled for the respective color
Invert: Inverts the sampled colors from the color texture.
Force Pack: Packs the resulting texture regardless of modification. (Overwrites result texture).
Window Settings
---------------
Used to modify the settings of the Auto-Packer.
Found under DreadTools > Utilities > Texture Auto-Packer
Active: Determines whether the Auto-Packer should check for channel modifications and pack the result if needed.
Active Modules: The Modules that the Auto-Packer should lookup for textures to pack
Force Check: Initiates the Auto-Packer without having to trigger a texture import.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3d86b10016e9bc64198f9c0c985fb5fc
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
Texture Utility is made to make mundane and simple edits easier and quicker by doing it straight through Unity
Found under DreadTools > Utilities > Texture Utility
General Settings:
-----------------
Dimensions (W and H): - Width and Height of the newly created Textures. Refresh Icon resets the dimensions to the currently set Main Texture.
- Popup button is to select hardcoded preset dimensions.
- You can add your own in the script in Texture Utility > Editor > TextureUtility.cs. Simply add a new line to "DimensionPresets" with the same format.
Save As: - Choose whether to save as PNG or JPG. JPG is typically smaller than but doesn't support Transparency.
- If using JPG, use the slider to set the quality of it. Less quality is smaller size but smaller color range.
Copy Import Settings: - Newly Created Texture will derive its import settings from the referenced texture. Settings such as Max Size, Crunch, Compression, etc...
Highlight Texture: - Project / Assets window will automatically navigate to the folder where the new texture was created.
Editing Tab: For Resize and Edits.
------------
Main: - The Main texture the edits will be applied to.
Mask: - Defines the parts and factor of how and where the edits will be applied. Black is a factor of 0. White is a factor of 1.
"M" Toggle: - Chooses whether the module should be affected by the Mask.
Rotate: - Rotates the texture or flips it.
Invert: - Inverts the Colors of the selected channels on the texture. R > Red, G > Green, B > Blue, A > Alpha. an R G B invert is the typical color invert.
Saturate: - (Very Wonky) Increases / Decreases the saturation of the texture. -1 will guarantee all colors are grayscale. +1 is Hell.
Hue Shift: - Shifts the Hue of the texture. +1 is a full round hue shift back to the same color.
Colorize: - Lerps the colors between the main texture and the target Texture / Color. 0 is no change. +1 is full on target colors.
- "T" Toggle switches the mode between Color and Texture. "A" Toggle chooses whether the Alpha of the target should be used.
Press "Apply" to apply the edits. This will create a new texture with the same name in the same folder as the main texture with the desired edits.
Creating Tab: For creating simple textures
-------------
Custom Dimensions: - Choose to specify the dimensions of the newly created texture
- By default, Dimensions will be 4x4 for Solid Color, 256x4 for Horizontal Gradient, 4x256 for Vertical Gradient.
Reverse Texture: - The colors of the created texture will be flipped.
Texture Mode: - Choose whether the texture is a solid color or a horizontal/vertical gradient.
Color/Gradient: - Choose your colors for the new texture.
Save To: - The folder where the textures will be created.
Press "Create" to create the new texture. It will save the texture under the path specified in "Save To".
Packing Tab: For Unpacking/Packing texture's channels (RGBA)
------------
Unpack: - Choose the main texture then Press "Unpack".
- This will create 3-4 textures (RGB(A)) in the same folder as the main texture with their appropriate channel colors.
Pack: - Insert your channel colors that you wish to merge under their appropriate channels
- The Colored box is the default solid color to use if not using a texture.
- Choose the color that you wish to extract from the Channel's texture or color
- Invert Toggle will invert the colors of the channel before packing it.
- Press "Pack" to pack the textures into 1 texture.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c707e378e04c9504fa468e0a8e33b44f
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
{
"name": "com.dreadscripts.textureutility",
"displayName": "DreadScripts - TextureUtility",
"version": "1.1.0",
"description": "Texture Utility's purpose is to speed up the workflow by negating the need to use other software for mundane texture edits and achieve the desired results directly in Unity.",
"gitDependencies": {},
"vpmDependencies": {},
"author": {
"name": "Dreadrith",
"email": "dreadscripts@gmail.com",
"url": "https://www.dreadrith.com"
},
"legacyFolders": {},
"legacyFiles": {},
"type": "tool",
"unity": "2019.4"
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 916a3c2e56cb4d0489cc897a2dd8d03c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: