• 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 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
Add comment · 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 ins$$anonymous$$d?

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

is there anyway to make a texture seamless at runtime through script 0 Answers

Can I do this in Unity without importing textures? 1 Answer

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

What scale value is necessary for get 1\2 part of the original? 1 Answer

Texture/Material changes but is not reflected in the game world 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges