Skip to content

Instantly share code, notes, and snippets.

@baba-s
Created September 9, 2025 05:39
Show Gist options
  • Select an option

  • Save baba-s/3a4d0cc7e30007be8cde1c9d9c31830d to your computer and use it in GitHub Desktop.

Select an option

Save baba-s/3a4d0cc7e30007be8cde1c9d9c31830d to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Diagnostics;
using UnityEngine;
using UnityEngine.UI;
internal sealed class Example : MonoBehaviour
{
public Text m_versionText;
public Text m_text;
public int m_count = 1000;
private IEnumerator Start()
{
m_versionText.text = Application.unityVersion;
var path = $"{Application.streamingAssetsPath}/AssetBundles/texturebundle";
var sw = Stopwatch.StartNew();
for ( var i = 0; i < m_count; i++ )
{
var assetBundleRequest = AssetBundle.LoadFromFileAsync( path );
yield return assetBundleRequest;
var assetBundle = assetBundleRequest.assetBundle;
var assetAsync = assetBundle.LoadAssetAsync<Texture2D>( "Assets/texture.png" );
yield return assetAsync;
assetBundle.Unload( true );
}
sw.Stop();
m_text.text = $"{sw.Elapsed.TotalSeconds:0.0 秒}";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment