浏览代码

add font load

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
7e12a7db
共有 3 个文件被更改,包括 26 次插入23 次删除
  1. 19
      Samples/UIWidgetsSamples_2019_4/Assets/TextTest.cs
  2. 21
      Samples/UIWidgetsSamples_2019_4/Assets/TextTest.unity
  3. 9
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs

19
Samples/UIWidgetsSamples_2019_4/Assets/TextTest.cs


using ParagraphBuilder = Unity.UIWidgets.ui2.ParagraphBuilder;
using ParagraphConstraints = Unity.UIWidgets.ui2.ParagraphConstraints;
using ParagraphStyle = Unity.UIWidgets.ui2.ParagraphStyle;
using Path = System.IO.Path;
using Picture = Unity.UIWidgets.ui2.Picture;
using PictureRecorder = Unity.UIWidgets.ui2.PictureRecorder;
using Rect = Unity.UIWidgets.ui.Rect;

{
if (check)
{
var robot_regular_bold = File.ReadAllBytes("./Assets/StreamingAssets/Roboto-BlackItalic.ttf");
ui_.loadFontFromList(robot_regular_bold, "Roboto-RegularB").then(value =>
foreach (var font in fonts)
Debug.Log("finish loading");
return FutureOr.nil;
});
var robot_regular = File.ReadAllBytes("./Assets/StreamingAssets/Roboto-Italic.ttf");
ui_.loadFontFromList(robot_regular, "Roboto-Regular");
var ranchers = File.ReadAllBytes("./Assets/StreamingAssets/Ranchers-Regular.ttf");
ui_.loadFontFromList(ranchers, "ranchers");
var path = Path.Combine(Application.streamingAssetsPath, font.path);
var fontFile = File.ReadAllBytes(path);
ui_.loadFontFromList(fontFile, font.name).then(value =>
{
Debug.Log("finish loading");
return FutureOr.nil;
});
}
check = false;
}

21
Samples/UIWidgetsSamples_2019_4/Assets/TextTest.unity


m_Script: {fileID: 11500000, guid: db61290d6ca38264995f5749021d562c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
fonts:
- path: Roboto-BlackItalic.ttf
name: Roboto-RegularB
- path: Roboto-Italic.ttf
name: Roboto-Regular
- path: Ranchers-Regular.ttf
name: ranchers
--- !u!222 &847097471
CanvasRenderer:
m_ObjectHideFlags: 0

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


using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using AOT;
using Unity.UIWidgets.foundation;

namespace Unity.UIWidgets.engine2 {
public partial class UIWidgetsPanel : MonoBehaviour {
[Serializable]
public class TextFont {
public string path;
public string name;
}
public List<TextFont> fonts;
public class UIWidgetRawImage : RawImage {
UIWidgetsPanel _uiWidgetsPanel;

正在加载...
取消
保存