浏览代码

update service to 1.17.5

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
8b32aab8
共有 6 个文件被更改,包括 1111 次插入330 次删除
  1. 7
      com.unity.uiwidgets/Runtime/services/asset_bundle.cs
  2. 2
      com.unity.uiwidgets/Runtime/services/binding.cs
  3. 986
      com.unity.uiwidgets/Runtime/services/keyboard_key.cs
  4. 92
      com.unity.uiwidgets/Runtime/services/text_editing.cs
  5. 28
      com.unity.uiwidgets/Runtime/services/text_formatter.cs
  6. 326
      com.unity.uiwidgets/Runtime/services/text_input.cs

7
com.unity.uiwidgets/Runtime/services/asset_bundle.cs


throw new UIWidgetsError($"Unable to load asset: {key}");
if (data.Length < 10 * 1024) {
// 10KB takes about 3ms to parse on a Pixel 2 XL.
// See: https://github.com/dart-lang/sdk/issues/31954
return Encoding.UTF8.GetString(data);
}

yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError) {
completer.completeError(new Exception($"Failed to load from url \"{url}\": {www.error}"));
completer.completeError(new UIWidgetsError(new List<DiagnosticsNode>() {
new ErrorSummary($"Unable to load asset: {key}"),
new StringProperty("HTTP status code", www.error)
}));
yield break;
}

2
com.unity.uiwidgets/Runtime/services/binding.cs


_defaultBinaryMessenger = createBinaryMessenger();
window.onPlatformMessage = defaultBinaryMessenger.handlePlatformMessage;
//initLicenses();
//SystemChannels.system.setMessageHandler(handleSystemMessage);
}

