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 lvictorino · Jul 01, 2012 at 02:10 PM · rotationtexturecubequadplacement

Change a cube face with another texture

Hello,

My question is hard for me to explain so please, do not hesitate to ask me for more details.

I work with a cube. This cube has a texture applied thanks to UV mapping in order to have a different color for each face of the cube. While the game is running I'd like to change one of the face of this cube to another texture (for example replacing the blue face by the "skull" texture). Then, this new face has to behave like it's actually a face of the cube (ie: when I rotate the cube, the face rotate as it's the actual blue face).

I looked for a solution and the simplest seems to be:

  • Instantiate a quad

  • Change the quad material to "skull texture"

  • Change rotation / position (minus very small number in order to avoid z-fight) to make it appear in front of the right face of the cube

  • Change the transform.parent to the cube transform property

Because the original cube on what I try to change a face may have already rotate (several time), I can't manage to correctly align the quad on the right face.

I hope my question is clear enough. If you have some other way to proceed and achieve the same thing, do not hesitate to share it.

Thank you.

Comment
Add comment · Show 2
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 tomekkie2 · Jul 01, 2012 at 03:20 PM 0
Share

I woul manipulate the uv or make the cube to have six submeshes and six materials to access them independently - or alternatively assembly the cube fom six planes and you could have individual colliders for individual mouse interaction as well

avatar image lvictorino · Jul 01, 2012 at 03:47 PM 0
Share

I think @Fattie is right. I can't manage to use decal yet... so playing with uv sounds too hard for me right now.

3 Replies

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

Answer by Fattie · Jul 01, 2012 at 02:25 PM

PS --- in an actual game you knwo how I would do this? Just swap it to ANOTHER DIFFERENT CUBE! it's that simple. Heh!


YES. what you're doing is just called a

Decal

it's a great idea! Go for it.

i suggest you search on "decal" and read all about the various techniques thereof.

Note that you could also use a "projector", if you like, for a different effect.

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 lvictorino · Jul 01, 2012 at 03:49 PM 0
Share

I can't find informations usefull about coordinates and how to correctly put the decal in the right spot.

avatar image lvictorino · Jul 01, 2012 at 07:27 PM 0
Share

About your PS: Changing the actual cube by another with the face would mean that you would need 6 different cubes for 1 changing face (1 per different face)... if you have to deal with a lot of "new faces" it would mean a lot of extra cubes. Also, you wouldn't be able to rotate the texture in order to have it in the "right" way.

avatar image
1

Answer by Ashkan_gc · Jul 01, 2012 at 03:30 PM

Create a cube in max with 6 materials and submeshes and then easily assign different textures at runtime to different materials or just use a texture for the material with 6 defined parts for each side and change the data for that part at runtime using SetPixels method of Texture2d class. The first method is faster in some ways and slower in some other, If it's not a common thing to change texture use the SetPixels method because rendering one material is faster than 6 ones.

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 lvictorino · Jul 01, 2012 at 07:33 PM 0
Share

Using SetPixel should be fine... however, does it work if I intend to use some render to texture on my quad?

avatar image
-1

Answer by reptilebeats · Jul 01, 2012 at 05:11 PM

one trick i sometimes use, never for changing objects though is to use lights with a cookie. i mainly use it for graffiti as you get a nice effect after its baked blends in like graffitie would.

depending on what your doing you could do that, or have seperate cube textures with transparent sides over the cube, probably best bet is just to have flat images parented to the cube that are either enabled or disabled at run time, a bit like gui

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

9 People are following this question.

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

Related Questions

Rotation of 3D text on a cube always being upright. 0 Answers

How do I add a texture to a cube (yes I know I'm a scrub)? 1 Answer

Rotating a Rotated GUI Texture 0 Answers

How do I make a cube roll on a set forward path without it deviating 4 Answers

Rotating Textures 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