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
19
Question by HolBol · Jun 17, 2010 at 09:00 PM · textureuvscrolling

Making textures Scroll/ animate textures

how do i get a set texture to scroll from left to right, and or change a materials image over time?

Comment
Add comment · Show 1
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 DaPacoTaco · Aug 04, 2014 at 09:04 PM 0
Share

Look back at my question please Fishman92

5 Replies

· Add your reply
  • Sort: 
avatar image
39
Best Answer

Answer by Tetrad · Jun 17, 2010 at 09:16 PM

http://www.unifycommunity.com/wiki/index.php?title=Animating_Tiled_texture

That script will step through a texture sheet. The important bit is this particular line of code

renderer.material.SetTextureOffset ("_MainTex", offset);

With that you can also write a script that animates offset over time smoothly. In fact, here's an example of one:

using UnityEngine; using System.Collections;

public class AnimatedUVs : MonoBehaviour { public int materialIndex = 0; public Vector2 uvAnimationRate = new Vector2( 1.0f, 0.0f ); public string textureName = "_MainTex";

 Vector2 uvOffset = Vector2.zero;

 void LateUpdate() 
 {
     uvOffset += ( uvAnimationRate * Time.deltaTime );
     if( renderer.enabled )
     {
         renderer.materials[ materialIndex ].SetTextureOffset( textureName, uvOffset );
     }
 }

}

For changing the image, the most efficient way is to use a tiling texture, but if you must use different source images, you can use this:

http://unity3d.com/support/documentation/ScriptReference/Material-mainTexture.html

I.e.

renderer.material.mainTexture = myTexture;
Comment
Add comment · Show 8 · 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 Bentford · Sep 02, 2010 at 01:15 PM 0
Share

awesome!!.......

avatar image bernardfrancois · Jun 06, 2011 at 11:43 AM 0
Share

Thanks. This is a lot easier than having to set all the vertex UVs separately!

avatar image hirenkacha · Jul 06, 2012 at 04:33 AM 0
Share

Great work....!! Worked for me too....

avatar image Sanky · Jan 26, 2013 at 08:03 AM 0
Share

superb man you are awesome thanks for this solution (y)

avatar image mikelewek · Jul 26, 2014 at 04:52 PM 1
Share

The top link is no longer accessible. Here's a replacement: Animating Tiled Texture Wiki Documentation

Show more comments
avatar image
3

Answer by zzeeshann · Jun 07, 2016 at 06:30 AM

 using UnityEngine;
 using System.Collections;
 
 public class ExampleClass : MonoBehaviour {
     public float scrollSpeed = 0.5F;
     public Renderer rend;
     void Start() {
         rend = GetComponent<Renderer>();
     }
     void Update() {
         float offset = Time.time * scrollSpeed;
         rend.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
     }
 }

This code is in C#

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
0

Answer by 3D-Magic-VR · Sep 01, 2011 at 10:46 PM

Hi, if you want animate multiple materials check this, hopes help you.

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
0

Answer by Dayradon · May 18, 2017 at 11:09 AM

file missing: http://www.unifycommunity.com/wiki/index.php?title=Animating_Tiled_texture file missing: http://www.youtube.com/watch?v=uR5QVTEI8X

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
0

Answer by refardeon · May 05, 2019 at 04:47 PM

unity wiki link is now: http://wiki.unity3d.com/index.php?title=Animating_Tiled_texture

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

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

12 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

Related Questions

Assigning UV Map to model at runtime 0 Answers

Initialize UV offset with UV scrolling script 1 Answer

Shader and Texture Scrolling depending on Direction 1 Answer

Using Rpg maker XP Tiles (2D Tile System) 2 Answers

Automatic mesh combine and texture atlasing 4 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