浏览代码

stash changes

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
d9a52efd
共有 3 个文件被更改,包括 42 次插入84 次删除
  1. 42
      com.unity.uiwidgets/Editor/UIWidgetsEditorPanel.cs
  2. 80
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs
  3. 4
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanelWrapper.cs

42
com.unity.uiwidgets/Editor/UIWidgetsEditorPanel.cs


using Unity.UIWidgets.ui;
using UnityEditor;
using UnityEngine;
using Font = Unity.UIWidgets.engine2.Font;
readonly Dictionary<string, UIWidgetsPanel.TextFont> _internalTextFonts =
new Dictionary<string, UIWidgetsPanel.TextFont>();
UIWidgetsPanelWrapper _wrapper;
int _currentWidth {

float _currentDevicePixelRatio {
get { return EditorGUIUtility.pixelsPerPoint; }
}
readonly Dictionary<string, TextFont> _internalTextFonts =
new Dictionary<string, TextFont>();
void Update() {
_wrapper.onEditorUpdate();

D.assert(_wrapper == null);
_wrapper = new UIWidgetsPanelWrapper();
onEnable();
_wrapper.Initiate(this, width: _currentWidth, height: _currentHeight, dpr: _currentDevicePixelRatio,
settings: _internalTextFonts);
_internalTextFonts.Clear();

Debug.LogError($"The size of {family}‘s assets should be equal to the weights'.");
return;
}
if (_internalTextFonts.ContainsKey(key: family)) {
var textFont = _internalTextFonts[key: family];
var fonts = new UIWidgetsPanel.Font[assets.Count];
for (var j = 0; j < assets.Count; j++) {
var font = new UIWidgetsPanel.Font();
font.asset = assets[index: j];
font.weight = weights[index: j];
fonts[j] = font;
}
textFont.fonts = fonts;
_internalTextFonts[key: family] = textFont;
}
else {
var textFont = new UIWidgetsPanel.TextFont();
textFont.family = family;
var fonts = new UIWidgetsPanel.Font[assets.Count];
for (var j = 0; j < assets.Count; j++) {
var font = new UIWidgetsPanel.Font();
font.asset = assets[index: j];
font.weight = weights[index: j];
fonts[j] = font;
}
textFont.fonts = fonts;
_internalTextFonts.Add(key: family, value: textFont);
var textFont = new TextFont {family = family};
var fonts = new Font[assets.Count];
for (var j = 0; j < assets.Count; j++) {
var font = new Font {asset = assets[index: j], weight = weights[index: j]};
fonts[j] = font;
textFont.fonts = fonts;
_internalTextFonts[key: family] = textFont;
}
Vector2? _getPointerPosition(Vector2 position) {

80
com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs


GameObjectPanel = 1,
EditorWindowPanel = 2
}
[Serializable]
public struct Font {
public string asset;
public int weight;
}
[Serializable]
public struct TextFont {
public string family;
[SerializeField] public Font[] fonts;
}
public interface IUIWidgetsWindow {
Offset windowPosToScreenPos(Offset offset);

D.assert(_wrapper == null);
_wrapper = new UIWidgetsPanelWrapper();
onEnable();
addFontFromInspector(fonts: fonts);
foreach (var font in fonts) {
AddFont(font.family, font);
}
texture = _wrapper.renderTexture;
texture = _wrapper.renderTexture;
Input_OnEnable();
panels.Add(this);
_ShowDebugLog = m_ShowDebugLog;

protected virtual void onEnable() {
}
protected void AddFont(string family, TextFont font) {
_internalTextFonts[key: family] = font;
}
if (_internalTextFonts.ContainsKey(key: family)) {
var textFont = _internalTextFonts[key: family];
var fonts = new Font[assets.Count];
for (var j = 0; j < assets.Count; j++) {
var font = new Font();
font.asset = assets[index: j];
font.weight = weights[index: j];
fonts[j] = font;
}
textFont.fonts = fonts;
_internalTextFonts[key: family] = textFont;
}
else {
var textFont = new TextFont();
textFont.family = family;
var fonts = new Font[assets.Count];
for (var j = 0; j < assets.Count; j++) {
var font = new Font();
font.asset = assets[index: j];
font.weight = weights[index: j];
fonts[j] = font;
}
textFont.fonts = fonts;
_internalTextFonts.Add(key: family, value: textFont);
}
}
void addFontFromInspector(TextFont[] fonts) {
foreach (var font in fonts) {
if (_internalTextFonts.ContainsKey(key: font.family)) {
_internalTextFonts[key: font.family] = font;
}
else {
_internalTextFonts.Add(key: font.family, value: font);
}
var textFont = new TextFont {family = family};
var fonts = new Font[assets.Count];
for (var j = 0; j < assets.Count; j++) {
var font = new Font {asset = assets[index: j], weight = weights[index: j]};
fonts[j] = font;
textFont.fonts = fonts;
AddFont(family, textFont);
}
[Serializable]
public struct Font {
public string asset;
public int weight;
}
[Serializable]
public struct TextFont {
public string family;
[SerializeField] public Font[] fonts;
}
}

4
com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanelWrapper.cs


public float devicePixelRatio { get; private set; }
public void Initiate(IUIWidgetsWindow host, int width, int height, float dpr,
Dictionary<string, UIWidgetsPanel.TextFont> settings) {
Dictionary<string, TextFont> settings) {
D.assert(renderTexture == null);
_recreateRenderTexture(width: width, height: height, devicePixelRatio: dpr);

}
}
public object fontsToObject(Dictionary<string, UIWidgetsPanel.TextFont> settings) {
public object fontsToObject(Dictionary<string, TextFont> settings) {
if (settings == null || settings.Count == 0) {
return null;
}

正在加载...
取消
保存