Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 aditya · Apr 25, 2016 at 06:02 AM · c#imagerectlow fpsraw

Changing RawImage position killing frame rate on Android

Well the question is self explanatory, i m changing the RawImage.position in Update method and this is killing my frame rate and one of my level is not changing position as it doesn't have any RawImage in it and it is running smoothly, this means it RawImage.position which is dropping my frame rate ... basically i want background of my 2D game to move in random directions so i used RawImage and changing its position through script ... below is my script ...

     public RawImage cieRawImageTop, cieRawImageBottom;
 
     private Vector2 offsetTop, offsetBottom;
     private float speed;
     private Rect tempRectTop, tempRectBottom;
     private uint currNum, newNum;
 
     void Start(){
         speed = 0.0002f;
         setTopDirection ();
     }
 
     void Update () {
         tempRectTop.position = cieRawImageTop.uvRect.position + offsetTop;
         cieRawImageTop.uvRect = tempRectTop;
         tempRectBottom.position = cieRawImageBottom.uvRect.position + offsetBottom;
         cieRawImageBottom.uvRect = tempRectBottom;
     }
 
     void setTopDirection(){
         offsetTop = setDirection ();
         Invoke ("setBottomDirection", 1f);
     }
 
     void setBottomDirection(){
         offsetBottom = setDirection ();
         Invoke ("setTopDirection", 4f);
     }
 
     Vector2 setDirection(){
         Vector2 newOffset = new Vector2 (0f, 0f);
         newNum = (uint)Random.Range (0, 8);
         switch (newNum) {
         case 0:
             newOffset.x = 0f;
             newOffset.y = -speed;
             break;
         case 1:
             newOffset.x = speed;
             newOffset.y = -speed;
             break;
         case 2:
             newOffset.x = speed;
             newOffset.y = 0f;
             break;
         case 3:
             newOffset.x = newOffset.y = speed;
             break;
         case 4:
             newOffset.x = 0f;
             newOffset.y = speed;
             break;
         case 5:
             newOffset.x = -speed;
             newOffset.y = speed;
             break;
         case 6:
             newOffset.x = -speed;
             newOffset.y = 0f;
             break;
         case 7:
             newOffset.x = newOffset.y = -speed;
             break;
         }
         return newOffset;
     }
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
0

Answer by aditya · Apr 25, 2016 at 07:21 AM

Okay ... i got it working myself ... so for anyone who facing same issue there are two things to consider here ... one is the size of your texture, the texture i used before was of size 800 - 1280 which i deducted to 360 - 640 and second and probably the most important, if you bring down the alpha of UI elements from unity editor (or play with this ALPHA thingy through scripts) this will kill your frame rate, so what i did is that i made texture with alpha pre decided and make the alpha full through unity editor

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

131 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 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 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 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 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 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 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 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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Component name for raw image. 1 Answer

UI Escape menu script not working. 2 Answers

C#: Generate Raw File from byte[]? 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