|
|
|
|
|
|
|
|
|
|
UIWidgetsWindowType getWindowType(); |
|
|
|
} |
|
|
|
|
|
|
|
public class Configurations { |
|
|
|
private Dictionary<string, TextFont> _textFonts = new Dictionary<string, TextFont>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public object fontsToObject() { |
|
|
|
Dictionary<string, TextFont> settings = _textFonts; |
|
|
|
if (settings == null || settings.Count == 0) { |
|
|
|
|
|
|
#else
|
|
|
|
if (!File.Exists(assetAbsolutePath)) { |
|
|
|
#endif
|
|
|
|
Debug.LogError($"The font asset (family: \"{setting.Key}\", path: \"{assetPath}\") is not found"); |
|
|
|
Debug.LogError( |
|
|
|
$"The font asset (family: \"{setting.Key}\", path: \"{assetPath}\") is not found"); |
|
|
|
|
|
|
|
fontDic.Add("asset", value: setting.Value.fonts[j].asset); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
#if !UNITY_EDITOR
|
|
|
|
CollectGarbageOnDemand(); |
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if !UNITY_EDITOR
|
|
|
|
// 8 MB
|
|
|
|
const long kCollectAfterAllocating = 8 * 1024 * 1024; |
|
|
|
|
|
|
lastFrameMemory = mem; |
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
IEnumerator ReEnableUIWidgetsNextFrame() { |
|
|
|
|
|
|
AddFont(family: font.family, font: font); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_wrapper.Initiate(this, width: _currentWidth, height: _currentHeight, dpr: _currentDevicePixelRatio, |
|
|
|
_configurations: _configurations); |
|
|
|
_configurations.Clear(); |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
enum UIWidgetsInputMode |
|
|
|
{ |
|
|
|
enum UIWidgetsInputMode { |
|
|
|
Mouse, |
|
|
|
Touch |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void Input_OnEnable() { |
|
|
|
#if !UNITY_EDITOR && (UNITY_IOS || UNITY_ANDROID)
|
|
|
|
Input.RawTouchEvent += ProcessRawTouch; |
|
|
|
#endif
|
|
|
|
enum TouchPhase { |
|
|
|
Began = 0, |
|
|
|
Moved = 1, |
|
|
|
Stationary = 2, |
|
|
|
Ended = 3, |
|
|
|
Canceled = 4 |
|
|
|
} |
|
|
|
|
|
|
|
void ProcessRawTouch(Input.RawTouchEventParam param) { |
|
|
|
var position = _getPointerPosition(new Vector2(param.x, param.y)); |
|
|
|
var pointerId = -1 - param.pointerId; |
|
|
|
switch ((TouchPhase)param.phase) { |
|
|
|
case TouchPhase.Began: |
|
|
|
_wrapper.OnPointerDown(position, pointerId); |
|
|
|
break; |
|
|
|
case TouchPhase.Moved: |
|
|
|
_wrapper.OnDrag(position, pointerId); |
|
|
|
break; |
|
|
|
|
|
|
|
case TouchPhase.Ended: |
|
|
|
_wrapper.OnPointerUp(position, pointerId); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#if !UNITY_EDITOR && (UNITY_IOS || UNITY_ANDROID)
|
|
|
|
Input.RawTouchEvent -= ProcessRawTouch; |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
void Input_Update() { |
|
|
|
|
|
|
if (_inputMode != UIWidgetsInputMode.Mouse) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var pos = _getPointerPosition(Input.mousePosition); |
|
|
|
_wrapper.OnMouseMove(pos); |
|
|
|
} |
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var pos = _getPointerPosition(Input.mousePosition); |
|
|
|
_wrapper.OnMouseScroll(Input.mouseScrollDelta, pos); |
|
|
|
} |
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
D.assert(eventData.pointerId < 0); |
|
|
|
_isEntered = true; |
|
|
|
_lastMousePosition = Input.mousePosition; |
|
|
|
|
|
|
if (_inputMode != UIWidgetsInputMode.Mouse) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR || (!UNITY_IOS && !UNITY_ANDROID)
|
|
|
|
public void OnPointerDown(PointerEventData eventData) { |
|
|
|
_convertPointerData(eventData, out var pos, out var pointerId); |
|
|
|
_wrapper.OnPointerDown(pos, pointerId); |
|
|
|
|
|
|
_convertPointerData(eventData, out var pos, out var pointerId); |
|
|
|
_wrapper.OnDrag(pos, pointerId); |
|
|
|
} |
|
|
|
#else
|
|
|
|
public void OnPointerDown(PointerEventData eventData) { |
|
|
|
} |
|
|
|
|
|
|
|
public void OnPointerUp(PointerEventData eventData) { |
|
|
|
} |
|
|
|
|
|
|
|
public void OnDrag(PointerEventData eventData) { |
|
|
|
} |
|
|
|
#endif
|
|
|
|
} |
|
|
|
} |