浏览代码

fix settings

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

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


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

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


ui_.runApp(new GalleryApp());
}
protected override void onFill()
protected override void loadConfiguration()
AddFont("GalleryIcons", new List<string>{"gallery/GalleryIcons.ttf"}, new List<int>{0});
base.onFill();
AddFont("GalleryIcons", new List<string>{"gallery/GalleryIcons.ttf"}, new List<int>{0,1});
AddFont("1", new List<string>{"gallery/GalleryIcons.ttf"}, new List<int>{0});
}
protected new void OnEnable() {

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


using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using System.Linq;
using Unity.UIWidgets.editor2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;

Input_OnDisable();
}
protected virtual void onFill() {}
protected virtual void loadConfiguration() {}
List<UIWidgetsPanel.TextFont> _internalTextFonts = new List<UIWidgetsPanel.TextFont>();
Dictionary<string,UIWidgetsPanel.TextFont> _internalTextFonts = new Dictionary<string, UIWidgetsPanel.TextFont>();
int repeat = 0;
for(int i = 0; i< _internalTextFonts.Count; i++ ) {
if (_internalTextFonts[i].family == family)
repeat++;
if (assets.Count != weights.Count) {
UnityEngine.Debug.Log($"The size of {family}‘s assets should be equal to the weights'.");
return;
if (repeat == 0) {
UIWidgetsPanel.TextFont textFont = new UIWidgetsPanel.TextFont();
textFont.family = family;
UIWidgetsPanel.Font[] fonts = new UIWidgetsPanel.Font[assets.Count];
for (int i = 0; i < assets.Count; i++) {
UIWidgetsPanel.Font font = new UIWidgetsPanel.Font();
font.asset = assets[i];
font.weight = weights[i];
fonts[i] = font;
}
textFont.fonts = fonts;
_internalTextFonts.Add(textFont);
UIWidgetsPanel.TextFont textFont = new UIWidgetsPanel.TextFont();
textFont.family = family;
UIWidgetsPanel.Font[] fonts = new UIWidgetsPanel.Font[assets.Count];
for (int j = 0; j < assets.Count; j++) {
UIWidgetsPanel.Font font = new UIWidgetsPanel.Font();
font.asset = assets[j];
font.weight = weights[j];
fonts[j] = font;
textFont.fonts = fonts;
_internalTextFonts.Add(family,textFont);
onFill();
loadConfiguration();
settings.Add("fonts", fontsToObject(textFonts));
settings.Add("fonts", _wrapper.fontsToObject(textFonts));
_wrapper.Initiate(this, _currentWidth, _currentHeight, _currentDevicePixelRatio, settings);
Input_OnEnable();
}

Input_OnGUIEvent(Event.current);
}
}
}
static object fontsToObject(UIWidgetsPanel.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;
}
}
for (int i = 0; i < _internalTextFonts.Count; i++) {
textFonts[i] = _internalTextFonts[i];
List<UIWidgetsPanel.TextFont> fontValues = _internalTextFonts.Values.ToList();
for (int i = 0; i < fontValues.Count; i++) {
textFonts[i] = fontValues[i];
}
return textFonts;
}

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


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.editor2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.services;

public TextFont[] fonts;
static object fontsToObject(TextFont[] textFont) {
/*static object fontsToObject(TextFont[] textFont) {
if (textFont == null || textFont.Length == 0) {
return null;
}

result[i] = font;
}
return result;
}
}*/
int _currentWidth {
get { return Mathf.RoundToInt(rectTransform.rect.width * canvas.scaleFactor); }

static bool _ShowDebugLog = false;
protected virtual void onFill() {}
protected virtual void loadConfiguration() {}
List<UIWidgetsPanel.TextFont> _internalTextFonts = new List<UIWidgetsPanel.TextFont>();
Dictionary<string,UIWidgetsPanel.TextFont> _internalTextFonts = new Dictionary<string, UIWidgetsPanel.TextFont>();
int repeat = 0;
for(int i = 0; i< _internalTextFonts.Count; i++ ) {
if (_internalTextFonts[i].family == family)
repeat++;
if (assets.Count != weights.Count) {
UnityEngine.Debug.Log($"The size of {family}‘s assets should be equal to the weights'.");
return;
if (repeat == 0) {
if (!_internalTextFonts.ContainsKey(family)) {
for (int i = 0; i < assets.Count; i++) {
for (int j = 0; j < assets.Count; j++) {
font.asset = assets[i];
font.weight = weights[i];
fonts[i] = font;
font.asset = assets[j];
font.weight = weights[j];
fonts[j] = font;
_internalTextFonts.Add(textFont);
_internalTextFonts.Add(family,textFont);
D.assert(_wrapper == null);
_wrapper = new UIWidgetsPanelWrapper();
settings.Add("fonts", fontsToObject(fonts));
for (int i = 0; i < fonts.Length; i++) {
if(!_internalTextFonts.ContainsKey(fonts[i].family))
_internalTextFonts.Add(fonts[i].family,fonts[i]);
}
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));
onFill();
loadConfiguration();
settings.Add("fonts", fontsToObject(textFonts));
settings.Add("fonts", _wrapper.fontsToObject(textFonts));
D.assert(_wrapper == null);
_wrapper = new UIWidgetsPanelWrapper();
for (int i = 0; i < _internalTextFonts.Count; i++) {
textFonts[i] = _internalTextFonts[i];
List<UIWidgetsPanel.TextFont> fontValues = _internalTextFonts.Values.ToList();
for (int i = 0; i < fontValues.Count; i++) {
textFonts[i] = fontValues[i];
public void mainEntry() {
main();
}

_wrapper?.Destroy();
_wrapper = null;
texture = null;
/*_internalAssets.Clear();
_internalFamilys.Clear();
_internalWeights.Clear();*/
//UnityEngine.Debug.Log("output _internalAssets " + _internalAssets.Count);
_internalTextFonts.Clear();
panels.Remove(this);
}

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


_ptr = UIWidgetsPanel_constructor((IntPtr) _handle, (int) host.getWindowType(), UIWidgetsPanel_entrypoint);
_host = host;
_enableUIWidgetsPanel(JSONMessageCodec.instance.toJson(settings));
NativeConsole.OnEnable();
}

}
}
}
public object fontsToObject(UIWidgetsPanel.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;
}
public void Destroy() {
UIWidgetsPanel_onDisable(_ptr);

正在加载...
取消
保存