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 AniketShark · Sep 22, 2012 at 07:32 AM · materialstextures

can we use same material and same mesh with different texture scaling in the project.....???????

Hi Everyone, Sorry in advance if u dont understand my english well...

In my game... i am making platforms using one mesh (plane with 4 vertices) which is 1*1 (unity units) block and i have applied a material to it with tillable texture.

So suppose i want to make platform of 20:1 (width:height), for that i have two options: 1> Duplicate the mesh i said above 20 times.!!! or 2> Scale Assets local scale to (20,1,0) and use materials texture scaling property and put Xscale to 20.....!!!

the Obvious choice for me is to use 2nd option as it saves 19*4 vertices from rendering....!!!!

Now if i want to make platform of 5:1 with the same material and same mesh???? the problem lies here....

if i use the same material from the first problem then the 5:1 platform texture looks like it is squeezed.... so if i change the texture scaling of the material in 5:1 platform it stratches the texture in the 20:1 platform...... so my question is>>>>>>>>>

can we use same material and same mesh with different texture scaling in the project.....???????

sorry if u dont understand it at first.... but seriously this problem is getting into my nerves..... i want to optimize my game....!!!!

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
1

Answer by whydoidoit · Sep 22, 2012 at 07:51 AM

Well you need to use "another choice" if you want to use the same material. Modify the mesh of the other platforms and set their vertices to be bigger with uvs to match - this is a lot less hard than it sounds. Then when you use the texture it will tile because you have tiling turned on and then tile again because the uvs of your new mesh are greater than 1.

You have two choices around doing this:

  • Do it at runtime based on some properties in a script that you attach to the platform

  • Do it in the editor and save the updated mesh as an asset or modify the attached mesh but make sure that it is a copy unique to this platform.

Your planes are simple - so there will be 6 vertices and 6 uvs to update (2 triangles to make 1 plane). If you make the platform 20 world units long then just modify the vertices and make the uvs match the 2d version of the vertex points. So if you make the uv of a point (20,0) it will tile 20 times before reaching that world point. A square plane 20 wide might then look like this for the vertices and uvs (just for an example - it would be easier to construct the array by code):

   var vertices = new {} [
    new Vector3(0,0,0),
    new Vector3(20,0,0),
    new Vector3(0,20,0),
    new Vector3(20,0,0),
    new Vector3(20,20,0),
    new Vector3(0,20,0)
   };

   var uvs = new {} [
    new Vector2(0,0),
    new Vector2(20,0),
    new Vector2(0,20),
    new Vector2(20,0),
    new Vector2(20,20),
    new Vector2(0,20)
   };



It is actually not as hard as it sounds.

Here is the documentation on vertices and uvs. You will use the platforms MeshFilter.mesh to access the mesh data. Changing the sharedMesh changes it for ALL objects - so operating on mesh is safer.

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 AniketShark · Sep 22, 2012 at 03:02 PM 0
Share

hey!!!! thanks mike!! i will give it a try and get back to u soon!!!!!

avatar image whydoidoit · Sep 22, 2012 at 03:06 PM 0
Share

Just a note: if you end up just constructing a mesh from scratch then you also need to set the triangles array to refer to your vertices and uvs.

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

10 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

Related Questions

How to create a shader that makes the texture look far away? 0 Answers

Help with GUI, Textures and Materials (Health Circle) 1 Answer

How to quickly change the texture on a material? 1 Answer

Applying materials/textures on imported fbx, dae, etc 2 Answers

How do I change the default material size in ProBuilder? 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