Example #1
0
        /// <summary>
        /// 执行异步加载
        /// </summary>
        /// <param name="async"></param>
        public IEnumerator AsyncRun(IRunAsync async)
        {
            var url     = AssetBundlePath.GetFullPath(m_bundleName);
            var request = AssetBundle.LoadFromFileAsync(url);

            m_request = request;
            yield return(request);

            m_request = null;

            if (!request.isDone)
            {
                m_state = ResState.Failed;
                async.OnRunAsync();
                Notification(false);
                yield break;
            }

            m_assetBundle = request.assetBundle;

            if (m_assetBundle == null)
            {
                m_state = ResState.Failed;
                async.OnRunAsync();
                Notification(false);
                yield break;
            }

            m_state = ResState.Ready;
            async.OnRunAsync();
            Notification(true);
        }
Example #2
0
        /// <summary>
        /// 同步加载
        /// </summary>
        public override bool LoadSync()
        {
            if (m_state == ResState.Ready)
            {
                return(true);
            }

            m_state = ResState.Loading;

            // 先加载依赖
            if (FindDependencies())
            {
                bool dpass = true;
                for (int i = 0; i < m_dependencies.Length; i++)
                {
                    if (!m_dependencies[i].LoadSync())
                    {
                        dpass = false;
                    }
                }
                if (!dpass)
                {
                    m_state = ResState.Failed;
                    return(false);
                }
            }

            // 加载本体
            var url = AssetBundlePath.GetFullPath(m_bundleName);

            m_assetBundle = AssetBundle.LoadFromFile(url);
            if (m_assetBundle == null)
            {
                m_state = ResState.Failed;
                return(false);
            }
            m_state = ResState.Ready;
            return(true);
        }
Example #3
0
 public override void OnSingletonInit()
 {
     m_bundle   = AssetBundle.LoadFromFile(AssetBundlePath.GetFullPath(AssetBundlePath.GetPlatformIds()));
     m_manifest = m_bundle.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
 }