Code Monkey home page Code Monkey logo

texture-toolkit's Introduction

texture-toolkit

Easily create, manipulate, and export textures in the Unity Technologies Game Engine

Copyright EJM Software 2015 โ€“ ejmsoftware.com


EDITOR

Found in editor folder

TextureCreatorWindow

  • Open window using: "Window/Texture TK/Creator"
  • Use to generate textures procedurally in the Unity Editor

TextureEditorWindow

  • Open window using: "Window/Texture TK/Editor"
  • Use to edit/draw on textures in the Unity Editor

API

Found in scripts folder and works in runtime

TextureGen

  • create procedual textures using algorithms for clouds, marble, wood, and xor

TextureTools

  • Draw shapes on textures and export to png

EXAMPLE USES

Export Mesh uvs to png file

using UnityEngine;
using texturetk;

[RequireComponent(typeof(MeshFilter))]
public class uvexporter : MonoBehaviour {

	[ContextMenu("Export to file")]
	void ExportUVs () {
		// Load the mesh
		Mesh m = gameObject.GetComponent<MeshFilter> ().sharedMesh;
		int[] tris = m.triangles;
		Vector2[] uvs = m.uv;
		// Create the texture to draw the uv map on
		int w = 1024;
		int h = 1024;
		Texture2D tex = new Texture2D(w, h);
		// Draw the uv map lines on the texture
		for (int i=0;i<tris.Length;i+=3){
			Vector2 pt1 = uvs[tris[i]];
			Vector2 pt2 = uvs[tris[i+1]];
			Vector2 pt3 = uvs[tris[i+2]];
			TextureTools.DrawLine(tex, (int)(pt1.x*w), (int)(pt1.y*h), (int)(pt2.x*w), (int)(pt2.y*h), Color.red);
			TextureTools.DrawLine(tex, (int)(pt2.x*w), (int)(pt2.y*h), (int)(pt3.x*w), (int)(pt3.y*h), Color.red);
			TextureTools.DrawLine(tex, (int)(pt3.x*w), (int)(pt3.y*h), (int)(pt1.x*w), (int)(pt1.y*h), Color.red);
		}
		tex.Apply();
		// Save the texture with exported uvs
		string path = Application.dataPath + "/exporteduvs.png";
		Debug.Log ("Exporting uvs to "+path);
		TextureTools.SaveTexture(tex, path);
	}
}

Licensed under Apache 2.0. You may obtain a copy of the License at apache.org

texture-toolkit's People

Contributors

bitoffdev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.