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 laurienash · Jun 23, 2016 at 11:51 AM · c#asyncloadlevelasyncload level

Load level async freezing animation for several seconds

Hi - I'm building a game for android. When the screen is swiped on the title screen, I'm using load level async. So whilst the next scene is loading - I move an object across the screen smoothly, and once it's moved to it's final position and the level is loaded, it switches smoothly to the title scene.

The problem I'm having is that the object moves for the first few frames, then freezes for several seconds, and then carries on moving.

I've been googling for a long time, and have tried adding Application.backgroundLoadingPriority = ThreadPriority.Low; But I can't work out how to make the scrolling smooth?

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class AsyncLoad : MonoBehaviour
 {
     
     private Vector2 StartPos;
     private int SwipeID = -1;
     
     public GameObject overlayTerrain;
     public GameObject textMain;
     public GameObject buttonAbout;
     public GameObject buttonCredits;
     Vector3 startPos = new Vector3 (-4.5f, -16f, 237.5f);
     Vector3 endPos = new Vector3 (-4.5f, -16f, 267.5f);
 
     public float speed = 1.0F;
     private float startTime;
     private float journeyLength;
     public Transform startMarker;
     public Transform endMarker;
     public Transform startButton;
     public Transform endButton;
     public GameObject canvasText;
     
     
     void Start()
     {
         textMain.SetActive(true);
         buttonAbout.SetActive(true);
         buttonCredits.SetActive(true);
 
         startTime = Time.time;
         journeyLength = Vector3.Distance(startMarker.position, endMarker.position);
 
         Application.backgroundLoadingPriority = ThreadPriority.Low; 
     }
     
     
     void OnSwipeUp()
     {
         StartCoroutine (LoadMainLevel());
     }
     
     public IEnumerator LoadMainLevel()
     {
         yield return null;
 
         var loadingOperation = Application.LoadLevelAsync(1);
         loadingOperation.allowSceneActivation = false;
         startTime = Time.time;
         float fracJourney = 0;
         print ("start "+Time.time );
         while(fracJourney<1f)
         {
             float distCovered = (Time.time - startTime) * speed;
 
             // to travel the whole distance will take 'journeyLength/speed' seconds
             fracJourney = distCovered / journeyLength;
             print ("fj "+fracJourney + ":"+Time.time);
 
             overlayTerrain.transform.position = Vector3.Lerp(startMarker.position, endMarker.position, fracJourney);
             canvasText.transform.position = Vector3.Lerp(startButton.position, endButton.position, fracJourney);
 
 
             print ("done "+loadingOperation.isDone+ ":"+Time.time);
         
             yield return null;
         }
 
         loadingOperation.allowSceneActivation = true;
         print ("end"+ ":"+Time.time);
         yield return loadingOperation;
     }
 }



(I've taken out the update so it's quicker to read the relevant parts of the script - in the update it's just checking if the screen has been swiped using touch.input)

Does anyone know if I've missed anything so that I can get the movement of the object to run smoothly?

Best, Laurien

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

0 Replies

· Add your reply
  • Sort: 

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

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

Loading Bar in Different Scenes 1 Answer

Got a problem with Async! 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Title Screen loading animation not looped 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