public override bool Update()
        {
            if (m_Request != null)
            {
                return(false);
            }

            LoadedAssetBundle bundle = AssetBundleLoad.GetLoadedAssetBundle(m_AssetBundleName, out m_DownloadingError);

            if (bundle != null)
            {
#if UNITY_5_3 || UNITY_5_4
                m_Request = SceneManager.LoadSceneAsync(m_LevelName, m_IsAdditive ? LoadSceneMode.Additive : LoadSceneMode.Single);
#else
                if (m_IsAdditive)
                {
                    m_Request = Application.LoadLevelAdditiveAsync(m_LevelName);
                }
                else
                {
                    m_Request = Application.LoadLevelAsync(m_LevelName);
                }
#endif
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 2
0
        //public static string OverrideBaseDownloadingURLWithPlatform (string bundleName)
        //{
        //	return AssetsUtility.GetPlatformName () + "/" + bundleName;
        //}

        public static T LoadPrefab <T> (string path) where T : UnityEngine.Object
        {
#if UNITY_EDITOR
            string strName = "Assets/" + path + ".prefab";
            T      go      = AssetDatabase.LoadAssetAtPath <T> (strName);

            return(go);
#else
            Console.Instance().Debug(path);
            path = path.ToLower();
            T go = AssetBundleLoad.LoadGameObject(path) as T;
            return(go);
#endif
        }
        // Returns true if more Update calls are required.
        public override bool Update()
        {
            if (m_Request != null)
            {
                return(false);
            }

            LoadedAssetBundle bundle = AssetBundleLoad.GetLoadedAssetBundle(m_AssetBundleName, out m_DownloadingError);

            if (bundle != null)
            {
                ///@TODO: When asset bundle download fails this throws an exception...
                m_Request = bundle.m_AssetBundle.LoadAssetAsync(m_AssetName, m_Type);
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 4
0
        public static GameObject LoadMaterialPrefabs(string path)
        {
#if UNITY_EDITOR
            //string strName = "Assets/Prefabs/" + path + ".prefab";
            //T go = AssetDatabase.LoadAssetAtPath<T> (strName);
            //			Debug.Log (path);
            path = path.ToLower();
            GameObject go = AssetBundleLoad.LoadGameObject(path) as GameObject;
            //         string strName = "Assets/" + path + ".prefab";
            //T go = AssetDatabase.LoadAssetAtPath<T> (strName);
            go.GetComponent <Renderer> ().sharedMaterial.shader = Shader.Find(go.GetComponent <Renderer> ().sharedMaterial.shader.name);
            return(go);
#else
            //string strName = ASSETBUNDLE_PATH + path;
            //Debug.Log(strName);
            //GameObject.Find ("Console").GetComponent <Text>().text += "\n" + strName;
            path = path.ToLower();
            GameObject go = AssetBundleLoad.LoadGameObject(path) as GameObject;
            go.GetComponent <Renderer>().sharedMaterial.shader = Shader.Find(go.GetComponent <Renderer>().sharedMaterial.shader.name);

            return(go);
#endif
        }
Esempio n. 5
0
        IEnumerator InitializeLevelAsync(string sceneName, UnityEngine.SceneManagement.LoadSceneMode mode)
        {
            yield return(null);

            AssetBundleLoadOperation operation;

            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder("scenes/", 3);
            stringBuilder.Append(sceneName);
            stringBuilder.Append(".unity3d");
            switch (mode)
            {
            case UnityEngine.SceneManagement.LoadSceneMode.Single:

                operation = AssetBundleLoad.LoadLevelAsync(stringBuilder.ToString(), sceneName, false);
                if (operation == null)
                {
                    yield break;
                }
                yield return(StartCoroutine(operation));

                break;

            case UnityEngine.SceneManagement.LoadSceneMode.Additive:
                operation = AssetBundleLoad.LoadLevelAsync(stringBuilder.ToString(), sceneName, true);
                if (operation == null)
                {
                    yield break;
                }
                yield return(StartCoroutine(operation));

                break;
            }

            //string strName = "Assets/" + sceneName + ".unity";
            //AssetBundleCreateRequest bundleLoadRequest = AssetBundle.LoadFromFileAsync (Path.Combine (STREAMING_PATH, sceneName));
            //yield return bundleLoadRequest;

            //AssetBundle myLoadedAssetBundle = bundleLoadRequest.assetBundle;
            //if (myLoadedAssetBundle == null) {
            //	Debug.Log ("Failed to load AssetBundle!");
            //	yield break;
            //}

            //var assetLoadRequest = myLoadedAssetBundle.LoadAssetAsync<GameObject> ("MyObject");
            //yield return assetLoadRequest;

            //GameObject prefab = assetLoadRequest.asset as GameObject;
            //Instantiate (prefab);
            //myLoadedAssetBundle.Unload (false);

            //asyncOperation.allowSceneActivation = false;
            //while (!asyncOperation.isDone) {

            //	//Output the current progress
            //	Debug.Log ("Loading progress: " + (asyncOperation.progress * 100) + "%");

            //	// Check if the load has finished
            //	if (asyncOperation.progress >= 0.9f) {
            //		//Change the Text to show the Scene is ready
            //		Debug.Log ("Press the space bar to continue");
            //		//Wait to you press the space key to activate the Scene
            //		if (Input.GetKeyDown (KeyCode.Space))
            //			//Activate the Scene
            //			asyncOperation.allowSceneActivation = true;
            //	}

            //	yield return null;
            //}
            ////if current scene is the now loaded scene, set it to variety
            //UnityEngine.SceneManagement.Scene scene =
            //UnityEngine.SceneManagement.SceneManager.GetActiveScene ();

            //if (scene.name == sceneName) {
            //	m_currentScene = scene;
            //}
        }