mirror of https://github.com/tuyoogame/YooAsset
Update Basic Sample
parent
2381b67312
commit
7c1e1ab593
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
@ -6,7 +6,7 @@ using UnityEngine.U2D;
|
|||
using UnityEngine.UI;
|
||||
using YooAsset;
|
||||
|
||||
public class Game1Scene : MonoBehaviour
|
||||
public class GameScene1 : MonoBehaviour
|
||||
{
|
||||
public GameObject CanvasRoot;
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class Game1Scene : MonoBehaviour
|
|||
#if UNITY_WEBGL
|
||||
{
|
||||
var rawImage = CanvasRoot.transform.Find("background").GetComponent<RawImage>();
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetAsync<Texture>("bg");
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetAsync<Texture>("tex_bg");
|
||||
_cachedAssetOperationHandles.Add(handle);
|
||||
handle.Completed += (AssetOperationHandle obj) =>
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ public class Game1Scene : MonoBehaviour
|
|||
#else
|
||||
{
|
||||
var rawImage = CanvasRoot.transform.Find("background").GetComponent<RawImage>();
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetSync<Texture>("bg");
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetSync<Texture>("tex_bg");
|
||||
_cachedAssetOperationHandles.Add(handle);
|
||||
rawImage.texture = handle.AssetObject as Texture;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class Game1Scene : MonoBehaviour
|
|||
#if UNITY_WEBGL
|
||||
{
|
||||
var logoImage = CanvasRoot.transform.Find("title/logo").GetComponent<Image>();
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetAsync<Sprite>("logo");
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetAsync<Sprite>("tex_logo");
|
||||
_cachedAssetOperationHandles.Add(handle);
|
||||
handle.Completed += (AssetOperationHandle obj) =>
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ public class Game1Scene : MonoBehaviour
|
|||
#else
|
||||
{
|
||||
var logoImage = CanvasRoot.transform.Find("title/logo").GetComponent<Image>();
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetSync<Sprite>("logo");
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetSync<Sprite>("tex_logo");
|
||||
_cachedAssetOperationHandles.Add(handle);
|
||||
logoImage.sprite = handle.AssetObject as Sprite;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class Game1Scene : MonoBehaviour
|
|||
var btn = CanvasRoot.transform.Find("load_scene").GetComponent<Button>();
|
||||
btn.onClick.AddListener(() =>
|
||||
{
|
||||
YooAssets.LoadSceneAsync("Game2");
|
||||
YooAssets.LoadSceneAsync("GameScene2");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ public class Game1Scene : MonoBehaviour
|
|||
// 加载背景音乐
|
||||
{
|
||||
var audioSource = CanvasRoot.transform.Find("music").GetComponent<AudioSource>();
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetAsync<AudioClip>("town");
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetAsync<AudioClip>("music_town");
|
||||
_cachedAssetOperationHandles.Add(handle);
|
||||
await handle.Task;
|
||||
audioSource.clip = handle.AssetObject as AudioClip;
|
|
@ -6,7 +6,7 @@ using UnityEngine.U2D;
|
|||
using UnityEngine.UI;
|
||||
using YooAsset;
|
||||
|
||||
public class Game2Scene : MonoBehaviour
|
||||
public class GameScene2 : MonoBehaviour
|
||||
{
|
||||
public GameObject CanvasRoot;
|
||||
private readonly List<AssetOperationHandle> _cachedAssetOperationHandles = new List<AssetOperationHandle>(1000);
|
||||
|
@ -41,7 +41,7 @@ public class Game2Scene : MonoBehaviour
|
|||
#if UNITY_WEBGL
|
||||
{
|
||||
var rawImage = CanvasRoot.transform.Find("background").GetComponent<RawImage>();
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetAsync<Texture>("bg");
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetAsync<Texture>("tex_bg");
|
||||
_cachedAssetOperationHandles.Add(handle);
|
||||
handle.Completed += (AssetOperationHandle obj) =>
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ public class Game2Scene : MonoBehaviour
|
|||
#else
|
||||
{
|
||||
var rawImage = CanvasRoot.transform.Find("background").GetComponent<RawImage>();
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetSync<Texture>("bg");
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetSync<Texture>("tex_bg");
|
||||
_cachedAssetOperationHandles.Add(handle);
|
||||
rawImage.texture = handle.AssetObject as Texture;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class Game2Scene : MonoBehaviour
|
|||
var btn = CanvasRoot.transform.Find("load_scene").GetComponent<Button>();
|
||||
btn.onClick.AddListener(() =>
|
||||
{
|
||||
YooAssets.LoadSceneAsync("Game1");
|
||||
YooAssets.LoadSceneAsync("GameScene1");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class Game2Scene : MonoBehaviour
|
|||
// 加载背景音乐
|
||||
{
|
||||
var audioSource = CanvasRoot.transform.Find("music").GetComponent<AudioSource>();
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetAsync<AudioClip>("town");
|
||||
AssetOperationHandle handle = YooAssets.LoadAssetAsync<AudioClip>("music_town");
|
||||
_cachedAssetOperationHandles.Add(handle);
|
||||
yield return handle;
|
||||
audioSource.clip = handle.AssetObject as AudioClip;
|
|
@ -11,7 +11,7 @@ internal class FsmPatchDone : IFsmNode
|
|||
PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.PatchDone);
|
||||
Debug.Log("补丁流程更新完毕!");
|
||||
|
||||
YooAsset.YooAssets.LoadSceneAsync("Game1");
|
||||
YooAsset.YooAssets.LoadSceneAsync("GameScene1");
|
||||
}
|
||||
void IFsmNode.OnUpdate()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue