浏览代码

fix add settings

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
eba2e5a9
共有 5 个文件被更改,包括 54 次插入79 次删除
  1. 4
      Samples/UIWidgetsSamples_2019_4/Assets/Editor/EditorWindowSample/GalleryMain.cs
  2. 6
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs
  3. 35
      com.unity.uiwidgets/Editor/UIWidgetsEditorPanel.cs
  4. 67
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs
  5. 21
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanelWrapper.cs

4
Samples/UIWidgetsSamples_2019_4/Assets/Editor/EditorWindowSample/GalleryMain.cs


CreateWindow<EditorWindowGallery>();
}
protected override void loadConfiguration()
protected override void onEnable()
AddFont("GalleryIcons", new List<string>{"gallery/GalleryIcons.ttf"}, new List<int>{0,1});
//AddFont("GalleryIcons", new List<string>{"gallery/GalleryIcons.ttf"}, new List<int>{0});
}
protected override void main()

6
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs


ui_.runApp(new GalleryApp());
}
protected override void loadConfiguration()
protected override void onEnable()
AddFont("Material Icons", new List<string>{"MaterialIcons-Regular.ttf"}, new List<int>{0});
//AddFont("Material Icons", new List<string>{"MaterialIcons-Regular.ttf"}, new List<int>{0});
AddFont("GalleryIcons", new List<string>{"gallery/GalleryIcons.ttf"}, new List<int>{0,1});
AddFont("GalleryIcons", new List<string>{"gallery/GalleryIcons.ttf"}, new List<int>{0});
AddFont("1", new List<string>{"gallery/GalleryIcons.ttf"}, new List<int>{0});
}

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


using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Unity.UIWidgets.editor2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;

