fzhangtj
6 年前
当前提交
4bf67a5a
共有 20 个文件被更改,包括 1591 次插入 和 151 次删除
-
14Runtime/editor/editor_window.cs
-
235Runtime/service/keyboard.cs
-
215Runtime/service/text_input.cs
-
2Runtime/service/text_input_utils.cs
-
4Runtime/ui/painting/canvas_impl.cs
-
1Runtime/ui/painting/txt/mesh_generator.cs
-
2Runtime/ui/window.cs
-
35Runtime/widgets/editable_text.cs
-
43Samples/UIWidgetSample/TextInput.unity
-
61Samples/UIWidgetSample/TextInputSample.cs
-
1UIWidgetCleanupPlugin.DotSettings
-
85Runtime/engine/UIWidgetsMessageManager.cs
-
11Runtime/engine/UIWidgetsMessageManager.cs.meta
-
8Runtime/external.meta
-
5Runtime/external/.editorconfig
-
8Runtime/external/simplejson.meta
-
1001Runtime/external/simplejson/SimpleJSON.cs
-
11Runtime/external/simplejson/SimpleJSON.cs.meta
|
|||
using System.Collections.Generic; |
|||
using System.Runtime.InteropServices; |
|||
using Unity.UIWidgets.external.simplejson; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.service; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.engine { |
|||
public class UIWidgetsMessageManager: MonoBehaviour { |
|||
|
|||
public delegate void MethodChannelMessageDelegate(string method, List<JSONNode> args); |
|||
|
|||
static UIWidgetsMessageManager _instance; |
|||
|
|||
readonly Dictionary<string, MethodChannelMessageDelegate> _methodChannelMessageDelegates = |
|||
new Dictionary<string, MethodChannelMessageDelegate>(); |
|||
public static UIWidgetsMessageManager instance { |
|||
get { return _instance; } |
|||
} |
|||
|
|||
string _lastObjectName; |
|||
|
|||
void OnEnable() { |
|||
D.assert(_instance == null, "Only one instance of UIWidgetsMessageManager should exists"); |
|||
_instance = this; |
|||
this.UpdateNameIfNeed(); |
|||
} |
|||
|
|||
void OnDisable() { |
|||
D.assert(_instance != null, "_instance should not be null"); |
|||
_instance = null; |
|||
} |
|||
|
|||
void Update() { |
|||
this.UpdateNameIfNeed(); |
|||
} |
|||
|
|||
void UpdateNameIfNeed() { |
|||
var name = this.gameObject.name; |
|||
if (name != this._lastObjectName) { |
|||
this._lastObjectName = name; |
|||
#if UNITY_IOS
|
|||
if (!Application.isEditor) { |
|||
UIWidgetsMessageSetObjectName(this._lastObjectName); |
|||
} |
|||
#endif
|
|||
} |
|||
} |
|||
|
|||
public void AddChannelMessageDelegate(string channel, MethodChannelMessageDelegate del) { |
|||
MethodChannelMessageDelegate exists; |
|||
this._methodChannelMessageDelegates.TryGetValue(channel, out exists); |
|||
this._methodChannelMessageDelegates[channel] = exists + del; |
|||
} |
|||
|
|||
public void RemoveChannelMessageDelegate(string channel, MethodChannelMessageDelegate del) { |
|||
MethodChannelMessageDelegate exists; |
|||
this._methodChannelMessageDelegates.TryGetValue(channel, out exists); |
|||
if (exists != null) { |
|||
this._methodChannelMessageDelegates[channel] = exists - del; |
|||
} |
|||
} |
|||
|
|||
void OnUIWidgetsMethodMessage(string message) { |
|||
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; |
|||
this._methodChannelMessageDelegates.TryGetValue(channel, out exists); |
|||
exists?.Invoke(method, args); |
|||
} |
|||
} |
|||
|
|||
#if UNITY_IOS
|
|||
[DllImport("__Internal")] |
|||
static extern void UIWidgetsMessageSetObjectName(string objectName); |
|||
#endif
|
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: efd031068fc9d41d6b4c165afaaa25ba |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 910527b5287c8499e8381ae8b9787b4a |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
root = true |
|||
|
|||
# For CSharp Only |
|||
[*.cs] |
|||
csharp_instance_members_qualify_members=none |
|
|||
fileFormatVersion: 2 |
|||
guid: 32a991dd6b6164b14976cfb586cc658f |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Runtime/external/simplejson/SimpleJSON.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: c1511f3e459f641589f4f62495cd64e6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue