Created
September 9, 2025 05:39
-
-
Save baba-s/3a4d0cc7e30007be8cde1c9d9c31830d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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