|
|
|
|
|
|
using System; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using Unity.UIWidgets.editor2; |
|
|
|
using Unity.UIWidgets.engine2; |
|
|
|
using Unity.UIWidgets.foundation; |
|
|
|
using Unity.UIWidgets.ui; |
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
|
|
|
UIWidgetsWindowType getWindowType(); |
|
|
|
} |
|
|
|
public class Configurations { |
|
|
|
|
|
|
|
private Dictionary<string, TextFont> _textFonts = new Dictionary<string, TextFont>(); |
|
|
|
public class ConfigurationSettings { |
|
|
|
public static Dictionary<IntPtr, bool> _internalShowDebugLog = new Dictionary<IntPtr, bool>(); |
|
|
|
} |
|
|
|
bool _debugMode = true; |
|
|
|
|
|
|
|
public bool debugMode { |
|
|
|
get { return _debugMode; } |
|
|
|
} |
|
|
|
|
|
|
|
public void Clear() { |
|
|
|
_textFonts.Clear(); |
|
|
|
_debugMode = true; |
|
|
|
} |
|
|
|
public void AddFont(string family, TextFont font) { |
|
|
|
_textFonts[key: family] = font; |
|
|
|
} |
|
|
|
public object fontsToObject() { |
|
|
|
Dictionary<string, TextFont> settings = _textFonts; |
|
|
|
if (settings == null || settings.Count == 0) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
public class Configurations { |
|
|
|
|
|
|
|
public Dictionary<string, TextFont> _internalTextFonts = new Dictionary<string, TextFont>(); |
|
|
|
public bool _showDebugLog; |
|
|
|
var result = new object[settings.Count]; |
|
|
|
var i = 0; |
|
|
|
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]; |
|
|
|
for (var j = 0; j < setting.Value.fonts.Length; j++) { |
|
|
|
dic[j] = new Dictionary<string, object>(); |
|
|
|
if (setting.Value.fonts[j].asset.Length > 0) { |
|
|
|
dic[j].Add("asset", value: setting.Value.fonts[j].asset); |
|
|
|
} |
|
|
|
|
|
|
|
if (setting.Value.fonts[j].weight > 0) { |
|
|
|
dic[j].Add("weight", value: setting.Value.fonts[j].weight); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
font.Add("fonts", value: dic); |
|
|
|
result[i] = font; |
|
|
|
i++; |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public void DisableDebugLog() { |
|
|
|
_debugMode = false; |
|
|
|
} |
|
|
|
public void EnableDebugLog() { |
|
|
|
_debugMode = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public partial class UIWidgetsPanel : RawImage, IUIWidgetsWindow { |
|
|
|
|
|
|
return currentDpi / 96; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static bool ShowDebugLog { get; set; } |
|
|
|
|
|
|
|
protected virtual void Update() { |
|
|
|
Input_Update(); |
|
|
|
} |
|
|
|
|
|
|
_configurations = new Configurations(); |
|
|
|
_wrapper = new UIWidgetsPanelWrapper(); |
|
|
|
onEnable(); |
|
|
|
|
|
|
|
|
|
|
|
if (m_ShowDebugLog) { |
|
|
|
EnableDebugLog(); |
|
|
|
} |
|
|
|
_configurations._internalTextFonts.Clear(); |
|
|
|
_configurations.Clear(); |
|
|
|
texture = _wrapper.renderTexture; |
|
|
|
Input_OnEnable(); |
|
|
|
panels.Add(this); |
|
|
|
|
|
|
_wrapper?.Destroy(); |
|
|
|
_wrapper = null; |
|
|
|
texture = null; |
|
|
|
//ConfigurationSettings._internalTextFonts.Clear();
|
|
|
|
Input_OnDisable(); |
|
|
|
base.OnDisable(); |
|
|
|
panels.Remove(this); |
|
|
|
|
|
|
|
|
|
|
protected virtual void onEnable() { |
|
|
|
} |
|
|
|
public void EnableDebugLog() { |
|
|
|
_configurations.EnableDebugLog(); |
|
|
|
} |
|
|
|
public void DisableDebugLog() { |
|
|
|
_configurations.DisableDebugLog(); |
|
|
|
} |
|
|
|
_configurations._internalTextFonts[key: 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 void SetShowDebugLog(bool showDebugLog) { |
|
|
|
_configurations._showDebugLog = showDebugLog || m_ShowDebugLog; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void main() { |
|
|
|
} |
|
|
|
} |
|
|
|