Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Lethil · Oct 15, 2015 at 08:58 PM · textureprefabmaterial

How do I get a material to tile dynamically?

Hi all, I've got a question regarding materials that I haven't been able to figure out. I'm working on building an isometric dungeon system with procedural rooms that are then connected with hallways.

My current plan is to create a hallway prefab that is smart enough to stretch between rooms. Unfortunately, I've run into a problem with materials assigned to the hall. When I stretch a hall, the textures stretch as well. If I shrink a hall, the texture shrinks as well. This makes sense obviously since the uvs on the hall (which are a series of planes) assume 0-1 on the lengths.

I want the material to tile the texture associated with it. Unfortunately, the only way I've seen to do this is to change the tiling on the material itself. The problem with this is that if there are 2 different sized walls with the same prefab, the shared prefab means that one material overrides the other.

I've seen this done in games, so I'm curious if anyone has a suggestion on how to do this. I've attached an image that sort of shows the problem I'm having.

Thanks!

example-of-issue.png (76.3 kB)
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

1 Reply

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

Answer by Eric5h5 · Oct 15, 2015 at 10:23 PM

It's not possible to do that with a single material. You will need different material instances for each hallway that needs different tiling. Just touching Renderer.material causes Unity to create a new instance for that object anyway, so it's easy enough to do.

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 Lethil · Oct 15, 2015 at 10:32 PM 0
Share

Oh, I misunderstood how the material works! If I touch the material properties, it instantiates it? $$anonymous$$y concern was that it shared the same reference with the other meshes pointing to the material and that changing it in one place will change it everywhere.

If the material is instanced the moment I change a property, that should solve the problem!

Thanks!

avatar image Eric5h5 Lethil · Oct 15, 2015 at 10:55 PM 0
Share

Yes, you'd need to use Renderer.shared$$anonymous$$aterial if you wanted to have your change reflected across everything that was using the material. When you touch Renderer.material, Unity creates an instance for you, behind the scenes. (Which can lead to confusion, but it can also be convenient, like in this case.)

avatar image Lethil Eric5h5 · Oct 15, 2015 at 10:57 PM 0
Share

Awesome. That is great news. 15 years of development background, but still a newb to graphics pipelines. You just made my day.

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

35 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Different prefabs with same mesh but different textures(materials). 1 Answer

Changing material with custom shader while instantiating prefab at runtime leads to change in color of all the instances 1 Answer

Prefab Material 0 Answers

Prefab material 1 Answer

How can I set the material on an instance after creating it? 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