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 /
This question was closed Jul 03, 2013 at 08:12 PM by Em3rgency for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Em3rgency · Jul 02, 2013 at 05:37 PM · texturescaling

Scaling/Offsetting a texture based on object size to match up with other objects

I have a 3d block. I can change the blocks scale in all 3 dimensions during runtime. Currently, the block has a material with a texture applied to it. Naturally, when I scale the block, the texture stretches with it.

I would like for the texture to be uniform, regardless of the block size. So if I place two blocks of different size next to each other, I'd like the textures to match up.

Normally, I'd work out something like this by myself, just playing around with different values, however, I haven't really messed around with textures, at all, so I find them a bit confusing. For instance, I realize a texture is an image with 2 dimensions, but my objects scale in 3 dimensions, and I can't wrap my head around how to scale the texture properly in this circumstance.

Any help on this would be appreciated.

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

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by Em3rgency · Jul 03, 2013 at 08:11 PM

Solved the whole problem with this: http://www.blog.radiator.debacle.us/2012/01/joys-of-using-world-space-procedural.html

This is what I wanted all along.

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 Quillicit · Jul 03, 2013 at 06:02 AM

For a block, something along these lines should work:

 using UnityEngine;
 using System.Collections;
 
 public class ScaleTexture : MonoBehaviour {
     void Update() {
         float scaleX = transform.localScale.x;
         float scaleY = transform.localScale.y;
         renderer.material.mainTextureScale = new Vector2(scaleX, scaleY);
     }
 }
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 Em3rgency · Jul 03, 2013 at 07:47 AM 0
Share

No. Please actually read my question before posting an answer. All the blocks are irregularly shaped, NOT CUBES. And they scale in all 3 dimensions, not just x and y.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

Unity 3 scales my iPhone/iPad icons to nonstandard sizes 0 Answers

Assigning UV Map to model at runtime 0 Answers

Scalling animation is blurring frame texture 1 Answer

Scaling bg gui texture without stretching it in unity 4.6 0 Answers

scaling a gui texture 2 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