services_.rootBundle.evict(asset);
}
}
class _DefaultBinaryMessenger : BinaryMessenger {
internal _DefaultBinaryMessenger() {

986
com.unity.uiwidgets/Runtime/services/keyboard_key.cs
文件差异内容过多而无法显示
查看文件

92
com.unity.uiwidgets/Runtime/services/text_editing.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.service {
// public class TextRange : IEquatable<TextRange> {
// public readonly int start;
// public readonly int end;
//
// public static TextRange collapsed(int offset) {
// D.assert(offset >= -1);
// return new TextRange(offset, offset);
// }
//
// public static readonly TextRange empty = new TextRange(-1, -1);
//
// public TextRange(int start, int end) {
// D.assert(start >= -1);
// D.assert(end >= -1);
// this.start = start;
// this.end = end;
// }
//
// public bool isValid {
// get { return start >= 0 && end >= 0; }
// }
//
// public bool isCollapsed {
// get { return start == end; }
// }
//
// public bool isNormalized {
// get { return start <= end; }
// }
//
// public string textBefore(string text) {
// D.assert(isNormalized);
// return text.Substring(0, start);
// }
//
// public string textAfter(string text) {
// D.assert(isNormalized);
// return text.Substring(end);
// }
//
// public string textInside(string text) {
// D.assert(isNormalized);
// return text.Substring(start, end - start);
// }
//
// public bool Equals(TextRange other) {
// if (ReferenceEquals(null, other)) {
// return false;
// }
//
// if (ReferenceEquals(this, other)) {
// return true;
// }
//
// return start == other.start && end == other.end;
// }
//
// public override bool Equals(object obj) {
// if (ReferenceEquals(null, obj)) {
// return false;
// }
//
// if (ReferenceEquals(this, obj)) {
// return true;
// }
//
// if (obj.GetType() != GetType()) {
// return false;
// }
//
// return Equals((TextRange) obj);
// }
//
// public override int GetHashCode() {
// unchecked {
// return (start * 397) ^ end;
// }
// }
//
// public static bool operator ==(TextRange left, TextRange right) {
// return Equals(left, right);
// }
//
// public static bool operator !=(TextRange left, TextRange right) {
// return !Equals(left, right);
// }
//
// public override string ToString() {
// return $"TextRange Start: {start}, End: {end}";
// }
// }
public class TextSelection : TextRange, IEquatable<TextSelection> {
public readonly int baseOffset;
public readonly int extentOffset;

28
com.unity.uiwidgets/Runtime/services/text_formatter.cs


public readonly int? maxLength;
internal static TextEditingValue truncate(TextEditingValue value, int maxLength) {
TextSelection newSelection = value.selection.copyWith(
baseOffset: Mathf.Min(value.selection.start, maxLength),
extentOffset: Mathf.Min(value.selection.end, maxLength));
string truncated = value.text.Substring(0, maxLength);
return new TextEditingValue(
text: truncated,
selection: newSelection,
composing: TextRange.empty
);
}
public override TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
if (maxLength != null && maxLength > 0 && newValue.text.Length > maxLength) {
if (Input.compositionString.Length > 0) {

TextSelection newSelection = newValue.selection.copyWith(
baseOffset: Mathf.Min(newValue.selection.start, maxLength.Value),
extentOffset: Mathf.Min(newValue.selection.end, maxLength.Value)
);
string truncated = newValue.text.Substring(0, maxLength.Value);
return new TextEditingValue(
text: truncated,
selection: newSelection,
composing: TextRange.empty
);
if (oldValue.text.Length == maxLength.Value) {
return oldValue;
}
return truncate(newValue, maxLength.Value);
}
return newValue;

326
com.unity.uiwidgets/Runtime/services/text_input.cs


using UnityEngine;
namespace Unity.UIWidgets.service {
public enum FloatingCursorDragState {
Start,
Update,
End
public enum SmartDashesType {
disabled,
enabled
public class RawFloatingCursorPoint {
public RawFloatingCursorPoint(
Offset offset = null,
FloatingCursorDragState? state = null
) {
D.assert(state != null);
D.assert(state != FloatingCursorDragState.Update || offset != null);
//D.assert(state == FloatingCursorDragState.Update ? offset != null : true);
this.offset = offset;
this.state = state;
}
public readonly Offset offset;
public readonly FloatingCursorDragState? state;
public enum SmartQuotesType {
disabled,
enabled
public class TextInputType : IEquatable<TextInputType> {
public readonly int index;
public readonly bool? signed;

}
public static readonly TextInputType text = new TextInputType(0);
public static readonly TextInputType multiline = new TextInputType(1);
public static readonly TextInputType number = numberWithOptions();

public static readonly TextInputType url = new TextInputType(6);
public static readonly TextInputType visiblePassword = new TextInputType(7);
public static readonly List<TextInputType> values = new List<TextInputType> {
text, multiline, number, phone, datetime, emailAddress, url, visiblePassword
};
"text", "multiline", "number", "phone", "datetime", "emailAddress", "url"
"text", "multiline", "number", "phone", "datetime", "emailAddress", "url", "visiblePassword"
};
public JSONNode toJson() {

return $"{GetType().FullName}(name: {_name}, signed: {signed}, decimal: {decimalNum})";
}
}
public enum TextInputAction {
none,
unspecified,
done,
go,
search,
send,
next,
previous,
continueAction,
join,
route,
emergencyCall,
newline
}
public enum TextCapitalization {
words,
sentences,
characters,
none
}
public class TextInputConfiguration {
public TextInputConfiguration(
TextInputType inputType = null,
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType = null,
SmartQuotesType? smartQuotesType = null,
bool enableSuggestions = true,
string actionLabel = null,
TextInputAction inputAction = TextInputAction.done,
ui.Brightness keyboardAppearance = ui.Brightness.light,
TextCapitalization textCapitalization = TextCapitalization.none,
bool unityTouchKeyboard = false
) {
D.assert(inputType != null);
this.smartDashesType =
smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
this.smartQuotesType =
smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
this.inputType = inputType ?? TextInputType.text;
this.obscureText = obscureText;
this.autocorrect = autocorrect;
this.enableSuggestions = enableSuggestions;
this.actionLabel = actionLabel;
this.inputAction = inputAction;
this.textCapitalization = textCapitalization;
this.keyboardAppearance = keyboardAppearance;
this.unityTouchKeyboard = unityTouchKeyboard;
}
public readonly TextInputType inputType;
public readonly bool obscureText;
public readonly bool autocorrect;
public readonly SmartDashesType smartDashesType;
public readonly SmartQuotesType smartQuotesType;
public readonly bool enableSuggestions;
public readonly string actionLabel;
public readonly TextInputAction inputAction;
public readonly TextCapitalization textCapitalization;
public readonly ui.Brightness keyboardAppearance;
public readonly bool unityTouchKeyboard;
public JSONNode toJson() {
var json = new JSONObject();
json["inputType"] = inputType.toJson();
json["obscureText"] = obscureText;
json["autocorrect"] = autocorrect;
json["smartDashesType"] = smartDashesType.ToString();
json["smartQuotesType"] = smartQuotesType.ToString();
json["enableSuggestions"] = enableSuggestions;
json["actionLabel"] = actionLabel;
json["inputAction"] = inputAction.ToString();
json["unityTouchKeyboard"] = unityTouchKeyboard;
json["textCapitalization"] = textCapitalization.ToString();
json["keyboardAppearance"] = keyboardAppearance.ToString();
return json;
}
}
static partial class TextInputUtils {
internal static TextAffinity? _toTextAffinity(string affinity) {
switch (affinity) {

return TextInputAction.newline;
}
throw new UIWidgetsError("Unknown text input action: $action");
throw new UIWidgetsError($"Unknown text input action: {action}");
}
public static FloatingCursorDragState _toTextCursorAction(string state) {

return FloatingCursorDragState.End;
}
throw new UIWidgetsError("Unknown text cursor action: $state");
throw new UIWidgetsError(new List<DiagnosticsNode>() {new ErrorSummary($"Unknown text cursor action: {state}")});
}
public static RawFloatingCursorPoint _toTextPoint(FloatingCursorDragState state,

}
}
public enum FloatingCursorDragState {
Start,
Update,
End
}
public class RawFloatingCursorPoint {
public RawFloatingCursorPoint(
Offset offset = null,
FloatingCursorDragState? state = null
) {
D.assert(state != null);
D.assert(state != FloatingCursorDragState.Update || offset != null);
this.offset = offset;
this.state = state;
}
public readonly Offset offset;
public readonly FloatingCursorDragState? state;
}
public readonly string text;
public readonly TextSelection selection;
public readonly TextRange composing;
static JSONNode defaultBoolNode = new JSONBool(false);
public TextEditingValue(
string text = "",

D.assert(text != null);
D.assert(selection != null);
D.assert(composing != null);
this.text = text;
this.composing = composing ?? TextRange.empty;

this.selection = selection.copyWith(start, end);
}
else {
this.selection = TextSelection.collapsed(-1);
this.selection = selection ?? TextSelection.collapsed(-1);
public static TextEditingValue fromJSON(JSONObject json) {
public static TextEditingValue fromJSON(JSONNode json) {
TextAffinity? affinity =
TextInputUtils._toTextAffinity(json["selectionAffinity"].Value);
return new TextEditingValue(

extentOffset: json.GetValueOrDefault("selectionExtent", defaultIndexNode).AsInt,
affinity: affinity != null ? affinity.Value : TextAffinity.downstream,
isDirectional: json["selectionIsDirectional"].AsBool
isDirectional: json.GetValueOrDefault("selectionIsDirectional", defaultBoolNode).AsBool
),
composing: new TextRange(
start: json.GetValueOrDefault("composingBase", defaultIndexNode).AsInt,

json["composingExtent"] = composing.end;
return json;
}
public readonly string text;
public readonly TextSelection selection;
public readonly TextRange composing;
public static readonly TextEditingValue empty = new TextEditingValue();
public TextEditingValue copyWith(
string text = null,

text ?? this.text,
selection ?? this.selection,
composing ?? this.composing
text: text ?? this.text,
selection: selection ?? this.selection,
composing: composing ?? this.composing
//unity-specific
public TextEditingValue insert(string text) {
string newText;
TextSelection newSelection;

);
}
//unity-specific
public TextEditingValue deleteSelection(bool backDelete = true) {
if (selection.isCollapsed) {
if (backDelete) {

}
}
//unity-specific
//unity-specific
//unity-specific
//unity-specific
//unity-specific
public TextEditingValue moveExtent(int move) {
int offset = selection.extentOffset + move;
offset = Mathf.Max(0, offset);

//unity-specific
public TextEditingValue moveSelection(int move) {
int offset = selection.baseOffset + move;
offset = Mathf.Max(0, offset);

//unity-specific
public TextEditingValue compose(string composeText) {
D.assert(!string.IsNullOrEmpty(composeText));
var composeStart = composing == TextRange.empty ? selection.start : composing.start;

);
}
//unity-specific
public TextEditingValue clearCompose() {
if (composing == TextRange.empty) {
return this;

);
}
public static readonly TextEditingValue empty = new TextEditingValue();
public bool Equals(TextEditingValue other) {
if (ReferenceEquals(null, other)) {
return false;

public override string ToString() {
return $"Text: {text}, Selection: {selection}, Composing: {composing}";
}
public static TextEditingValue fromJSON(JSONNode encoded) {
return new TextEditingValue(
text: encoded["text"] ,
selection: new TextSelection(
baseOffset: encoded.GetValueOrDefault("selectionBase", defaultIndexNode).AsInt,
extentOffset: encoded.GetValueOrDefault("selectionExtent", defaultIndexNode).AsInt,
affinity: TextInputUtils._toTextAffinity(encoded["selectionAffinity"] ) ?? TextAffinity.downstream,
isDirectional: encoded["selectionIsDirectional"] ?? false
),
composing: new TextRange(
start: encoded.GetValueOrDefault("composingBase", defaultIndexNode).AsInt,
end: encoded.GetValueOrDefault("composingExtent", defaultIndexNode).AsInt
)
);
}
}
public interface TextSelectionDelegate {

void performAction(TextInputAction action);
void updateFloatingCursor(RawFloatingCursorPoint point);
RawInputKeyResponse globalInputKeyHandler(RawKeyEvent evt);
}
public enum TextInputAction {
none,
unspecified,
done,
go,
search,
send,
next,
previous,
continueAction,
join,
route,
emergencyCall,
newline
}
public enum TextCapitalization {
words,
sentences,
characters,
none
}
public class TextInputConfiguration {
public TextInputConfiguration(
TextInputType inputType = null,
bool obscureText = false,
bool autocorrect = true,
//SmartDashesType smartDashesType,
//SmartQuotesType smartQuotesType,
bool enableSuggestions = true,
string actionLabel = null,
TextInputAction inputAction = TextInputAction.done,
ui.Brightness keyboardAppearance = ui.Brightness.light,
TextCapitalization textCapitalization = TextCapitalization.none,
bool unityTouchKeyboard = false
) {
D.assert(inputType != null);
D.assert(obscureText != null);
//smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
//smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
D.assert(autocorrect != null);
D.assert(enableSuggestions != null);
D.assert(keyboardAppearance != null);
D.assert(inputAction != null);
D.assert(textCapitalization != null);
this.inputType = inputType ?? TextInputType.text;
this.obscureText = obscureText;
this.autocorrect = autocorrect;
this.enableSuggestions = enableSuggestions;
this.actionLabel = actionLabel;
this.inputAction = inputAction;
this.textCapitalization = textCapitalization;
this.keyboardAppearance = keyboardAppearance;
this.unityTouchKeyboard = unityTouchKeyboard;
}
public readonly TextInputAction inputAction;
public readonly TextInputType inputType;
public readonly string actionLabel;
public readonly bool obscureText;
public readonly bool autocorrect;
//public readonly TextInputAction inputAction;
public readonly bool enableSuggestions;
public readonly TextCapitalization textCapitalization;
public readonly ui.Brightness keyboardAppearance;
public readonly bool unityTouchKeyboard;
public JSONNode toJson() {
var json = new JSONObject();
json["inputType"] = inputType.toJson();
json["obscureText"] = obscureText;
json["autocorrect"] = autocorrect;
//'smartDashesType': smartDashesType.index.toString(),
//'smartQuotesType': smartQuotesType.index.toString(),
json["enableSuggestions"] = enableSuggestions;
json["actionLabel"] = actionLabel;
json["inputAction"] = inputAction.ToString();
json["unityTouchKeyboard"] = unityTouchKeyboard;
json["textCapitalization"] = textCapitalization.ToString();
json["keyboardAppearance"] = keyboardAppearance.ToString();
return json;
}
//unity-specific
RawInputKeyResponse globalInputKeyHandler(RawKeyEvent evt);
}
public class TextInputConnection {

internal Size _cachedSize;
internal Matrix4 _cachedTransform;
D.assert(to != null);
//TextInput._instance._show();
Input.imeCompositionMode = IMECompositionMode.On;
TextInput.keyboardDelegate.show();

D.assert(attached);
TextInput.keyboardDelegate.setEditingState(value);
//TextInput._instance._setEditingState(value);
//var dictionary = new JSONObject();
//json["text"] = text;
Dictionary<string,object> dictionary = new Dictionary<string, object>();
dictionary["width"] = editableBoxSize.width;
dictionary["height"] = editableBoxSize.height;

);
}
}
string fontFamily = null,
float? fontSize = null,
FontWeight fontWeight = null,
TextDirection? textDirection = null,
TextAlign? textAlign = null
) { /// ????
string fontFamily,
float? fontSize,
FontWeight fontWeight,
TextDirection textDirection,
TextAlign textAlign
) {
dictionary["textAlignIndex"] = textAlign?.GetHashCode();
dictionary["textDirectionIndex"] = textDirection?.GetHashCode();
dictionary["textAlignIndex"] = (int)textAlign;
dictionary["textDirectionIndex"] = (int)textDirection;
//TextInput._instance._clearClient();
TextInput.keyboardDelegate.clearClient();
TextInput._currentConnection = null;
Input.imeCompositionMode = IMECompositionMode.Auto;

TextInput._currentConnection = null;
D.assert(!attached);
}
internal readonly Window _window;
TouchScreenKeyboard _keyboard;
}

public static TextInputConnection attach(TextInputClient client, TextInputConfiguration configuration) {
D.assert(client != null);
D.assert(configuration != null);
var connection = new TextInputConnection(client);
_currentConnection = connection;
if (keyboardDelegate != null) {

正在加载...
取消
保存