浏览代码

Merge pull request #129 from Unity-Technologies/siyaoH/1.17/android

ios & isolate
/siyaoH-1.17-PlatformMessage
GitHub 3 年前
当前提交
1cab4cfb
共有 2 个文件被更改,包括 28 次插入17 次删除
  1. 27
      com.unity.uiwidgets/Runtime/engine/UIWidgetsMessageManager.cs
  2. 18
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs

27
com.unity.uiwidgets/Runtime/engine/UIWidgetsMessageManager.cs


using Unity.UIWidgets.external.simplejson;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.service;
using System.Runtime.InteropServices;
using Unity.UIWidgets.ui;
using UnityEngine;

}
void UpdateNameIfNeed() {
#if UNITY_ANDROID || UNITY_WEBGL
#if UNITY_IOS || UNITY_ANDROID || UNITY_WEBGL
var name = gameObject.name;
if (name != _lastObjectName) {

}
void OnUIWidgetsMethodMessage(string message) {
using (Isolate.getScope(TextInput._currentConnection.isolate)) {
JSONObject jsonObject = (JSONObject) JSON.Parse(message);
string channel = jsonObject["channel"].Value;
string method = jsonObject["method"].Value;
var args = new List<JSONNode>(jsonObject["args"].AsArray.Children);
if (string.IsNullOrEmpty(channel) || string.IsNullOrEmpty(method)) {
Debug.LogError("invalid uiwidgets method message");
}
else {
MethodChannelMessageDelegate exists;
_methodChannelMessageDelegates.TryGetValue(channel, out exists);
exists?.Invoke(method, args);
}
JSONObject jsonObject = (JSONObject) JSON.Parse(message);
string channel = jsonObject["channel"].Value;
string method = jsonObject["method"].Value;
var args = new List<JSONNode>(jsonObject["args"].AsArray.Children);
if (string.IsNullOrEmpty(channel) || string.IsNullOrEmpty(method)) {
Debug.LogError("invalid uiwidgets method message");
}
else {
MethodChannelMessageDelegate exists;
_methodChannelMessageDelegates.TryGetValue(channel, out exists);
exists?.Invoke(method, args);
}
}

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


public partial class UIWidgetsPanel : RawImage, IUIWidgetsWindow {
static List<UIWidgetsPanel> panels = new List<UIWidgetsPanel>();
static public Isolate anyIsolate {
get {
if (panels.Count == 0) {
return null;
}
return panels[0]._wrapper.isolate;
}
}
static void registerPanel(UIWidgetsPanel panel) {
panels.Add(panel);
}

bool _viewMetricsCallbackRegistered;
void _handleViewMetricsChanged(string method, List<JSONNode> args) {
_wrapper.displayMetrics.onViewMetricsChanged();
Window.instance.updateSafeArea();
Window.instance.onMetricsChanged?.Invoke();
using (Isolate.getScope(anyIsolate)) {
_wrapper.displayMetrics.onViewMetricsChanged();
Window.instance.updateSafeArea();
Window.instance.onMetricsChanged?.Invoke();
}
}
protected virtual void Update() {

正在加载...
取消
保存