Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by giraffeseatwindmills · Jun 22, 2016 at 06:00 AM · textureuvcoordinatesuv mappingmapping

How can I make my texure line up right with the default cube

So I have a square texture (300 X 300) and I would assume that it would align right with the default cube all around but on some faces it flips the image upside down.

On three of the four faces the texture is fine and is the right side up but it flips it on one side and I can't figure out why.

I added a T to the top of the texture to help illustrate whats wrong. Any help would be great. alt text

bad-mapping.png (153.5 kB)
Comment
Add comment · Show 3
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 SarperS · Jun 22, 2016 at 06:53 AM 0
Share

Is using a custom mesh an option? Here, I made one for you link text

unit-cube.zip (4.3 kB)
avatar image Dibbie SarperS · Jun 22, 2016 at 07:00 AM 0
Share

Sarper is correct. Unity isnt always easy to work around textures, so you cant essentially drag/drop onto a object and expect perfect results... You have to mess around with shaders or import the object as a mesh and UV the texture onto it, and sometimes a combination of both (which from my experience, importing UV's is essentially making Unity create a custom shader with default settings)

avatar image giraffeseatwindmills SarperS · Jun 22, 2016 at 03:43 PM 0
Share

I've tried using a basic cube I imported from blender with UV's that I set up and it works. I'd just really prefer to use the built in cube for the sake of easier access and an overall cleaner environment. The weird thing is that some other textures of the same proportions line up just fine while others don't.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by RumbleStrut · Nov 06, 2017 at 04:10 PM

 using UnityEngine;
 
 public class FILENAME : MonoBehaviour {
 
     //Flips the UV on the backside of the cube so it matches the front and sides
     void OnValidate () {
         Vector2[] uvs = GetComponent<MeshFilter> ().sharedMesh.uv;
 
         uvs [6] = new Vector2 (0, 0);
         uvs [7] = new Vector2 (1, 0);
         uvs [10] = new Vector2 (0, 1);
         uvs [11] = new Vector2 (1, 1);
 
         GetComponent<MeshFilter> ().sharedMesh.uv = uvs;
     }
 }
Comment
Add comment · Show 2 · 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 pbavinck · Apr 20, 2021 at 01:17 PM 0
Share

Was struggling with the same (I'm an absolute beginner) and this solved it immediately.

Some additional questions.

How often is the OnValidate() executed ? Only in Editor, and only after change of GameObject?

Does the script need to remain attached to the cube or prefab once it has executed? (I expect it to have updated the uvs of the cube (in the prefab) and does not need to remain attached).

Thanks.

avatar image RumbleStrut pbavinck · May 19, 2021 at 12:21 AM 0
Share
     // you are correct, here's another example
 
     // first script
      using UnityEngine;
      
      public class MyGameObjectClass : MonoBehavior {
      
          public GameObject cuber;
     
          void Start () {
              MyStaticClass.FlipCubeFace(cuber);
          }
      }
     
     //second script
      using UnityEngine;
      
      public static class MyStaticClass {
      
          public static void FlipCubeFace (GameObject cubee) {
              Vector2[] uvs = cubee.GetComponent<MeshFilter> ().sharedMesh.uv;
      
              uvs [6] = new Vector2 (0, 0);
              uvs [7] = new Vector2 (1, 0);
              uvs [10] = new Vector2 (0, 1);
              uvs [11] = new Vector2 (1, 1);
      
              cubee.GetComponent<MeshFilter> ().sharedMesh.uv = uvs;
          }
      }
 

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

6 People are following this question.

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

Related Questions

instantiate gameobject with the uv 0 Answers

part of my cube is textured but not bumpmapped 0 Answers

Hi, My textures are good on one side of the object, but very stretched out on the other side? How do I fix this? 0 Answers

orthographic sphere projection 0 Answers

UV distortions in Blender when connecting vertices. 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