├── .gitignore ├── Assets ├── texture-toolkit.meta └── texture-toolkit │ ├── Logo.xcf │ ├── Logo.xcf.meta │ ├── editor.meta │ ├── editor │ ├── TextureCreatorWindow.cs │ ├── TextureCreatorWindow.cs.meta │ ├── TextureEditorWindow.cs │ └── TextureEditorWindow.cs.meta │ ├── examples.meta │ ├── examples │ ├── .DS_Store │ ├── Grass.png │ ├── Grass.png.meta │ ├── marble.png │ ├── marble.png.meta │ ├── tile.png │ ├── tile.png.meta │ ├── wood.png │ └── wood.png.meta │ ├── scripts.meta │ └── scripts │ ├── TextureGen.cs │ ├── TextureGen.cs.meta │ ├── TextureTools.cs │ └── TextureTools.cs.meta ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── QualitySettings.asset ├── TagManager.asset └── TimeManager.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | 6 | # Autogenerated VS/MD solution and project files 7 | /*.csproj 8 | /*.unityproj 9 | /*.sln 10 | /*.suo 11 | /*.user 12 | /*.userprefs 13 | /*.pidb 14 | /*.booproj 15 | 16 | #Unity3D Generated File On Crash Reports 17 | sysinfo.txt 18 | 19 | #Mac desktop files 20 | .DS_Store 21 | -------------------------------------------------------------------------------- /Assets/texture-toolkit.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 079dcb23e9aad4f568697739215d54ca 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/texture-toolkit/Logo.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/Assets/texture-toolkit/Logo.xcf -------------------------------------------------------------------------------- /Assets/texture-toolkit/Logo.xcf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fb834cfff39545ba9d57fc14f4bc807 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/texture-toolkit/editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 131346e2ec62546eabcc01e6bbd569de 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/texture-toolkit/editor/TextureCreatorWindow.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System; 4 | using System.Reflection; 5 | using texturetk; 6 | using System.Collections.Generic; 7 | 8 | public class TextureCreatorWindow : EditorWindow 9 | { 10 | class TextureLayer 11 | { 12 | public MethodInfo LayerMethod; 13 | public Color StartColor = Color.white; 14 | public Color EndColor = Color.black; 15 | 16 | object[] ParameterData = new object[0]; 17 | Texture2D _tex = new Texture2D(512, 512); 18 | bool isDirty = true; 19 | 20 | public TextureLayer(MethodInfo layermethod){ 21 | LayerMethod = layermethod; 22 | ParameterData = loadParameters(LayerMethod); 23 | } 24 | 25 | public void SetDirty(){ 26 | isDirty = true; 27 | } 28 | 29 | public string Name{ 30 | get { 31 | return LayerMethod.Name; 32 | } 33 | } 34 | 35 | public Texture2D Tex{ 36 | get { 37 | if (isDirty){ 38 | _tex = LayerMethod.Invoke(null, ParameterData) as Texture2D; 39 | TextureTools.GrayscaleToColor(_tex, StartColor, EndColor); 40 | isDirty = false; 41 | } 42 | return _tex; 43 | } 44 | } 45 | 46 | public void DrawEditor(){ 47 | EditorGUI.BeginChangeCheck (); 48 | GUI.Label (new Rect (3, 20, 70, 16), "Start Color"); 49 | StartColor = EditorGUI.ColorField (new Rect(76, 20, 80, 16), StartColor); 50 | GUI.Label (new Rect (3, 40, 70, 16), "End Color"); 51 | EndColor = EditorGUI.ColorField (new Rect(76, 40, 80, 16), EndColor); 52 | 53 | ParameterInfo[] Params = LayerMethod.GetParameters (); 54 | for (int i=0;i layers = new List(); 79 | 80 | //Structure 81 | Vector2 ScrollPos = Vector2.zero; 82 | Rect PreviewRect; 83 | Rect LabelRect = new Rect(3, 3, 50, 16); 84 | Rect DeleteRect = new Rect(76, 3, 80, 16); 85 | 86 | [MenuItem ("Window/Texture TK/Creator")] 87 | public static void ShowWindow () 88 | { 89 | EditorWindow win = EditorWindow.GetWindow ("Tex-Creator"); 90 | win.minSize = new Vector2 (160f, 200f); 91 | } 92 | 93 | void OnEnable() 94 | { 95 | // Get the public methods. 96 | LayerMethods = loadMethods (typeof(TextureGen)); 97 | //Get method names 98 | LayerMethodNames = new string[LayerMethods.Length]; 99 | for (int i=0; i 139 | /// Loads the methods for a given type. 140 | /// 141 | /// The methods as a MethodInfo Array. 142 | /// Type. 143 | static MethodInfo[] loadMethods(Type type){ 144 | MethodInfo[] methods = type.GetMethods(); 145 | methods = System.Array.FindAll (methods, p => p.DeclaringType==type); 146 | return methods; 147 | } 148 | /// 149 | /// Loads the parameters of a given method 150 | /// 151 | /// ParameterInfo Array 152 | /// Method to get paramters from 153 | static object[] loadParameters(MethodInfo method){ 154 | ParameterInfo[] pInfo = method.GetParameters(); 155 | object[] pData = new object[pInfo.Length]; 156 | for (int i=0; i ls){ 168 | Texture2D tex = new Texture2D (512, 512); 169 | Color[] outpix = new Color[tex.width*tex.height]; 170 | for (int i=0;i 183 | /// Saves a texture. 184 | /// 185 | /// Texture to save 186 | /// Path to save the texture to 187 | static void SaveTexture(Texture2D tex, string path) 188 | { 189 | if (!string.IsNullOrEmpty(path)){ 190 | byte[] bytes = tex.EncodeToPNG(); 191 | System.IO.File.WriteAllBytes(path, bytes); 192 | } 193 | } 194 | /// 195 | /// Loads a texture. 196 | /// 197 | /// The texture as a Texture2D 198 | /// Path to load the texture from. 199 | static Texture2D LoadTexture(string path) 200 | { 201 | Texture2D tex = new Texture2D(0,0); 202 | if (!string.IsNullOrEmpty(path)){ 203 | byte[] bytes = System.IO.File.ReadAllBytes(path); 204 | tex.LoadImage(bytes); 205 | } 206 | return tex; 207 | } 208 | #endregion 209 | } 210 | -------------------------------------------------------------------------------- /Assets/texture-toolkit/editor/TextureCreatorWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43842775f8c9040dc8e62208f9f1596c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/texture-toolkit/editor/TextureEditorWindow.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System; 4 | using System.Reflection; 5 | using System.Collections.Generic; 6 | 7 | public class TextureEditorWindow : EditorWindow 8 | { 9 | Texture2D preview; 10 | Rect labelposition; 11 | int currentTool = 0; 12 | List versions = new List (); 13 | Vector2 clickpos; 14 | Rect settingsrect = new Rect (10f, 30f, 100f, 40f); 15 | //Styles 16 | //GUIStyle winstyle; 17 | //User Prefs 18 | Color paintColor = Color.white; 19 | 20 | [MenuItem ("Window/Texture TK/Editor")] 21 | public static void ShowWindow () 22 | { 23 | EditorWindow win = EditorWindow.GetWindow ("Tex-Editor"); 24 | win.minSize = new Vector2 (275f, 200f); 25 | } 26 | 27 | void OnGUI () 28 | { 29 | GUILayout.BeginHorizontal (EditorStyles.toolbar); 30 | if (GUILayout.Button ("File", EditorStyles.toolbarDropDown, GUILayout.Width (50f))) { 31 | GenericMenu filedrop = new GenericMenu(); 32 | filedrop.AddItem(new GUIContent("New"), false, NewFile); 33 | filedrop.AddItem(new GUIContent("Open"), false, OpenFile); 34 | filedrop.AddItem(new GUIContent("Save"), false, SaveFile); 35 | filedrop.DropDown(new Rect(5f, 0f, 80f, 20f)); 36 | } 37 | if (GUILayout.Button ("Edit", EditorStyles.toolbarDropDown, GUILayout.Width (50f))) { 38 | GenericMenu editdrop = new GenericMenu(); 39 | editdrop.AddItem(new GUIContent("Rotate"), false, RotateTex); 40 | editdrop.AddItem(new GUIContent("Flip Y"), false, FlipTex); 41 | editdrop.AddItem(new GUIContent("Undo"), false, UndoTex); 42 | editdrop.DropDown(new Rect(55f, 0f, 80f, 20f)); 43 | } 44 | currentTool = EditorGUILayout.Popup (currentTool, new string[5]{"Tools", "Brush", "Line", "Rect", "Circle"}, EditorStyles.toolbarDropDown, GUILayout.Width (50f)); 45 | GUILayout.FlexibleSpace (); 46 | GUILayout.EndHorizontal (); 47 | 48 | GUILayout.Label (preview); 49 | labelposition = GUILayoutUtility.GetLastRect(); 50 | /* 51 | GUIStyle style = new GUIStyle(); 52 | labelposition = GUILayoutUtility.GetRect(this.position.width, this.position.width); 53 | GUI.DrawTexture(labelposition, preview, ScaleMode.StretchToFill, true, 10.0f); 54 | */ 55 | 56 | if (currentTool==1) { 57 | TryDraw (GUILayoutUtility.GetLastRect ()); 58 | } else if (currentTool==2) { 59 | TryLine (GUILayoutUtility.GetLastRect ()); 60 | } else if (currentTool==3) { 61 | TryRect (GUILayoutUtility.GetLastRect ()); 62 | } else if (currentTool==4) { 63 | TryCircle (GUILayoutUtility.GetLastRect ()); 64 | } 65 | BeginWindows (); 66 | settingsrect = GUI.Window(0, settingsrect, RectSettings, "Settings"); 67 | EndWindows (); 68 | if (preview!=null){ 69 | GUI.Box (new Rect (this.position.width-100f, this.position.height-20f, 100f, 20f), TexMousePos().ToString ()); 70 | Repaint (); 71 | } 72 | } 73 | void OpenFile(){ 74 | preview = LoadTexture (EditorUtility.OpenFilePanel("Open Image", Application.absoluteURL, "")); 75 | versions.Clear (); 76 | versions.Add(Instantiate(preview) as Texture2D); 77 | } 78 | void NewFile(){ 79 | preview = new Texture2D(512, 512); 80 | versions.Clear (); 81 | versions.Add(Instantiate(preview) as Texture2D); 82 | } 83 | void SaveFile(){ 84 | SaveTexture(preview, EditorUtility.SaveFilePanelInProject("Save Texture", "image", "png", "")); 85 | AssetDatabase.Refresh(); 86 | } 87 | void RotateTex(){ 88 | texturetk.TextureTools.Rotate(preview); 89 | versions.Add(Instantiate(preview) as Texture2D); 90 | } 91 | void FlipTex(){ 92 | texturetk.TextureTools.FlipY(preview); 93 | versions.Add(Instantiate(preview) as Texture2D); 94 | } 95 | void UndoTex(){ 96 | if(versions.Count>1){ 97 | versions.RemoveAt(versions.Count-1); 98 | preview = Instantiate(versions[versions.Count-1]) as Texture2D; 99 | Repaint(); 100 | } 101 | } 102 | #region Static Helper Methods 103 | /// 104 | /// Saves a texture. 105 | /// 106 | /// Texture to save 107 | /// Path to save the texture to 108 | static void SaveTexture(Texture2D tex, string path) 109 | { 110 | if (!string.IsNullOrEmpty(path)){ 111 | byte[] bytes = tex.EncodeToPNG(); 112 | System.IO.File.WriteAllBytes(path, bytes); 113 | } 114 | } 115 | /// 116 | /// Loads a texture. 117 | /// 118 | /// The texture as a Texture2D 119 | /// Path to load the texture from. 120 | static Texture2D LoadTexture(string path) 121 | { 122 | Texture2D tex = new Texture2D(0,0); 123 | if (!string.IsNullOrEmpty(path)){ 124 | byte[] bytes = System.IO.File.ReadAllBytes(path); 125 | tex.LoadImage(bytes); 126 | } 127 | return tex; 128 | } 129 | #endregion 130 | Vector2 TexMousePos(){ 131 | float pixRatio = Mathf.Max(1f, preview.width / labelposition.width); // Ratio to convert mouse coordinates to texture pixel coordinates 132 | int texCursorX = (int)((Event.current.mousePosition.x - labelposition.x - 3) * pixRatio); 133 | int texCursorY = preview.height - (int)((Event.current.mousePosition.y - labelposition.y - 3) * pixRatio); 134 | return new Vector2((float)texCursorX, (float)texCursorY); 135 | } 136 | 137 | void TryDraw(Rect texrect){ 138 | if ((Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseDrag) && texrect.Contains (Event.current.mousePosition)) { 139 | float pixRatio = Mathf.Max(1f, preview.width / texrect.width); // Ratio to convert mouse coordinates to texture pixel coordinates 140 | int texCursorX = (int)((Event.current.mousePosition.x - texrect.x - 3) * pixRatio); 141 | int texCursorY = preview.height - (int)((Event.current.mousePosition.y - texrect.y - 3) * pixRatio); 142 | for (int x=texCursorX-3;xProcedural Marble Texture 9 | /// Pixel width of texture 10 | /// Pixel height of texture 11 | /// defines repetition of marble lines in x direction (Default 5) 12 | /// defines repetition of marble lines in y direction (Default 10) 13 | /// Makes twists (Default 0.1) 14 | /// Initial size of the turbulence (Default 32) 15 | /// 16 | /// xPeriod and yPeriod together define the angle of the lines 17 | /// xPeriod and yPeriod both 0 ==> it becomes a normal clouds or turbulence pattern 18 | /// turbPower = 0 ==> it becomes a normal sine pattern 19 | /// 20 | /// Returns a Texture2D 21 | public static Texture2D marble(int w = 512, int h = 512, float xPeriod = 5f, float yPeriod = 10f, float turbPower = 300f, float turbSize = 32f) 22 | { 23 | Color[] pix = new Color[w * h]; 24 | 25 | for(int x = 0; x < w; x++){ 26 | for(int y = 0; y < h; y++){ 27 | int i = x + y * w; 28 | float xyValue = x * xPeriod / h + y * yPeriod / w + turbPower * turbulence(x, y, turbSize) / 256f; 29 | float sineValue = 256f * Mathf.Abs(Mathf.Sin(xyValue * 3.14159f)); 30 | pix[i] = Color.Lerp (Color.black, Color.white, sineValue/255); 31 | } 32 | } 33 | 34 | Texture2D noiseTex = new Texture2D (w, h); 35 | noiseTex.SetPixels(pix); 36 | noiseTex.Apply(); 37 | return noiseTex; 38 | } 39 | /// Procedural Wood Texture 40 | /// Pixel width of texture 41 | /// Pixel height of texture 42 | /// number of rings (Default 12) 43 | /// Makes twists (Default 0.1) 44 | /// Initial size of the turbulence (Default 32) 45 | /// Returns a Texture2D 46 | public static Texture2D wood(int w = 512, int h = 512, float xyPeriod = 12f, float turbPower = 0.1f, float turbSize = 32f) 47 | { 48 | Color[] pix = new Color[w * h]; 49 | 50 | for(int x = 0; x < w; x++){ 51 | for(int y = 0; y < h; y++){ 52 | int i = x + y * w; 53 | float xValue = (x - h / 2f) / (float)h; 54 | float yValue = (y - w / 2f) / (float)w; 55 | float distValue = Mathf.Sqrt(xValue * xValue + yValue * yValue) + turbPower * turbulence(x, y, turbSize) / 256f; 56 | float sineValue = 128f * Mathf.Abs(Mathf.Sin(2f * xyPeriod * distValue * 3.14159f)); 57 | pix[i] = Color.Lerp (Color.black, Color.white, sineValue/255); 58 | } 59 | } 60 | 61 | Texture2D noiseTex = new Texture2D (w, h); 62 | noiseTex.SetPixels(pix); 63 | noiseTex.Apply(); 64 | return noiseTex; 65 | } 66 | /// Procedural Cloud Texture 67 | /// Pixel width of texture 68 | /// Pixel height of texture 69 | /// Lower values are grittier, higher values are smoother 70 | /// Returns a Texture2D 71 | public static Texture2D clouds(int w = 512, int h = 512, float size = 64f) 72 | { 73 | Color[] pix = new Color[w * h]; 74 | 75 | for(int x = 0; x < w; x++){ 76 | for(int y = 0; y < h; y++){ 77 | int i = x + y * w; 78 | float val = turbulence(x, y, size); 79 | pix[i] = Color.Lerp (Color.black, Color.white, val); 80 | } 81 | } 82 | 83 | Texture2D noiseTex = new Texture2D (w, h); 84 | noiseTex.SetPixels(pix); 85 | noiseTex.Apply(); 86 | return noiseTex; 87 | } 88 | /// Procedural XOR (tiled) Texture 89 | /// Pixel width of texture 90 | /// Pixel height of texture 91 | /// The texture will look best when the w and h parameters are powers of two. 92 | /// Returns a Texture2D 93 | public static Texture2D xor(int w = 512, int h = 512) 94 | { 95 | Color[] pix = new Color[w * h]; 96 | float size = Mathf.Max (w, h); 97 | 98 | for(int x = 0; x < w; x++){ 99 | for(int y = 0; y < h; y++){ 100 | int i = x + y * w; 101 | float val = (x ^ y)/size; 102 | pix[i] = Color.Lerp (Color.black, Color.white, val); 103 | } 104 | } 105 | 106 | Texture2D noiseTex = new Texture2D (w, h); 107 | noiseTex.SetPixels(pix); 108 | noiseTex.Apply(); 109 | return noiseTex; 110 | } 111 | /// 112 | /// Turbulence given the specified x, y and size. 113 | /// 114 | /// The x coordinate. 115 | /// The y coordinate. 116 | /// Size. 117 | static float turbulence(float x, float y, float size){ 118 | float value = 0.0f; 119 | float n = size; 120 | 121 | while(n >= 1) { 122 | value += Mathf.PerlinNoise(x / n, y / n) * n; 123 | n /= 2.0f; 124 | } 125 | 126 | return(value / size); 127 | } 128 | } 129 | } -------------------------------------------------------------------------------- /Assets/texture-toolkit/scripts/TextureGen.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8361a5799d97c419ebdcfb970db8b459 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/texture-toolkit/scripts/TextureTools.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.IO; 3 | 4 | namespace texturetk 5 | { 6 | public class TextureTools 7 | { 8 | /// 9 | /// Draws a circle on the given texture 10 | /// 11 | public static void DrawCircle(Texture2D tex, Vector2 pos, int radius, Color col){ 12 | DrawCircle (tex, (int)pos.x, (int)pos.y, radius, col); 13 | } 14 | public static void DrawCircle(Texture2D tex, int cx, int cy, int r, Color col) 15 | { 16 | int x, y, px, nx, py, ny, d; 17 | 18 | for (x = 0; x <= r; x++) 19 | { 20 | d = (int)Mathf.Ceil(Mathf.Sqrt(r * r - x * x)); 21 | for (y = 0; y <= d; y++) 22 | { 23 | px = cx + x; 24 | nx = cx - x; 25 | py = cy + y; 26 | ny = cy - y; 27 | 28 | tex.SetPixel(px, py, col); 29 | tex.SetPixel(nx, py, col); 30 | 31 | tex.SetPixel(px, ny, col); 32 | tex.SetPixel(nx, ny, col); 33 | 34 | } 35 | } 36 | tex.Apply (); 37 | } 38 | /// 39 | /// Draws a line from pos1 to pos2 on the given texture 40 | /// 41 | public static void DrawLine (Texture2D tex, Vector2 pos1, Vector2 pos2, Color col){ 42 | DrawLine (tex, (int)pos1.x, (int)pos1.y, (int)pos2.x, (int)pos2.y, col); 43 | } 44 | public static void DrawLine (Texture2D tex, int x1, int y1, int x2, int y2, Color col){ 45 | if (x2-x1 == 0f){//Check if vertical line 46 | for (int y=(int)Mathf.Min (y1, y2); y<(int)Mathf.Max (y1, y2); y++){ 47 | tex.SetPixel((int)x1, y, col); 48 | } 49 | } else { 50 | float m = (y2 - y1) / (x2 - x1);//Line slope 51 | float b = -m * x1 + y1;//Y-intercept 52 | int blockH = (int)Mathf.Abs(m) + 1; 53 | Color[] cols = new Color[blockH]; 54 | for (int i=0; i 73 | /// Flips the given texture vertically 74 | /// 75 | public static void FlipY(Texture2D tex){ 76 | Color[] pix = new Color[tex.width*tex.height]; 77 | for (int x=0;x 86 | /// Rotates the given texture 90 degrees 87 | /// 88 | public static void Rotate(Texture2D tex){ 89 | Color[] pix = new Color[tex.width*tex.height]; 90 | for (int x=0;x 99 | /// Converts Grayscale Textures to Colored Texture 100 | /// 101 | public static void GrayscaleToColor(Texture2D tex, Color start, Color end) 102 | { 103 | Color[] pix = tex.GetPixels (); 104 | for (int i=0; i 111 | /// Saves a texture at the given path 112 | /// 113 | public static void SaveTexture(Texture2D tex, string path) 114 | { 115 | if (!string.IsNullOrEmpty(path)){ 116 | byte[] bytes = tex.EncodeToPNG(); 117 | File.WriteAllBytes(path, bytes); 118 | } 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /Assets/texture-toolkit/scripts/TextureTools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5e4d9d7bbde84a8f900c73cb5fcd72f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2014 EJM Software 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitoffdev/texture-toolkit/4794ec12911ec639f4cc67aac02bdd7afd64b3ce/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | texture-toolkit 2 | =================== 3 | 4 | Easily create, manipulate, and export textures in the Unity Technologies Game Engine 5 | 6 | Copyright EJM Software 2015 – [ejmsoftware.com](http://ejmsoftware.com) 7 | 8 | ------ 9 | 10 | ### EDITOR 11 | 12 | Found in editor folder 13 | 14 | TextureCreatorWindow 15 | - Open window using: "Window/Texture TK/Creator" 16 | - Use to generate textures procedurally in the Unity Editor 17 | 18 | TextureEditorWindow 19 | - Open window using: "Window/Texture TK/Editor" 20 | - Use to edit/draw on textures in the Unity Editor 21 | 22 | ------ 23 | 24 | ### API 25 | 26 | Found in scripts folder and works in runtime 27 | 28 | TextureGen 29 | - create procedual textures using algorithms for clouds, marble, wood, and xor 30 | 31 | TextureTools 32 | - Draw shapes on textures and export to png 33 | 34 | ------ 35 | 36 | ### EXAMPLE USES 37 | 38 | Export Mesh uvs to png file 39 | 40 | using UnityEngine; 41 | using texturetk; 42 | 43 | [RequireComponent(typeof(MeshFilter))] 44 | public class uvexporter : MonoBehaviour { 45 | 46 | [ContextMenu("Export to file")] 47 | void ExportUVs () { 48 | // Load the mesh 49 | Mesh m = gameObject.GetComponent ().sharedMesh; 50 | int[] tris = m.triangles; 51 | Vector2[] uvs = m.uv; 52 | // Create the texture to draw the uv map on 53 | int w = 1024; 54 | int h = 1024; 55 | Texture2D tex = new Texture2D(w, h); 56 | // Draw the uv map lines on the texture 57 | for (int i=0;i