示例#1
0
        public async void LoadConfigAsyn(string configPath,
                                         GameFrameworkAction <string> loadCompleteHandle = null, GameFrameworkAction <string> loadErrorHandle = null)
        {
            FileStream fileStream = null;

            try
            {
                fileStream = File.Open(configPath, FileMode.Open);
                byte[]        bytes = new byte[1024];
                StringBuilder sb    = new StringBuilder();
                int           count = await fileStream.ReadAsync(bytes, 0, bytes.Length);

                while (count > 0)
                {
                    sb.Append(Encoding.UTF8.GetString(bytes));
                    count = await fileStream.ReadAsync(bytes, 0, bytes.Length);
                }

                loadCompleteHandle.Handle(sb.ToString());
            }
            catch (FileNotFoundException)
            {
                loadErrorHandle.Handle($"加载失败,没有找到,路径为{configPath}的文件.");
            }
            catch (Exception ex)
            {
                loadErrorHandle.Handle($"加载失败,其他错误,路径为{configPath}.\n Message:{ex.Message}");
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                    fileStream.Dispose();
                }
            }
        }
示例#2
0
        private bool _checkAppVersion()
        {
            int appVersion = 0;

            try
            {
                appVersion = int.Parse(Application.version.Split('.').Last());
            }
            catch (Exception e)
            {
                _errorHandle.Handle(
                    $"请确保 Edit-->" +
                    $"Project Settings-->Player --> " +
                    $"Other Setting 下的 Version " +
                    $"字段‘.’分割的" +
                    $"最后一位是int值,如:0.1.1s.2,‘2’就是我默认的规则");
                return(false);
            }

            return(appVersion > ServerVersionInfo.MinAppVersion);
        }