• 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
1
Question by mausalamon · Dec 27, 2010 at 04:10 PM · shadertexturecolormappinball

Shader Texture Change

Hi, guys.

I'm making some pinball game and I have a doubt about some textures.

On the pinball table I have some objects that work as labels like "POWER", arrows and other lights. All objects have some shader and are using the same Texture Map, an image that contains all textures of all objects on the table (this was provided by my 3D modeler).

I need to change the texture of some objects when player hit some table areas. Some objects, not all objects. Is there any way to do this using a general texture map like I'm using or I need to create specified textures for each object?

Thanks!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Graineik · Jan 07, 2011 at 02:27 PM

You can use general texture maps for that. Just create a script that changes the texture whenever the instance gets hit, or whenerver you want to change the apperance. I have made a script that works quite similar. It changes textures when you hit a button.

var happyTex : Texture; var sadTex : Texture;

function OnEnable(){ renderer.material.mainTexture = happyTex; }

function Update () { if (Input.GetKeyDown (KeyCode.U)) { if (renderer.material.mainTexture == happyTex) { renderer.material.mainTexture = sadTex; } else if (renderer.material.mainTexture == sadTex) { renderer.material.mainTexture = happyTex; } } }

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
-1

Answer by mausalamon · Jan 07, 2011 at 03:49 PM

Thank you! This sample code help me!

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 Jessy · Jan 07, 2011 at 04:18 PM 0
Share

This does not belong in an answer, and this technique isn't code-based. It's based on modeling and texturing.

avatar image
0

Answer by Jessy · Jan 07, 2011 at 02:58 PM

The term that you want, when saying "general texture map", is atlas.

You can do this any way you like. My recommendation is to copy the UVs, from UV1, move them to UV2. Then, you can transform them as you like, but it would probably make the most sense to work with them in the islands they came in, because the modeler presumably did a good job unwrapping already. Then, when the appearances need to change, change the materials, and use custom shaders that utilize UV2 instead of UV1.

You could always just keep the same UVs, and map a new atlas to them, but if you've got an entire machine, and you're only going to make an atlas for a subset of that machine, UV1 probably isn't going to make good use of texture space - there would probably be a lot of empty area.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Assigning UV Map to model at runtime 0 Answers

Coloured specularity mapping? 1 Answer

Shader to partially ignore lighting (Specific colors) 0 Answers

Why are my values shifted by a factor of around 13 ? 0 Answers

How to access Emission Color of a Material in Script? 5 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