コード例 #1
0
ファイル: AppEngine.cs プロジェクト: niu461393873/KSFramework
 void Start()
 {
     IsAppPlaying = true;
     if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXPlayer)
     {
         LogFileManager.Start();
     }
     Debuger.Assert(_isNewByStatic);
 }
コード例 #2
0
ファイル: AppEngine.cs プロジェクト: niu461393873/KSFramework
 void OnApplicationQuit()
 {
     IsApplicationQuit = true;
     IsAppPlaying      = false;
     if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXPlayer)
     {
         LogFileManager.Destory();
     }
     LogFileRecorder.CloseStream();
 }
コード例 #3
0
        private IEnumerator LoadAssetBundle(string relativeUrl)
        {
#if UNITY_5 || UNITY_2017_1_OR_NEWER
            // Unity 5 Manifest中管理了依赖
            var abPath = relativeUrl.ToLower();
            var deps   = _assetBundleManifest.GetAllDependencies(abPath);
            _depLoaders = new AssetBundleLoader[deps.Length];
            for (var d = 0; d < deps.Length; d++)
            {
                var dep = deps[d];
                _depLoaders[d] = AssetBundleLoader.Load(dep, null, _loaderMode);
                if (_depLoaders[d].dependFrom == string.Empty)
                {
                    _depLoaders[d].dependFrom = relativeUrl;
                }
            }
            for (var l = 0; l < _depLoaders.Length; l++)
            {
                var loader = _depLoaders[l];
                while (!loader.IsCompleted)
                {
                    yield return(null);
                }
            }
#endif

#if UNITY_5 || UNITY_2017_1_OR_NEWER
            // Unity 5 AssetBundle自动转小写
            relativeUrl = relativeUrl.ToLower();
#endif
            if (AppConfig.IsLogAbLoadCost)
            {
                beginTime = Time.realtimeSinceStartup;
            }

            string _fullUrl = KResourceModule.GetAbFullPath(relativeUrl);

            if (string.IsNullOrEmpty(_fullUrl))
            {
                OnFinish(null);
                yield break;
            }

            AssetBundle assetBundle = null;
            if (_loaderMode == LoaderMode.Sync)
            {
                assetBundle = AssetBundle.LoadFromFile(_fullUrl);
            }
            else
            {
                var request = AssetBundle.LoadFromFileAsync(_fullUrl);
                while (!request.isDone)
                {
                    if (IsReadyDisposed) // 中途释放
                    {
                        OnFinish(null);
                        yield break;
                    }
                    Progress = request.progress;
                    yield return(null);
                }
                assetBundle = request.assetBundle;
            }
            if (assetBundle == null)
            {
                Log.Error("assetBundle is NULL: {0}", RelativeResourceUrl);
            }
            if (AppConfig.IsLogAbLoadCost)
            {
                Log.Info("[Finish] Load AssetBundle {0}, CostTime {1}s {2}", relativeUrl, Time.realtimeSinceStartup - beginTime, dependFrom);
            }
            if (AppConfig.IsSaveCostToFile && !relativeUrl.StartsWith("ui/"))
            {
                LogFileManager.WriteLoadAbLog(relativeUrl, Time.realtimeSinceStartup - beginTime);
            }
            OnFinish(assetBundle);
        }