예제 #1
0
파일: AssetRes.cs 프로젝트: Luffyzeng/ZCode
        public override void LoadAsync()
        {
            State = ResState.Loading;

            mResLoader.LoadAsync <AssetBundle>(mOwnerBundleName, ownerBundle =>
            {
                if (ResMgr.IsSimulationModeLogic)
                {
#if UNITY_EDITOR
                    var assetPaths = UnityEditor.AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(mOwnerBundleName, Name);

                    Asset = UnityEditor.AssetDatabase.LoadAssetAtPath <Object>(assetPaths[0]);

                    State = ResState.Loaded;
#endif
                }
                else
                {
                    var assetBundleRequest = ownerBundle.LoadAssetAsync(Name);

                    assetBundleRequest.completed += operation =>
                    {
                        Asset = assetBundleRequest.asset;

                        State = ResState.Loaded;
                    };
                }
            });
        }
예제 #2
0
        // Use this for initialization
        void Start()
        {
            mResLoader.LoadAsync <AssetBundle>("gameobject", loadedBundle =>
            {
                var gameObj = loadedBundle.LoadAsset <GameObject>("gameobject");

                Instantiate(gameObj);
            });
        }
예제 #3
0
        // Use this for initialization
        IEnumerator Start()
        {
            yield return(new WaitForSeconds(2f));

            mResLoader.LoadAsync <AudioClip>("resources://hit", hitClip => {
                Debug.Log(hitClip.name);
                Debug.Log(Time.deltaTime);
            });

            Debug.Log(Time.deltaTime);

            mResLoader.LoadSync <GameObject>("resources://HomePanel");

            yield return(new WaitForSeconds(2f));

            mResLoader.LoadSync <AudioClip>("resources://bgm");

            mResLoader.LoadSync <AudioClip>("resources://Audio/hit");

            yield return(new WaitForSeconds(5f));

            mResLoader.ReleaseAll();
        }
예제 #4
0
        private void LoadDependencyBundleAsync(Action onAllLoaded)
        {
            int loadedCount = 0;

            var dependencyBundleNames = ResData.Instance.GetDirectDependencies(Name);

            if (dependencyBundleNames.Length == 0)
            {
                onAllLoaded();
            }

            foreach (var dependencyBundleName in dependencyBundleNames)
            {
                mResLoader.LoadAsync <AssetBundle>(dependencyBundleName,
                                                   dependBundle =>
                {
                    loadedCount++;
                    if (loadedCount == dependencyBundleNames.Length)
                    {
                        onAllLoaded();
                    }
                });
            }
        }