浏览代码

Merge pull request #223 from Unity-Technologies/siyaoH/1.17/fix_crash

check graphic api
/main
GitHub 3 年前
当前提交
e26ce617
共有 1 个文件被更改,包括 45 次插入12 次删除
  1. 57
      com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs

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


using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.Scripting;
using UnityEngine.UI;
using Path = System.IO.Path;

UIWidgetsWindowType getWindowType();
}
public class Configurations {
private Dictionary<string, TextFont> _textFonts = new Dictionary<string, TextFont>();
public void Clear() {

_textFonts[key: family] = font;
_textFonts[key: family] = font;
}
public object fontsToObject() {
Dictionary<string, TextFont> settings = _textFonts;

for (var j = 0; j < setting.Value.fonts.Length; j++) {
var fontDic = new Dictionary<string, object>();
var fileExist = false;
if (setting.Value.fonts[j].asset.Length > 0) {
var assetPath = setting.Value.fonts[j].asset;
var assetAbsolutePath = Path.Combine(Application.streamingAssetsPath, assetPath);

}
}
[ExecuteInEditMode]
[ExecuteInEditMode]
public partial class UIWidgetsPanel : RawImage, IUIWidgetsWindow {
static List<UIWidgetsPanel> panels = new List<UIWidgetsPanel>();

UIWidgetsMessageManager.instance?.AddChannelMessageDelegate("ViewportMetricsChanged",
_handleViewMetricsChanged);
}
#if !UNITY_EDITOR
CollectGarbageOnDemand();
#endif

return true;
}
#endif
static bool UIWidgetsDisabled;
void DisableUIWidgets() {
Debug.Log("Please change graphic api for UIWidgets.\n" +
"Metal for iOS and MacOS.\n" +
"Direct3D11 for Windows\n" +
"Vulkan for Android\n");
UIWidgetsDisabled = true;
enabled = false;
}
if (UIWidgetsDisabled) {
enabled = false;
return;
}
var type = SystemInfo.graphicsDeviceType;
if(type != GraphicsDeviceType.OpenGLES2 && type != GraphicsDeviceType.OpenGLES3){
DisableUIWidgets();
return;
}
#endif
#if UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
if (type != GraphicsDeviceType.Metal) {
DisableUIWidgets();
return;
}
#endif
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
if (type != GraphicsDeviceType.Direct3D11) {
DisableUIWidgets();
return;
}
if(canvas == null){
if (canvas == null) {
enabled = false;
startCoroutine(ReEnableUIWidgetsNextFrame());
return;

Hooks.tryHook();
#endif
#if !UNITY_EDITOR
TryEnableOnDemandGC();
Application.lowMemory += () => {

#endif
base.OnEnable();
D.assert(_wrapper == null);
_configurations = new Configurations();
_wrapper = new UIWidgetsPanelWrapper();

protected virtual void onEnable() {
}
_configurations.AddFont(family,font);
_configurations.AddFont(family, font);
}
protected void AddFont(string family, List<string> assets, List<int> weights) {

textFont.fonts = fonts;
AddFont(family: family, font: textFont);
}
protected virtual void main() {
}
}

}
}
}
#if UNITY_ANDROID && !UNITY_EDITOR
if (Input.GetKeyDown(KeyCode.Escape)) {
using (Isolate.getScope(anyIsolate)) {

正在加载...
取消
保存