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 GGStudios · Jan 09, 2013 at 11:06 AM · meshimagecubebox

Cube shows image same on all sides?

hey, im new to the program, im working with a cube that shows a tree.png image. when i rotate the game n it shows the other side of the cube its upside down. a few sides of the cube shows the tree upright but other sides show it upside down, how do i make it so the cube shows the image upright on all 4 sides.

thanks heap

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

2 Replies

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

Answer by AlucardJay · Jan 09, 2013 at 12:30 PM

This is a copy of my answer Here : http://answers.unity3d.com/questions/306959/uv-mapping.html


I have listed all the ways to custom UV map a unity cube here : http://answers.unity3d.com/questions/294165/apply-uv-coordinates-to-unity-cube-by-script.html

Imagine looking at the front of the cube, the first 4 vertices are arranged like so

 //   2 --- 3
 //   |     |
 //   |     |
 //   0 --- 1

then the UV's are mapped as follows :

 theUVs[2] = Vector2( 0, 1 );
 theUVs[3] = Vector2( 1, 1 );
 theUVs[0] = Vector2( 0, 0 );
 theUVs[1] = Vector2( 1, 0 );

 //    2    3    0    1   Front
 //    6    7   10   11   Back
 //   19   17   16   18   Left
 //   23   21   20   22   Right
 //    4    5    8    9   Top
 //   15   13   12   14   Bottom

So where the UV's for Vertices 2 is ( 0, 1 ), so is 6, 19, 23, 4, 15.

You can test this by replacing all the zero's with 0.5, then check every face of the cube has the same portion of the image, and rotated the correct way (not inverted) . Note if standing at the origin looking up the positive Z-Axis, Right is your right.

for example this script would map the TOP of the cube to any UV coordinates of a texture you like :

 #pragma strict
 // TOP
 
 function Start() 
 {
     // Get the mesh
     var theMesh : Mesh;
     theMesh = this.transform.GetComponent(MeshFilter).mesh as Mesh;
 
     // Now store a local reference for the UVs
     var theUVs : Vector2[] = new Vector2[theMesh.uv.Length];
     theUVs = theMesh.uv;
 
     // set UV co-ordinates
     theUVs[4] = Vector2( 0.5, 1.0 );
     theUVs[5] = Vector2( 1.0, 1.0 );
     theUVs[8] = Vector2( 0.5, 0.5 );
     theUVs[9] = Vector2( 1.0, 0.5 );
 
     // Assign the mesh its new UVs
     theMesh.uv = theUVs;
 }
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 Turbine · Jan 15, 2013 at 04:09 AM 0
Share

don't reinvent the light bulb. Just download the right model in the first place. You didn't deal with mesh tangents. They are used in bump mapping and need to be updated when you change the UV's. I don't understand the math to it, but it makes a big difference.

avatar image AlucardJay · Jan 15, 2013 at 04:22 AM 0
Share

That is interesting. As just (some of) the UVs are re-assigned, wouldn't the tangents remain persistent? This point wasn't raised on the last 2 questions I gave this answer for. With custom procedural meshes I pass my whole mesh to TangentSolver by Eric5h5

http://forum.unity3d.com/threads/38984-How-to-Calculate-$$anonymous$$esh-Tangents

http://answers.unity3d.com/questions/7789/calculating-tangents-vector4.html

to the OP : I just wanted to know if you saw this, tried it, and what you thought (had alot of answers recently with no response).

avatar image Turbine · Jan 16, 2013 at 04:34 PM 0
Share

I don't feel like stepping through the math to figure out how they use the UV's, but I noticed that they used the texture coordinates in this post of code at lines 17, 34-36,45-48.

http://forum.unity3d.com/threads/38984-How-to-Calculate-$$anonymous$$esh-Tangents?p=284585&viewfull=1#post284585

avatar image
2

Answer by tosi · Jan 09, 2013 at 11:36 AM

I don't know, if there is an easy way in Unity. But you could model a cube in your favorite 3d modelling program and adjust the texture mapping there. After that you import the cube into Unity.

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

11 People are following this question.

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

Related Questions

Simple plane generation 1 Answer

Making a cube from planes, arranging planes into a box 1 Answer

Box Collider Vs Simple Plane Mesh Collider 1 Answer

Procedurally Generated Cube Mesh 3 Answers

How make an object fall after a cube moves off the object? 1 Answer


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