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

8
Text2Texture/Editor.meta Normal file
View File

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

View File

@@ -0,0 +1,596 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UnityEngine;
using TMPro;
using UnityEditor;
using Object = UnityEngine.Object;
namespace DreadScripts.TextToTexture
{
public class TextToTexture : EditorWindow
{
#region Constants
private const string POIYOMI_SHADER_NAME = ".poiyomi/• Poiyomi Toon •";
private const string FALLBACK_SHADER_NAME = "Standard";
private const string DUMMY_PARENT_NAME = "(Temp) TTT_Objects";
private const string EDITORPREFS_SAVEPATH = "Text2TextureSavePath";
private const string EDITORPREFS_DEFAULTSAVEPATH = "Assets/DreadScripts/TextToTexture/Generated Assets";
private const string RESOURCE_FONTPATH = "Assets/DreadScripts/TextToTexture/Resources/TTT_DancingScript TMP.asset";
private const string RESOURCE_FONTGUID = "e7d6a5821a387564caacc9929e10eb22";
private const string RESOURCE_TEMPLATEPATH = "Assets/DreadScripts/TextToTexture/Resources/TTT_CanvasTemplate.prefab";
private const string RESOURCE_TEMPLATEGUID = "2cd48bc473a380748ad104409753555e";
private readonly string[] DimensionPresets =
{
"128x128",
"256x256",
"512x512",
"1024x1024",
"2048x2048",
"4096x4096",
};
#endregion
#region Automated Variables
public static string savePath;
private static GUIContent resetIcon;
private static bool showExtra;
private static bool isInCustomizing;
private static Camera tempCamera;
private static TextMeshProUGUI tempText;
private static GameObject tempParent;
private static Material tempMaterial;
private static RenderTexture tempRenderTexture;
#endregion
#region Input Variables
public static string textInput = "";
public static TextureGenerationType generationType = TextureGenerationType.GenerateMaterial;
public static TMP_FontAsset customFont;
public static float outlineThickness = 0.075f;
public static float extraPadding = 5;
public static Vector2 offset;
public static int resolutionWidth = 1024;
public static int resolutionHeight = 1024;
public static float verticalMargin = 100;
public static float horizontalMargin = 100;
public static bool invert;
public static bool wrapText = true;
#endregion
#region Declarations
public enum TextureGenerationType
{
GenerateNormalMap,
GenerateMask,
GenerateCustomTexture,
GenerateMaterial
}
#endregion
[MenuItem("DreadTools/Utility/Text2Texture")]
public static void showWindow()
{
var title = GetWindow<TextToTexture>(false, "Text2Texture", true).titleContent;
title.image = EditorGUIUtility.IconContent("GUIText Icon").image;
}
private void OnGUI()
{
EditorGUI.BeginDisabledGroup(isInCustomizing);
GUIStyle iconStyle = new GUIStyle() {margin = new RectOffset(0, 0, 1, 1)};
using (new GUILayout.VerticalScope("helpbox"))
{
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
GUILayout.Label("Text Input", "boldlabel");
GUILayout.FlexibleSpace();
}
textInput = EditorGUILayout.TextArea(textInput);
generationType = (TextureGenerationType)EditorGUILayout.EnumPopup(generationType);
}
using (new GUILayout.VerticalScope("box"))
{
showExtra = EditorGUILayout.Foldout(showExtra, "Extra Settings");
if (showExtra)
{
using (new GUILayout.HorizontalScope("helpbox"))
customFont = (TMP_FontAsset) EditorGUILayout.ObjectField("Custom Font", customFont, typeof(TMP_FontAsset), false);
using (new GUILayout.HorizontalScope("helpbox"))
using (new EditorGUI.DisabledScope(generationType != TextureGenerationType.GenerateNormalMap && generationType != TextureGenerationType.GenerateMaterial))
outlineThickness = Mathf.Clamp01(EditorGUILayout.FloatField("Normal Thickness", outlineThickness));
using (new GUILayout.HorizontalScope("helpbox"))
extraPadding = EditorGUILayout.FloatField("Padding", extraPadding);
using (new GUILayout.HorizontalScope("helpbox"))
{
GUILayout.Label("Offset", GUILayout.Width(136));
offset = EditorGUILayout.Vector2Field(GUIContent.none, offset);
}
using (new GUILayout.HorizontalScope("helpbox"))
{
GUILayout.Label("Margin (%)", GUILayout.Width(136));
EditorGUIUtility.labelWidth = 10;
horizontalMargin = EditorGUILayout.FloatField(new GUIContent("X", "Width"), horizontalMargin);
verticalMargin = EditorGUILayout.FloatField(new GUIContent("Y", "Height"), verticalMargin);
EditorGUIUtility.labelWidth = 0;
}
using (new GUILayout.HorizontalScope("helpbox"))
{
GUILayout.Label("Resolution", GUILayout.Width(136));
EditorGUIUtility.labelWidth = 0;
EditorGUIUtility.labelWidth = 10;
resolutionWidth = EditorGUILayout.IntField(new GUIContent("X", "Width"), resolutionWidth);
resolutionHeight = EditorGUILayout.IntField(new GUIContent("Y", "Height"), resolutionHeight);
EditorGUIUtility.labelWidth = 0;
int dummy = -1;
EditorGUI.BeginChangeCheck();
dummy = EditorGUILayout.Popup(dummy, DimensionPresets, GUILayout.Width(18));
if (EditorGUI.EndChangeCheck())
{
string[] dimensions = ((string) DimensionPresets.GetValue(dummy)).Split('x');
resolutionWidth = int.Parse(dimensions[0]);
resolutionHeight = int.Parse(dimensions[1]);
}
if (GUILayout.Button(resetIcon, iconStyle, GUILayout.Height(18), GUILayout.Width(18)))
resolutionWidth = resolutionHeight = 1024;
}
using (new GUILayout.HorizontalScope("helpbox"))
{
wrapText = EditorGUILayout.Toggle("Wrap Text", wrapText);
using (new EditorGUI.DisabledScope((int)generationType > 1))
invert = EditorGUILayout.Toggle(new GUIContent("Invert Map"), invert);
}
}
}
EditorGUI.EndDisabledGroup();
if (!isInCustomizing)
{
using (new EditorGUI.DisabledScope(string.IsNullOrWhiteSpace(textInput)))
using (new GUILayout.HorizontalScope())
{
if (GUILayout.Button("Generate"))
{
switch (generationType)
{
case TextureGenerationType.GenerateNormalMap:
case TextureGenerationType.GenerateMask:
GenerateInit();
break;
case TextureGenerationType.GenerateCustomTexture:
isInCustomizing = true;
GenerateInit();
break;
case TextureGenerationType.GenerateMaterial:
generationType = TextureGenerationType.GenerateNormalMap;
Texture2D normalTexture = GenerateInit();
generationType = TextureGenerationType.GenerateMask;
bool oldInvert = invert;
invert = true;
Texture2D maskTexture = GenerateInit();
invert = oldInvert;
generationType = TextureGenerationType.GenerateMaterial;
Shader currentShader = Shader.Find(POIYOMI_SHADER_NAME) ?? Shader.Find(FALLBACK_SHADER_NAME);
Material newMaterial = new Material(currentShader);
#region Standard/Generic Property Set
newMaterial.SetTexture("_MainTex", maskTexture);
newMaterial.SetTexture("_MetallicGlossMap", maskTexture);
newMaterial.SetTexture("_BumpMap", normalTexture);
newMaterial.SetFloat("_Glossiness", 0.85f);
newMaterial.SetFloat("_GlossMapScale", 0.85f);
#endregion
#region Poiyomi Propert Set
newMaterial.EnableKeyword("VIGNETTE_CLASSIC");
newMaterial.SetTexture("_BRDFSpecularMap", maskTexture);
newMaterial.SetTexture("_BRDFMetallicMap", maskTexture);
newMaterial.SetFloat("_LightingMode", 1);
newMaterial.SetFloat("_LightingStandardSmoothness", 0.85f);
newMaterial.SetFloat("_EnableBRDF", 1);
newMaterial.SetFloat("_BRDFMetallic", 1);
newMaterial.SetFloat("_BRDFGlossiness", 0.85f);
#endregion
string newMatName = Regex.Replace(textInput, "[^\\w\\._ ]", "");
if (newMatName.Length > 30) newMatName = "Generated TextMaterial";
string newMatPath = AssetDatabase.GenerateUniqueAssetPath($"{savePath}/{newMatName}.mat");
AssetDatabase.CreateAsset(newMaterial, newMatPath);
EditorGUIUtility.PingObject(newMaterial);
break;
}
}
}
}
else
{
if (!tempCamera) isInCustomizing = false;
if (GUILayout.Button("Save Texture"))
GenerateTexture();
}
DrawSeparator();
savePath = AssetFolderPath(savePath, "New Textures Path", EDITORPREFS_SAVEPATH, false);
Credit();
}
private Texture2D GenerateInit()
{
GameObject canvasTemplate = ReadyResource<GameObject>(RESOURCE_TEMPLATEPATH, RESOURCE_TEMPLATEGUID);
customFont = customFont ?? ReadyResource<TMP_FontAsset>(RESOURCE_FONTPATH, RESOURCE_FONTGUID);
tempRenderTexture = new RenderTexture(resolutionWidth, resolutionHeight, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
float resolutionRatio = (float) resolutionWidth / resolutionHeight;
tempParent = GameObject.Find(DUMMY_PARENT_NAME);
if (tempParent) DestroyImmediate(tempParent);
tempParent = new GameObject(DUMMY_PARENT_NAME)
{
hideFlags = HideFlags.DontSaveInEditor | HideFlags.DontSaveInBuild,
transform =
{
position = new Vector3(420, 666, 69)
}
};
GameObject canvas = Instantiate(canvasTemplate, tempParent.transform);
if (generationType == TextureGenerationType.GenerateCustomTexture) EditorGUIUtility.PingObject(canvas.GetInstanceID());
tempCamera = canvas.GetComponentInChildren<Camera>();
tempText = canvas.GetComponentInChildren<TextMeshProUGUI>();
RectTransform textRect = tempText.GetComponent<RectTransform>();
tempCamera.transform.Translate(-offset);
tempCamera.orthographicSize = 80 + extraPadding * 2;
tempText.enableWordWrapping = wrapText;
tempText.font = customFont;
tempText.text = textInput;
switch (generationType)
{
case TextureGenerationType.GenerateNormalMap:
CreateTemporaryMaterial(tempText.fontSharedMaterial, true, true);
break;
case TextureGenerationType.GenerateMask:
CreateTemporaryMaterial(tempText.fontSharedMaterial, true, false);
break;
case TextureGenerationType.GenerateCustomTexture:
CreateTemporaryMaterial(tempText.fontSharedMaterial, false, false);
break;
}
textRect.sizeDelta = new Vector2(160 * resolutionRatio * (horizontalMargin/100), 160 * (verticalMargin / 100));
return isInCustomizing ? null : GenerateTexture();
}
private Texture2D GenerateTexture()
{
isInCustomizing = false;
tempCamera.targetTexture = tempRenderTexture;
RenderTexture.active = tempRenderTexture;
ReadyPath(savePath);
byte[] textureBytes = null;
switch (generationType)
{
case TextureGenerationType.GenerateNormalMap:
{
tempMaterial.SetFloat("_LightAngle", 0);
Texture2D bottomTexture = CaptureRender();
tempMaterial.SetFloat("_LightAngle", 6.28f / 4);
Texture2D rightTexture = CaptureRender();
tempMaterial.SetFloat("_LightAngle", 6.28f / 4 * 2);
Texture2D topTexture = CaptureRender();
tempMaterial.SetFloat("_LightAngle", 6.28f / 4 * 3);
Texture2D leftTexture = CaptureRender();
Color[] bottomPixels = bottomTexture.GetPixels();
Color[] rightPixels = rightTexture.GetPixels();
Color[] topPixels = topTexture.GetPixels();
Color[] leftPixels = leftTexture.GetPixels();
Color[] newColors = new Color[resolutionHeight * resolutionWidth];
Parallel.For(0, resolutionHeight, i =>
{
Parallel.For(0, resolutionWidth, j =>
{
int currentIndex = i * resolutionWidth + j;
float horizontalInfluence = 0.5f + leftPixels[currentIndex].r / 2 - rightPixels[currentIndex].r / 2;
float verticalInfluence = 0.5f + bottomPixels[currentIndex].r / 2 - topPixels[currentIndex].r / 2;
float blueColor = 1 - ((Mathf.Abs(horizontalInfluence - 0.5f) + Mathf.Abs(verticalInfluence - 0.5f)) / 2);
newColors[currentIndex] = new Color(horizontalInfluence, verticalInfluence, blueColor);
});
});
DestroyImmediate(rightTexture);
DestroyImmediate(topTexture);
DestroyImmediate(leftTexture);
bottomTexture.SetPixels(newColors);
bottomTexture.Apply();
textureBytes = bottomTexture.EncodeToPNG();
DestroyImmediate(bottomTexture);
break;
}
case TextureGenerationType.GenerateMask:
{
CreateTemporaryMaterial(tempText.fontSharedMaterial, true, false);
tempCamera.backgroundColor = invert ? Color.white : Color.black;
Texture2D maskTexture = CaptureRender();
textureBytes = maskTexture.EncodeToPNG();
DestroyImmediate(maskTexture);
break;
}
case TextureGenerationType.GenerateCustomTexture:
{
Texture2D newTexture = CaptureRender();
textureBytes = newTexture.EncodeToPNG();
DestroyImmediate(newTexture);
break;
}
}
RenderTexture.active = null;
tempRenderTexture.Release();
Texture2D generatedTexture = SaveTexture(textureBytes);
EditorGUIUtility.PingObject(generatedTexture);
if (tempParent)
DestroyImmediate(tempParent);
return generatedTexture;
}
private static Texture2D SaveTexture(byte[] textureBytes)
{
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(tempMaterial));
string suffix;
switch (generationType)
{
case TextureGenerationType.GenerateNormalMap:
suffix = " Normal";
break;
case TextureGenerationType.GenerateMask:
suffix = " Mask";
break;
default:
suffix = string.Empty;
break;
}
string texturePath = AssetDatabase.GenerateUniqueAssetPath($"{savePath}/{Regex.Replace(textInput, "[^\\w\\._ ]", "")}{suffix}.png");
try
{
File.WriteAllBytes(texturePath, textureBytes);
}
catch
{
texturePath = AssetDatabase.GenerateUniqueAssetPath($"{savePath}/Generated TextTexture.png");
File.WriteAllBytes(texturePath, textureBytes);
}
AssetDatabase.ImportAsset(texturePath);
TextureImporter textureSettings = (TextureImporter)AssetImporter.GetAtPath(texturePath);
if (generationType == TextureGenerationType.GenerateNormalMap) textureSettings.textureType = TextureImporterType.NormalMap;
if (generationType == TextureGenerationType.GenerateMask) textureSettings.sRGBTexture = false;
textureSettings.maxTextureSize = 1024;
textureSettings.crunchedCompression = true;
textureSettings.compressionQuality = 100;
textureSettings.streamingMipmaps = true;
textureSettings.SaveAndReimport();
return (Texture2D)AssetDatabase.LoadMainAssetAtPath(texturePath);
}
private static Texture2D CaptureRender()
{
tempCamera.Render();
Texture2D capturedTexture = new Texture2D(resolutionWidth, resolutionHeight, TextureFormat.RGBA32, false);
capturedTexture.ReadPixels(new Rect(0, 0, resolutionWidth, resolutionHeight), 0, 0);
return capturedTexture;
}
private static void SetRequiredMaterialSettings(Material m, bool isNormal)
{
foreach (var key in m.shaderKeywords)
m.DisableKeyword(key);
if (isNormal)
{
m.EnableKeyword("BEVEL_ON");
m.SetFloat("_OutlineWidth", outlineThickness);
}
m.SetFloat("_ShaderFlags", 0);
m.SetFloat("_Bevel", isNormal ? invert ? -1 : 1 : 0);
m.SetFloat("_BevelOffset", 0);
m.SetFloat("_BevelClamp", 0);
m.SetFloat("_BevelRoundness", 0);
m.SetFloat("_BevelWidth", 0.5f);
m.SetFloat("_Ambient", 1);
m.SetFloat("_SpecularPower", 1);
m.SetFloat("_Reflectivity", 5);
m.SetFloat("_Diffuse", 0);
m.SetFloat("_BumpFace", 0);
m.SetFloat("_BumpOutline", 0);
m.SetColor("_FaceColor", isNormal ? Color.clear : invert ? Color.black : Color.white);
m.SetColor("_OutlineColor", isNormal ? Color.black : Color.clear);
m.SetColor("_ReflectFaceColor", Color.clear);
m.SetColor("_ReflectOutlineColor", Color.clear);
m.SetColor("_SpecularColor", new Color(1.498039f, 1.498039f, 1.498039f));
}
private static void CreateTemporaryMaterial(Material original, bool ForceSettings, bool isNormal)
{
ReadyPath($"{savePath}/Temp");
string path = AssetDatabase.GenerateUniqueAssetPath($"{savePath}/Temp/(Temp) {original.name}.mat");
tempMaterial = CopyAssetAndReturn(original, path);
if (ForceSettings) SetRequiredMaterialSettings(tempMaterial, isNormal);
tempText.fontSharedMaterial = tempMaterial;
}
private void OnEnable()
{
savePath = EditorPrefs.GetString(EDITORPREFS_SAVEPATH, EDITORPREFS_DEFAULTSAVEPATH);
resetIcon = new GUIContent(EditorGUIUtility.IconContent("d_Refresh")) {tooltip = "Reset Dimensions"};
}
#region DSHelper Methods
private static T ReadyResource<T>(string resourcePath, string resourceGUID = "", string msg = "") where T : Object
{
T asset = Resources.Load<T>(resourcePath);
if (asset) return asset;
if (!string.IsNullOrWhiteSpace(resourceGUID))
{
asset = AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(resourceGUID));
if (asset) return asset;
}
if (string.IsNullOrWhiteSpace(msg)) msg = $"Required Resources Asset at Resource Path {resourcePath} not found! Execution may not proceed.";
EditorUtility.DisplayDialog("Error", msg, "Heck");
throw new NullReferenceException(msg);
}
private static void ReadyPath(string path)
{
if (Directory.Exists(path)) return;
Directory.CreateDirectory(path);
AssetDatabase.ImportAsset(path);
}
private static T CopyAssetAndReturn<T>(T obj, string newPath) where T : Object
{
string assetPath = AssetDatabase.GetAssetPath(obj);
Object mainAsset = AssetDatabase.LoadMainAssetAtPath(assetPath);
if (!mainAsset) return null;
if (obj != mainAsset)
{
T newAsset = Object.Instantiate(obj);
AssetDatabase.CreateAsset(newAsset, newPath);
return newAsset;
}
AssetDatabase.CopyAsset(assetPath, newPath);
return AssetDatabase.LoadAssetAtPath<T>(newPath);
}
private static string AssetFolderPath(string variable, string title, string playerpref, bool isPlayerPrefs = true)
{
using (new GUILayout.HorizontalScope())
{
using (new EditorGUI.DisabledScope(true))
EditorGUILayout.TextField(title, variable);
if (GUILayout.Button("...", GUILayout.Width(30)))
{
var dummyPath = EditorUtility.OpenFolderPanel(title, AssetDatabase.IsValidFolder(variable) ? variable : string.Empty, string.Empty);
if (string.IsNullOrEmpty(dummyPath))
return null;
if (!dummyPath.StartsWith("Assets"))
{
Debug.LogWarning("New Path must be a folder within Assets!");
return null;
}
variable = FileUtil.GetProjectRelativePath(dummyPath);
if (isPlayerPrefs)
PlayerPrefs.SetString(playerpref, variable);
else
EditorPrefs.SetString(playerpref, variable);
}
}
return variable;
}
private static void DrawSeparator(int thickness = 2, int padding = 10)
{
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(thickness + padding));
r.height = thickness;
r.y += padding / 2f;
r.x -= 2;
r.width += 6;
ColorUtility.TryParseHtmlString(EditorGUIUtility.isProSkin ? "#595959" : "#858585", out Color lineColor);
EditorGUI.DrawRect(r, lineColor);
}
private static void Credit()
{
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button("Made By Dreadrith#3238", "boldlabel"))
Application.OpenURL("https://linktr.ee/Dreadrith");
}
}
#endregion
}
}

View File

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

View File

@@ -0,0 +1,18 @@
{
"name": "com.dreadscripts.text2texture.Editor",
"references": [
"GUID:6546d7765b4165b40850b3667f981c26",
"GUID:6055be8ebefd69e48b49212b09b47b2f"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

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

21
Text2Texture/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: 346c416569d58b04794129825a43a514
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

26
Text2Texture/README.md Normal file
View File

@@ -0,0 +1,26 @@
# Text2Texture
Easily generate a Normal Map, Mask, Custom Text Texture or a Material from given text input
## Requires TextMeshPro!
Window > Package Manager > TextMeshPro. When prompted, Import TMP Essentials.
## Features
- Supports custom font to use any font you'd like
- Generate a Normal Map to engrave or emboss text on a surface
- Generate a Mask to apply whatever masked effects you'd like in a text shape
- Generate a Material utilizing both of the maps. Uses Poiyomi and falls back to Standard.
- Easily generate any text image by customizing it in the intermediate stage in "Generate Custom Texture"
- Extra settings to generate the textures the way you want them
![image](https://cdn.discordapp.com/attachments/1096063656447459490/1096063656632000512/brandeded.gif?ex=66343d13&is=6632eb93&hm=1decea93481aaa9b076fb86306b85d99616bbe21872ba82c8e5e9512074bc2f7&)
## How to use a custom font
- Import your font asset into Unity
- Right Click Font > Create > TextMeshPro > Font Asset
- (Optional) You may change the settings on this asset if you'd like
- You can now Drag and Drop the new asset to the Custom Font field anytime
Done!
### Thank you
If you enjoy Text2Texture, please consider [supporting me ♡](https://ko-fi.com/Dreadrith)!

View File

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

View File

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

View File

@@ -0,0 +1,310 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8085274800980037037
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8085274800980037038}
- component: {fileID: 8085274800980037039}
m_Layer: 0
m_Name: Render Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8085274800980037038
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8085274800980037037}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -200}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 8085274801473204273}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &8085274800980037039
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8085274800980037037}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 90
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!1 &8085274801473204286
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8085274801473204273}
- component: {fileID: 8085274801473204275}
- component: {fileID: 8085274801473204272}
m_Layer: 5
m_Name: Input Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8085274801473204273
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8085274801473204286}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 8085274800980037038}
m_Father: {fileID: 8085274802494049708}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 160, y: 160}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8085274801473204275
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8085274801473204286}
m_CullTransparentMesh: 0
--- !u!114 &8085274801473204272
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8085274801473204286}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: e7d6a5821a387564caacc9929e10eb22, type: 2}
m_sharedMaterial: {fileID: -567968814723445512, guid: e7d6a5821a387564caacc9929e10eb22,
type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 0
m_fontSizeMax: 999
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &8085274802494049704
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8085274802494049708}
- component: {fileID: 8085274802494049709}
- component: {fileID: 8085274802494049706}
- component: {fileID: 8085274802494049707}
m_Layer: 5
m_Name: TTT_CanvasTemplate
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8085274802494049708
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8085274802494049704}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 8085274801473204273}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 160, y: 160}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!223 &8085274802494049709
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8085274802494049704}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 2
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!114 &8085274802494049706
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8085274802494049704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!114 &8085274802494049707
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8085274802494049704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295

View File

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

Binary file not shown.

View File

@@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 2dedba84ce1ce5c4c8bfb2b6ae52aabc
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontName: Dancing Script
fontNames:
- Dancing Script
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e7d6a5821a387564caacc9929e10eb22
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

17
Text2Texture/package.json Normal file
View File

@@ -0,0 +1,17 @@
{
"name": "com.dreadscripts.text2texture",
"displayName": "DreadScripts - Text2Texture",
"version": "1.0.2",
"description": "Easily generate a Normal Map, Mask, Custom Text Texture or a Material from given text input.",
"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: 978fe590e329822418f0a78fbd4df2fe
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: