Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Fattie · May 03, 2012 at 05:54 PM · texturemeshsprite2.5dextensions

Tool to make ONE flat sized mesh from a png/texture?

I have the very specific problem that I need to take an image, and then,

quickly create a flat mesh, two tris, and put the image on it and sized to it.

So that's a two-tri mesh, sized to the actual image portion and spun correctly, etc.

If anyone knows of a tool that does this, thanks!!

This is NOT for use in the GUI layer nor on a 2.5D stage solution. It is for use in a normal 3D scene.

Actually it sounds like there is NOT such a tool in the asset store -- which probably makes sense as it seems like a pretty specific use case.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Fattie · Jun 23, 2012 at 09:33 PM

Just FTR there is NOT such a tool in the asset store -- which probably makes sense as it seems like a pretty specific use case.

Simply use 2DTooljit (or any competitor) and make just the one item. There's no "lighter solution" around.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by Bunny83 · May 05, 2012 at 01:19 PM

I just read your comments and even after your long phrased question you still haven't mentioned any auto-alignment or auto-fitting. If you need something like that why don't use use one of those packages like the spritemanager? People usually invent toolkits or tools to be used in many situations. Most the time you need more than one sprite. You said the plane that comes with Unity is bad (due to 121 verts and 200 tris so you want a 2 tris mesh). If you worry about the tris why don't you use the spritemanager then? For example 4 such sprites with seperate renderers will produce 4 drawcalls. The tris isn't that important. It's the fact that each of them need a renderer. That's why those toolkits pack all sprites into one mesh so it just needs one drawcall.

If you really need exactly one of these sprites, you can just use the plane mesh in Unity, import a 2 tris mesh from your favourite model app or create it procedural.

If you attach the following script to an empty gameobject it will create a 1x1 mesh along the x-y plane, so it's facing toward positive z (forward) axis.

 //C#
 using UnityEngine;
 using System.Collections;
 
 public class Quad : MonoBehaviour {
     public Material material;
     void Start() {
         gameObject.AddComponent<MeshRenderer>().material = material;
         Mesh mesh = gameObject.AddComponent<MeshFilter>().mesh;
         mesh.Clear();
         mesh.vertices = new Vector3[] {new Vector3(-0.5f, 0, -0.5f), new Vector3(0.5f, 0, -0.5f), new Vector3(0.5f, 0, 0.5f), new Vector3(-0.5f, 0, 0.5f)};
         mesh.uv = new Vector2[] {new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0)};
         mesh.triangles = new int[] {0, 1, 2,  2, 3, 0};
     }
 }

To rotate an object towards another object (if noone is given it will choose the main camera), just attach this script:

 //C#
 using UnityEngine;
 using System.Collections;
 
 public class LookAt : MonoBehaviour {
     public Transform target;
     void Start() {
         if (target == null && Camera.main != null)
             target = Camera.main.transform;
     }
     void LateUpdate() {
         if (target == null) return;
         transform.LookAt(target);
     }
 }

Now you have a 2 tris quad mesh which will automatically rotate itself towards the camera or towards any given object.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Greg Dunn · May 05, 2012 at 02:16 PM 1
Share

I think what they're trying to say is that no, it doesn't exist in a package you can just download or buy or find on the wiki because there are a number of ways to accomplish it, most of which would involve building the tools yourself if you don't want to do things manually (via 3D app or just dragging it on and resizing it).

While yes, it seems like something that someone would have already built and put out there, but at the same time, it's so simple that most people wouldn't see the value in taking the time to build it and package it up and throw it on the asset store (for example) because there are a number of ways (code and non-code) to accomplish the same result and existing toolkits (like Sprite$$anonymous$$anager) are available to do this and much more, because this typically wouldn't be used on it's own.

avatar image
0

Answer by Piflik · May 03, 2012 at 06:17 PM

What do you mean, turn one image into a sprite?

A sprite IS an image...if you want it animated you have multiple versions of the same object on the sprite(sheet), but it is still just an image. There is no difference between a texture and a sprite.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Piflik · May 03, 2012 at 06:52 PM 0
Share

Create a plane, create a material, put texture into material, put material on the plane (not necessarily in that exact order). You need an automatism for that?

avatar image Eric5h5 · May 04, 2012 at 09:07 AM 1
Share

Sure you can do it manually. Also you don't have to use a 2-tri mesh, it's just better, and you don't have to run an algorithm. You can just stick a texture on a plane and there's your sprite.

avatar image Piflik · May 04, 2012 at 11:16 AM 0
Share

Finding the correct aspect ratio should be easy, too. Textures should be power of 2 anyway, so they would either be square, or rectangular with a 1:2, 1:4, 1:8, etc aspect ratio.

avatar image Fattie · May 05, 2012 at 09:46 AM 0
Share

E, yes 2-tri is what I need. You can't do rotation fitting manually, (other than just by eye).

avatar image
0

Answer by Eric5h5 · May 04, 2012 at 09:06 AM

Just use a GUITexture?

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · May 04, 2012 at 09:15 AM 0
Share

:D I love this short answers

avatar image Eric5h5 · May 04, 2012 at 07:18 PM 0
Share

It's really short in Unity too... 1) Click on desired texture. 2) Select GameObject -> Create Other -> GUI Texture. Bam! Sprite!

avatar image Fattie · May 05, 2012 at 09:40 AM 0
Share

Hi Eric, thanks for that, however I don't want a texture for use in Unity's GUI.

I just want pretty much what it says: a 2-tri mesh (for use in the normal 3d world) with the texture fitted to it. Exactly like 2DToolkit's runtime provides, say, but just a one-off.

avatar image
0

Answer by monks · Oct 13, 2013 at 12:08 AM

https://www.assetstore.unity3d.com/#/content/10063

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

multiple textures on one mesh + different Albedos 1 Answer

How to scroll a region of texture (which is an atlas) on a mesh (which is a sprite) 2 Answers

Texture type -> Advanced -> Mesh type: how it works? 1 Answer

Unity distort a sprite to match a mesh 2 Answers

Apply a texture on model 3D with the Mouse Position taking account of the scale/position/rotation of uv // Appliquer une texture sur un modele 3D en fonction de la position du curseur en prenant en compte la rotation/taille/position des uv 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges