728x90
Unirx 로 에셋 번들 다운받기를 써봅시다
네이버 구글 다 뒤져도 없어서 직접 제작.. 이 내용에 대한 튜토리얼은 -_- 전세계 최초라고!
예제
#if !(UNITY_METRO || UNITY_WP8)
using UnityEngine;
using System.Collections;
using UniRx;
public class TestWWW : MonoBehaviour {
void Start()
{
//StartCoroutine (DownLoadState ());
StartCoroutine (DownLoadState_Unirx ());
}
// unirx 로 다운 받기
IEnumerator DownLoadState_Unirx()
{
while (!Caching.ready)
yield return null;
ObservableWWW.LoadFromCacheOrDownload("https://dl.dropboxusercontent.com/u/238284954/Rem.unity3d", 0, null).Subscribe(x => NewObject(x.LoadAsset("TestRem")), ex => Debug.LogException(ex));
}
// 기본 다운 받기
IEnumerator DownLoadState()
{
while (!Caching.ready)
yield return null;
WWW www = WWW.LoadFromCacheOrDownload ("https://dl.dropboxusercontent.com/u/238284954/Rem.unity3d", 0);
yield return www;
if (www.error != null)
yield break;
else
NewObject (www.assetBundle.LoadAsset("TestRem"));
}
void NewObject(Object obj)
{
GameObject tmp = Instantiate (obj, Vector3.zero, Quaternion.identity) as GameObject;
foreach(Transform t in tmp.GetComponentsInChildren<Transform>())
if(t.gameObject.GetComponent<Renderer>() != null)
t.gameObject.GetComponent<Renderer>().material.shader = Shader.Find(t.gameObject.GetComponent<Renderer>().material.shader.name);
Debug.Log("obj name " + obj.name);
}
}
#endif
728x90
'프로그래밍 > Unity' 카테고리의 다른 글
| [Unity3D] Enable 과 Awake (0) | 2018.01.03 |
|---|---|
| public 변수를 컴포넌트에서 읽기 전용으로 하기 (0) | 2017.11.16 |
| UniRx - 튜토리얼 2 (0) | 2016.09.09 |
| []배열 꿀 ArrayUtillity (0) | 2014.12.17 |
| 에셋 번들 빌드 시 계속 1KB 로 생성될 때 (0) | 2014.12.16 |
댓글