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 Jadugara · May 04, 2012 at 09:55 PM · animationuvoffset

Material.mainTextureOffset,...how do I use this?

I'm trying to making my texture animate by scrolling it rapidly from side to side... I've found several answers here, all pointing to "Material.mainTextureOffset", which then brings up a page that shows multiple lines of scripting...

I'm VERY new to Unity, and I'm not sure how I'm supposed to use this code... Do I cut and paste it into a certain shader? If it's the Diffuse shader, Unity doesn't seem to let me access the script...

Please, I'd be very appreciative if someone would explain to me exactly how I use Material.mainTextureOffset to make my textures scroll...

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
Best Answer

Answer by Berenger · May 04, 2012 at 10:08 PM

Inside unity's code, when the object is drawn, the material will give that offset to the shader. You don't need to change the shader what so ever in that case.

What you need to do though, is a a reference to that material, probably in a class inheriting from MonoBehaviour (if your using javascript, it means a regular script). Then affect a new value to the property material.mainTextureOffset. Now, you want this to be animated, so you'll need to give a new value to mainTextureOffset each times you want the result to change.

If you need more details, I'll can explain further.

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 Jadugara · May 04, 2012 at 10:47 PM 0
Share

Thanks Bérenger, I'd certainly love more details... Without help, I'm worried that this may be beyond me at the moment...

I'm an environment artists who has gotten used to using Gamebryo (in my last project), which simply sees that you've animated the UVs of an object when you import it... And in the game, it simply works...

I'm not used to having to script basic UV settings to make them work, so this may be a bit tough for me...

I'd really appreciate if you can walk me through the steps...

O$$anonymous$$,..so I've started by opening the material in the Inspector in Unity, and I have applied an Offset of 1 in the "Y" direction (which I'm assu$$anonymous$$g means "up")...

Now that I've done that, where do I access the interface in Unity to make a reference to that material (in other words, how do I get to where I implant and affect the $$anonymous$$aterial.mainTextureOffset code)?

avatar image Berenger · May 05, 2012 at 02:32 PM 0
Share

I added a scene example to the wiki, but read the following first.

Each gameObject in unity contains a collection of components. You have the built-in like Transform, $$anonymous$$eshRenderer, BoxCollider, or the scripts for more control.

When you attach a script to a gameobject, the code inside will be executed on this instance at the proper time. You can access the other components of the gameobject with some properties provided by Unity, among other ways.

In that case, you need access to the renderer, which contains the material. Then, you can modify mainTextureOffset. It takes a Vector2.

I hope it helps you.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

texture offset question 2 Answers

UV Animation export from Maya? 1 Answer

Eyes animation texture problem 0 Answers

Can u3 support 3dmax physical model directly importting? 0 Answers

Adding a UV offset to tex2dproj. 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