Complaining: Unity infrastructure is not my strong point, I mainly do the engine and project combat, how to use the unity engine to efficiently realize the function of the game is my main research direction.
But after taking office has been doing UI, tuning components, layout, not Kai Sen, not Kai Sen!
Today, ah light to share is a small tool, write their own. Because the company's UI is rich, a variety of basemaps and so many. In order not to let the picture resources repeat for reasons such as importing pictures
When you need a picture from the art resources to take, one by one to add to the project. Then, as usual, modify the picture to make it into a sprite.
Add a picture to a project resource by default this is the case,
The Required property setting is this:
If you manually adjust it, it's too much trouble, click Select, apply options, and then I write a gadget right away. It's good to write code in C #, but.
I can only write in Lua right now.
Now share this gadget with everyone.
Today's mood so down, do not want to comment. The code is simple, which is to set some properties. You can try to modify to achieve your desired requirements.
usingUnityengine;usingSystem.Collections;usingUnityeditor;usingSystem.IO;/// <summary>///This function is automatically processed for the image resource, set type, format, etc./// </summary> Public classTextureeditor {StaticObject targetobj; [MenuItem ("Textureedit/edit")] Static voidedittexture () {targetobj= Selection.activeobject;//This function will give you the object you selected. if(Targetobj && Targetobj isTexture) { stringPath =Assetdatabase.getassetpath (targetobj); Textureimporter Texture= Assetimporter.getatpath (path) asTextureimporter; Texture.texturetype=Textureimportertype.sprite; Texture.spritepixelsperunit=1; Texture.filtermode=filtermode.trilinear; Texture.mipmapenabled=false; Texture.textureformat=Textureimporterformat.automatictruecolor; Assetdatabase.importasset (path); } } }
After you finish writing, you may need to reopen the project, and you'll see this stuff:
Select the picture and click Edit to see the effect yourself!
Unity uses code to modify texture properties, one-click to generate Sprites