using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class TestChangeScene : MonoBehaviour {
public string targetScene;
void Start ()
{
Resources.UnloadUnusedAssets();
}
void Update()
{
if(Input.GetKeyDown(KeyCode.Space))
{
TriggerSceneChange();
}
}
public void TriggerSceneChange()
{
UIWidget[] widgets = Resources.FindObjectsOfTypeAll<UIWidget>();
foreach(UIWidget tmp in widgets)
{
Debug.Log("destroying : " + tmp.name);
Destroy(tmp);
}
StartCoroutine(unload());
}
IEnumerator unload()
{
yield return new WaitForEndOfFrame
(); Resources.UnloadUnusedAssets();
Application.LoadLevel(targetScene);
}
}