• 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
Question by TheDawningLegend · Aug 22, 2015 at 08:33 PM · texturematerialscalescaling

Scaling material without saving scale on original material

Hello, I am looking for a way to scale a material on a game object without scaling all the same materials in the scene. By default, my material is 1x1. I scale it to 2x5 on a game object. But i then realize that all of the game objects that have that same materials on will be scaled 2x5 as well, and thats what I am trying to avoid.

Is there someting i can do in the mesh renderer?

(If you dont understand, i mean to make a gameobject unique material scaling without making a whole new material)

Thanks for the help :)

Comment

People who like this

0 Show 4
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 VesuvianPrime · Aug 21, 2015 at 07:50 PM 0
Share

Can you have the texture as a child to your GameObject and scale the child instead?

avatar image TheDawningLegend · Aug 21, 2015 at 08:49 PM 0
Share

I am trying to scale the material, not the gameobject

avatar image VesuvianPrime · Aug 21, 2015 at 09:13 PM 0
Share

I understand. You would be able to keep the scale of your parent GameObject as whatever you want, while changing the scale of the child texture.

avatar image TheDawningLegend · Aug 21, 2015 at 10:02 PM 0
Share

I see what you mean, but the material's scale will still be applied to the material in the assets folder...

What do i have to do if i want a cube with the texture scaled 1x2 and another cube that its texture is scaled 1x1 with the exact same texture? what it does is that both is 1x2 or 1x1, thats my issue because the last scale i put on one will be applied on every gameobject that has that texture...

Thats why im talking about a "gameobject unique texture scale" setting, so that every cube in the scene has its independant texture scale, or else every cube has the same texture scale that is taken from the material in the assets folder

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Umresh · Aug 24, 2015 at 09:06 AM

You can attach the material at run time using script and set the offset. In this wat instance of the material is created and you can have different scale for different cubes

 if(this.GetComponent<MeshRenderer>())
         {
             MeshRenderer _meshRenderer = this.GetComponent<MeshRenderer>();
             _meshRenderer.material = _material;
             _meshRenderer.material.mainTextureScale = Vector2.one *2;//Your desired scale
         }
Comment

People who like this

0 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 TheDawningLegend · Aug 24, 2015 at 07:00 PM 0
Share

Thanks, thats perfect!

But is there a meshRenderer.material.mainTextureScale option in the inspector?

avatar image Umresh · Aug 25, 2015 at 05:09 AM 0
Share

Yes it's named as tiling.

avatar image TheDawningLegend · Aug 25, 2015 at 01:20 PM 0
Share

In the mesh renderer component? Because if it is in the material itself, it will bring the issue again...

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Stuck with scaling an object 1 Answer

Why does my model not display proper material? 2 Answers

Model replacement via c# Script 0 Answers

Help with mesh Texture Seems,Texture Showing Seems 0 Answers

How do I make a mesh texture transparent, but not for some objects? 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