Code Monkey home page Code Monkey logo

easy-icon-maker's Introduction

Easy Icon Maker

Easy Icon Maker is a simple but flexible tool for creating images from 3D objects in Unity Editor.

Main

Key features:

  • creating an image from objects with the MeshRenderer component in a specially created scene
  • use the visual interface or the plugin api
  • setting the position, rotation and scale of the object
  • setting the direction and color of two light sources
  • fill the background with solid color, set a transparent background, or set the image as the background
  • the ability to select a folder to save the image (by default, images are saved in the "Assets/Easy Icon Maker" folder)

Examples of getting an image from the code:

Creating an image will consist of several basic steps:

  • create a preview scene
  • adding an object with the MeshRenderer component to the scene
  • calling the image-making method
  • clear scene preview

Optionally, you can customize the scene using the following properties of the scene object:

  • GameObject CameraContainer (used for rotation the camera around the object)
  • Camera PreviewCamera
  • Light Light1
  • Light Light2

Texture2D MakeImage(string folderPathf, string name, int size, Texture texBG) method parameters:

  • folderPathf - path to save the image. If you specify null, then image will be no saving, if you specify "default", then there will be a save to the folder "Assets/Easy Icon Maker/".
  • name - name of the saved file. If you specify "default", then the name will be taken from GameObject.name.
  • size - width and height of the square image.
  • texBG - image to be used as background.
using EasyIconMaker;
//...

#if UNITY_EDITOR

	// creating Preview Scene
	PreviewScene preview = new PreviewScene();
	
	// adding a prefab object to the scene
	preview.InitInstance(go);
	
	
	// getting a texture with a white background and a size of 256x256 pixels without saving the file to disk
	Texture2D tex = preview.MakeImage(null, null, 256, null);  
	
	// getting a texture with a yellow background, size 378x378 pixels and saving it in the "Assets/My folder/" folder with the name icon1.png
	string folderPathf = "Assets/My folder/";
	string name = "icon1";
	preview.PreviewCamera.backgroundColor = Color.yellow;
	Texture2D tex = preview.MakeImage(folderPathf, name, 378, null); 

	// getting a texture with a transparent background, size 512x512 pixels and saving it in the "Assets/Easy Icon Maker/" folder with the GameObject name .png
	preview.PreviewCamera.clearFlags = CameraClearFlags.Nothing;
	Texture2D tex = preview.MakeImage("default", "default", 512, null);  
	
	// creating a texture with a background from your image, size 256x256 and saving it in the "Assets/Easy Icon Maker/" folder with name car.png
	string name = "car";
	Texture myBackground = Resources.Load<Texture>("Textures/backgroundForIcon"));
	preview.PreviewCamera.clearFlags = CameraClearFlags.Nothing;
	preview.MakeImage("default", name, 256, myBackground);
	
	
	// clearing the scene
	preview.Cleanup();
	
#endif

//...

easy-icon-maker's People

Contributors

servalstar 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.