Log in or register to post comments

Loadlevelasync is not Loading between the scenes

January 26, 2014 - 11:43am #1
HI, 
 
I have two scenes on login and a AR bookstore scene, I have implemented a Loadlevelasync in the login that schuld load the bookstore scene in the background , but It  still takes 25 sec of loading time between the scenes,
I have no 3D content in the scene , but i have almost 60 imagetargets the app is about 30mb.
 
Is there anybody In the forum who is familier with  Loadlevelasync and can it be used with the Vuforia API, because it seams that Vuforia will initalized the whole bookstore scene and not run in the background when loading the login scene.
 
 
My code for the loginmanager is down below, if anybody can spot a mistake or verify that is not possible to run  Loadlevelasync with the SDK 
I have Unity Pro, any also knowleage about the Vurforia Cloud Recognition, but still  I want the app to run with a local devicedatabase for fast detection .
 
Best Regards 
Daniel 
Simulacrum.dk
--------------------------------------------------------------------------------------------------------------------------------
 
using UnityEngine;
using System.Collections;
 
public class LoginManager : MonoBehaviour {
 
    public UIInput user;
    public UIInput password;
 
 
public UIInput Username;
public UIInput Password;
public UIInput email;
public UIInput name;
public AsyncOperation async;
public string level;
public UILabel errorLogin;
    public UILabel errorRegister;
public UILabel errorRegister2;
public UILabel errorRegister3;
 
    public Animation loginAnimation;
    public Animation registerAnimation;
 
 
 
 
    private void Awake() {
        instance = this;
 
    }
 
void Start()
{
 
StartCoroutine(loadCoroutine());
 
}
 
private IEnumerator loadCoroutine() {
  
       Debug.Log ("Loading starts");
 
       async = Application.LoadLevelAsync(level);
  yield return 0;
  async.allowSceneActivation = false;
}
 
         
       private void RequestLogin() {
 
Handheld.SetActivityIndicatorStyle(AndroidActivityIndicatorStyle.Large);
Handheld.StartActivityIndicator();
        StartCoroutine(Login(user.text,password.text));
 
 
    }
 
    private IEnumerator Login(string user, string password)
{
 
if (user == "" || password == "" )
NGUITools.SetActive(errorLogin.gameObject, false);
else
{
   
       
        WWWForm newForm = new WWWForm();
 
        newForm.AddField("user", user);
newForm.AddField("password", password);
 
        WWW w = new WWW("XXXXXXXXXXXXXXX", newForm);
 
 
        while (!w.isDone) {
 
 
            yield return new WaitForEndOfFrame();
 
 
        }
 
        if (w.error != null) { 
            Debug.LogError(w.error); 
        }
 
        //string[] param=w.text.Split(' ');
 
       if (w.text == "login-SUCCESS")
 
                   if (async.isDone) {
                Debug.Log ("Loading done - ACTIVATE SCENE");
                //yield return new WaitForSeconds(0);
                async.allowSceneActivation = true;
               Handheld.StopActivityIndicator();
 
            }
            yield return 0; 
        }  
 
 
        else {
            NGUITools.SetActive(errorLogin.gameObject, true);
 
        }
 
    }
 
}
 
    public void RequestRegistration() {
        StartCoroutine(RegisterProfile(Username.text, Password.text,name.text,email.text));
    }
 
    public IEnumerator RegisterProfile(string Username, string Password,string name,string email) {
        NGUITools.SetActive(errorRegister2.gameObject, false);
if (Username == "" || Password == "" || name == "" || email == "" )
 
NGUITools.SetActive(errorRegister2.gameObject, true);
 
else
{
        WWWForm newForm = new WWWForm();
 
        newForm.AddField("user", Username);
newForm.AddField("password", Password);
newForm.AddField("name", name);
newForm.AddField("email", email);
WWW w = new WWW("XXXXXXXXXXXXXXXXXXXXXXXX", newForm);
 
 
 
        while (!w.isDone)
        {
            yield return new WaitForEndOfFrame();
        }
 
        if (w.error != null)
        {
            Debug.LogError(w.error);
        }
 
     
       
        string res = w.text.Trim();
        if (res.Equals("success"))
        {  
            ActiveAnimation.Play(registerAnimation, "regi", AnimationOrTween.Direction.Reverse);
 
//OnSelect();
            //ActiveAnimation.Play(loginAnimation, "translation_forward", AnimationOrTween.Direction.Reverse);
        }
        else
        {
 
            NGUITools.SetActive(errorRegister3.gameObject, true);
        }
 
    }
 
}
// void OnSelect ()
//    {
//        UIInput input = GetComponent<UIInput>();
//        
//        {
//                
//            input.text = ""; //clear field on click
//            input.label.text = ""; //clear field on click
//        }
     
}

Loadlevelasync is not Loading between the scenes

January 27, 2014 - 5:35am #3

HI David,

I need some more advice if it is okey.

I will go' for preloading the dataset in ARBook scene, when the user is in the login scene.

The question is still I  have two scenes but only one ARcamera in the ARBook scene, but if I move the ARcamera with the datasets to the login scene with KeepAlive check and do the LoadLevelAsync, then the AR camera don't work In ARBook scene I get a black scene.

My question is how is it possible to load the dataset in my loginmanager and keepItAlive when loading the ARBook scene.

and can I do it programmatically?, so I can balanced the loading time.

Best Regards

Daniel

 

 

 

 

 

Loadlevelasync is not Loading between the scenes

January 26, 2014 - 12:11pm #2

The delay is due to the large number of ImageTargets you're loading.

One technique that you can evaluate, is to load these in your initial scene, while the user is logging in, and persist the initialized ARCamera into the book store scene using the KeepAlive behavior - see: https://developer.vuforia.com/resources/dev-guide/special-options-unityKeeping Vuforia objects alive across multiple Unity scenes.

Alternatively, if you don't need all of the targets to be recognizeable at the same time, you can use multiple dataset that contain a smaller number of targets and load and activate these programmatically when they are needed.

Log in or register to post comments