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 chronos · Jan 20, 2012 at 05:15 PM · mapscroll

how to make a texture scroll on an object?

I'm trying to make a map for mobile game where the user scrolls on the map of the planet in a loop, so if u scroll to the left edge you will start seeing the right edge and so on. it works fine by rotating the object when input key is pressed but i want to rotate the texture on the object not the object itself. or any other solution. any help would be appreciated.

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 Fattie · Jan 20, 2012 at 10:54 PM 0
Share

In a word - simply change the offset. Just try it in the editor so you get the idea.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by digitalConundrum · Jan 20, 2012 at 06:20 PM

Meltdown's answer would work, though you could also animate the texture scrolling by changing the tiling to a lower amount (perhaps x=.5,y=.5) and then increment or decrement the offset values to cause the texture to scroll without having to move the actual object.

here is a sample script I wrote in an old project to create a pulsating beam by scrolling the texture on a linerenderer based on time and a constant value. You could adapt this approach to your project by changing it to rely on time.deltaTime*input instead of a constant value.

 public class beamScroll : MonoBehaviour {
     LineRenderer thisRenderer;
 
     // Use this for initialization
     void Start () {
         thisRenderer = gameObject.GetComponent<LineRenderer>();
     }
     
     // Update is called once per frame
     void Update () {
         thisRenderer.material.mainTextureOffset = new Vector2(thisRenderer.renderer.material.mainTextureOffset.x + .25f * Time.deltaTime,
                 thisRenderer.renderer.material.mainTextureOffset.y + .25f * Time.deltaTime);
     }
 }

Hope this helps!

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 Meltdown · Jan 20, 2012 at 06:09 PM

Very easy.

Create one really long plane. Apply your texture to it, then on the material settings tile the texture on the plane so it repeats many times. Then when your user scrolls this plane, the texture scrolls.

Do not worry about having a plane that is say 10000 units long and is tiled, very little performance impact.

Also make sure the texture's import settings support repeating.

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 chronos · Jan 20, 2012 at 11:06 PM

OK thanks a lot for the help i got it to work using void Update () { float direction = Input.GetAxis("Horizontal"); if (direction != 0) {

         Vector2  offset = renderer.material.GetTextureOffset("_MainTex");
         float xOffset = offset.x;
         renderer.material.SetTextureOffset("_MainTex", new Vector2(xOffset + direction * scrollSpeed ,0));
          
     }

but my problem now is there is another circle object on top of the plane, and when i scroll the texture on the plane I want the circle to stay in the relative position. I tried to update the position of the circle by the offset of the plane but these two variables are not linearly correlated, so the circle does not update correctly. any ideas?

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 Meltdown · Jan 21, 2012 at 04:51 AM 0
Share

$$anonymous$$ake the plane and your circle game object seperate game objects. What you do on the plane should do nothing to the circle object.

avatar image digitalConundrum · Jan 21, 2012 at 06:37 AM 0
Share

I think what the OP means is that he wants the circle to stay in the same position relative to the texture scrolling, not in world-space (Like a YOU ARE HERE marker.) That's gonna take a little bit of math(and/or trial and error) You'll have to convert the world space to the 2d coordinates of the texture on the plane and then use the current offset to move your circle.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

ScrollView: scroll bar on left side instead of right? 1 Answer

I just wanna display my data in list view but i am not finding the solution, in unity how can we create list view..??? 3 Answers

Terrain Texture Issue? 1 Answer

ListView scrolling with swipe 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