using UnityEngine;
using Rect = UnityEngine.Rect;
using TextFont = Unity.UIWidgets.engine2.UIWidgetsPanel.TextFont;
using Font = Unity.UIWidgets.engine2.UIWidgetsPanel.Font;
namespace Unity.UIWidgets.Editor {
public class UIWidgetsEditorPanel : EditorWindow, IUIWidgetsWindow {
UIWidgetsPanelWrapper _wrapper;

D.assert(_wrapper != null);
_wrapper?.Destroy();
_wrapper = null;
_internalTextFonts.Clear();
protected virtual void loadConfiguration() {}
protected virtual void onEnable() {}
Dictionary<string,UIWidgetsPanel.TextFont> _internalTextFonts = new Dictionary<string, UIWidgetsPanel.TextFont>();
Dictionary<string,TextFont> _internalTextFonts = new Dictionary<string, TextFont>();
UnityEngine.Debug.Log($"The size of {family}‘s assets should be equal to the weights'.");
UnityEngine.Debug.LogError($"The size of {family}‘s assets should be equal to the weights'.");
UIWidgetsPanel.TextFont textFont = new UIWidgetsPanel.TextFont();
TextFont textFont = new TextFont();
UIWidgetsPanel.Font[] fonts = new UIWidgetsPanel.Font[assets.Count];
Font[] fonts = new Font[assets.Count];
UIWidgetsPanel.Font font = new UIWidgetsPanel.Font();
Font font = new Font();
font.asset = assets[j];
font.weight = weights[j];
fonts[j] = font;

void OnEnable() {
D.assert(_wrapper == null);
_wrapper = new UIWidgetsPanelWrapper();
loadConfiguration();
var settings = new Dictionary<string, object>();
UIWidgetsPanel.TextFont[] textFonts = loadTextFont();
settings.Add("fonts", _wrapper.fontsToObject(textFonts));
_wrapper.Initiate(this, _currentWidth, _currentHeight, _currentDevicePixelRatio, settings);
onEnable();
_wrapper.Initiate(this, _currentWidth, _currentHeight, _currentDevicePixelRatio, _internalTextFonts);
_internalTextFonts.Clear();
Input_OnEnable();
}

}
Vector2? _getPointerPosition(Vector2 position) {
return new Vector2(position.x, position.y);
}
UIWidgetsPanel.TextFont[] loadTextFont() {
UIWidgetsPanel.TextFont[] textFonts = new UIWidgetsPanel.TextFont[_internalTextFonts.Count];
List<UIWidgetsPanel.TextFont> fontValues = _internalTextFonts.Values.ToList();
for (int i = 0; i < fontValues.Count; i++) {
textFonts[i] = fontValues[i];
}
return textFonts;
int _buttonToPointerId(int buttonId) {
if (buttonId == 0) {
return -1;

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


using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using TextFont = Unity.UIWidgets.engine2.UIWidgetsPanel.TextFont;
using Font = Unity.UIWidgets.engine2.UIWidgetsPanel.Font;
namespace Unity.UIWidgets.engine2 {

public TextFont[] fonts;
/*static object fontsToObject(TextFont[] textFont) {
if (textFont == null || textFont.Length == 0) {
return null;
}
var result = new object[textFont.Length];
for (int i = 0; i < textFont.Length; i++) {
var font = new Dictionary<string, object>();
font.Add("family", textFont[i].family);
var dic = new Dictionary<string, object>[textFont[i].fonts.Length];
for (int j = 0; j < textFont[i].fonts.Length; j++) {
dic[j] = new Dictionary<string, object>();
if (textFont[i].fonts[j].asset.Length > 0) {
dic[j].Add("asset", textFont[i].fonts[j].asset);
}
if (textFont[i].fonts[j].weight > 0) {
dic[j].Add("weight", textFont[i].fonts[j].weight);
}
}
font.Add("fonts", dic);
result[i] = font;
}
return result;
}*/
int _currentWidth {
get { return Mathf.RoundToInt(rectTransform.rect.width * canvas.scaleFactor); }
}

static bool _ShowDebugLog = false;
protected virtual void loadConfiguration() {}
protected virtual void onEnable() {}
Dictionary<string,UIWidgetsPanel.TextFont> _internalTextFonts = new Dictionary<string, UIWidgetsPanel.TextFont>();
Dictionary<string,TextFont> _internalTextFonts = new Dictionary<string, TextFont>();
UnityEngine.Debug.Log($"The size of {family}‘s assets should be equal to the weights'.");
UnityEngine.Debug.LogError($"The size of {family}‘s assets should be equal to the weights'.");
UIWidgetsPanel.TextFont textFont = new UIWidgetsPanel.TextFont();
TextFont textFont = new TextFont();
UIWidgetsPanel.Font[] fonts = new UIWidgetsPanel.Font[assets.Count];
Font[] fonts = new Font[assets.Count];
UIWidgetsPanel.Font font = new UIWidgetsPanel.Font();
Font font = new Font();
font.asset = assets[j];
font.weight = weights[j];
fonts[j] = font;

base.OnEnable();
D.assert(_wrapper == null);
_wrapper = new UIWidgetsPanelWrapper();
var settings = new Dictionary<string, object>();
for (int i = 0; i < fonts.Length; i++) {
if(!_internalTextFonts.ContainsKey(fonts[i].family))
_internalTextFonts.Add(fonts[i].family,fonts[i]);
foreach (var font in fonts) {
if(!_internalTextFonts.ContainsKey(font.family))
_internalTextFonts.Add(font.family,font);
loadConfiguration();
UIWidgetsPanel.TextFont[] textFonts = new UIWidgetsPanel.TextFont[_internalTextFonts.Keys.Count];
for (int i = 0; i < _internalTextFonts.Keys.Count; i++) {
textFonts[i] = _internalTextFonts.Values.ToList()[i];
}
settings.Add("fonts", _wrapper.fontsToObject(textFonts));
onEnable();
loadConfiguration();
UIWidgetsPanel.TextFont[] textFonts = loadTextFont();
settings.Add("fonts", _wrapper.fontsToObject(textFonts));
onEnable();
_wrapper.Initiate(this, _currentWidth, _currentHeight, _currentDevicePixelRatio, settings);
_wrapper.Initiate(this, _currentWidth, _currentHeight, _currentDevicePixelRatio, _internalTextFonts);
_internalTextFonts.Clear();
UIWidgetsPanel.TextFont[] loadTextFont() {
UIWidgetsPanel.TextFont[] textFonts = new UIWidgetsPanel.TextFont[_internalTextFonts.Count];
List<UIWidgetsPanel.TextFont> fontValues = _internalTextFonts.Values.ToList();
TextFont[] loadTextFont() {
TextFont[] textFonts = new TextFont[_internalTextFonts.Count];
List<TextFont> fontValues = _internalTextFonts.Values.ToList();
for (int i = 0; i < fontValues.Count; i++) {
textFonts[i] = fontValues[i];
}

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


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using AOT;
using Unity.UIWidgets.engine2;

using Unity.UIWidgets.ui;
using UnityEngine;
using TextFont = Unity.UIWidgets.engine2.UIWidgetsPanel.TextFont;
using Font = Unity.UIWidgets.engine2.UIWidgetsPanel.Font;
namespace Unity.UIWidgets.editor2 {

}
public void Initiate(IUIWidgetsWindow host, int width, int height, float dpr,
Dictionary<string, object> settings) {
Dictionary<string, TextFont> settings) {
D.assert(_renderTexture == null);
_recreateRenderTexture(width, height, dpr);

_enableUIWidgetsPanel(JSONMessageCodec.instance.toJson(settings));
TextFont[] textFonts = loadTextFont(settings);
var fontsetting = new Dictionary<string, object>();
fontsetting.Add("fonts", fontsToObject(textFonts));
_enableUIWidgetsPanel(JSONMessageCodec.instance.toJson(fontsetting));
}
public TextFont[] loadTextFont(Dictionary<string,TextFont> TextFontsList) {
TextFont[] textFonts = new TextFont[TextFontsList.Count];
List<TextFont> fontValues = TextFontsList.Values.ToList();
for (int i = 0; i < fontValues.Count; i++) {
textFonts[i] = fontValues[i];
}
return textFonts;
}
public void _entryPoint() {

正在加载...
取消
保存