浏览代码

fix crash when font file doesn't exist

/main
Xingwei Zhu 3 年前
当前提交
ceb6795a
共有 1 个文件被更改,包括 21 次插入5 次删除
  1. 26
      com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs

26
com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Unity.UIWidgets.external.simplejson;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;

using UnityEngine.Profiling;
using UnityEngine.Scripting;
using UnityEngine.UI;
using Path = System.IO.Path;
using RawImage = UnityEngine.UI.RawImage;
namespace Unity.UIWidgets.engine {

foreach (var setting in settings) {
var font = new Dictionary<string, object>();
font.Add("family", value: setting.Key);
var dic = new Dictionary<string, object>[setting.Value.fonts.Length];
var dic = new List<Dictionary<string, object>>();
dic[j] = new Dictionary<string, object>();
var fontDic = new Dictionary<string, object>();
var fileExist = false;
dic[j].Add("asset", value: setting.Value.fonts[j].asset);
var assetPath = setting.Value.fonts[j].asset;
var assetAbsolutePath = Path.Combine(Application.streamingAssetsPath, assetPath);
if (!File.Exists(assetAbsolutePath)) {
Debug.LogError($"The font asset (family: \"{setting.Key}\", path: \"{assetPath}\") is not found");
}
else {
fileExist = true;
}
fontDic.Add("asset", value: setting.Value.fonts[j].asset);
dic[j].Add("weight", value: setting.Value.fonts[j].weight);
fontDic.Add("weight", value: setting.Value.fonts[j].weight);
}
if (fileExist) {
dic.Add(fontDic);
font.Add("fonts", value: dic);
font.Add("fonts", value: dic.ToArray());
result[i] = font;
i++;
}

正在加载...
取消
保存