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 ahsanI · Oct 28, 2013 at 07:44 AM · androidiphone

Question related to optimization in unity3d

Hi

I am new to unity, I am working on a 2d game. I have created a background that scrolls infinitely over time. For that I have created a plane as a game object and assign it a material and to that material I have assigned a texture. now I change offset of the texture every frame through a script. It looks fine when the game starts but if I let game running for about 30 mins or so it starts showing waves in the background here is my code

 public class BackgroundManager : MonoBehaviour {
     
     public int materialIndex = 0;
     public Vector2 uvAnimationRate = new Vector2( 0.0f, 1.0f );
     public string textureName = "_MainTex";
     public float speed = 0.5f;
     Vector2 uvOffset = Vector2.zero;
     
     // Use this for initialization
     void Start () {
 
     }
     
     // Update is called once per frame
     void Update () {
         uvOffset -= ( uvAnimationRate * Time.deltaTime * speed) ;
         if( renderer.enabled )
         {
             renderer.materials[ materialIndex ].SetTextureOffset( textureName, uvOffset );
         }
     }
 
 }

An Edit: I will be deploying this code to android/ios devices. please help

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 YoungDeveloper · Oct 28, 2013 at 09:39 AM 0
Share

If you know specific number for one background loop, you can $$anonymous$$us that amount each loop. Similar like circle angle 361 is the same as 1 degree. Zeroing the number wouldn't be the best option because it will result in slight "laag", because the actual number will be higher than that zero border.

 if(currentPosition > amountForOneLoop) currentPosition -= amountForOneLoop;

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by pointcache · Oct 28, 2013 at 08:36 AM

is it possible to use 2 planes and swap them with zeroing positions each loop?

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 ahsanI · Oct 28, 2013 at 09:09 AM 0
Share

@pointcache : I can use that approach as well but as for as I know this is better approach, also just an edit that I am deploying to android/ios

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

17 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 avatar image

Related Questions

Optimal # of Faces for many mesh scene for mobile 1 Answer

Changing the splash screen background color 3 Answers

GUI system for android? 1 Answer

What is static batching and dynamic batching? 0 Answers

Joystick trouble... 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