浏览代码

Merge branch 'master' into yczhang

/main
Yuncong Zhang 5 年前
当前提交
218e45f1
共有 14 个文件被更改,包括 90 次插入82 次删除
  1. 2
      README-ZH.md
  2. 8
      README.md
  3. 13
      Runtime/Plugins/platform/android/view/UIWidgetsViewController.java
  4. 4
      Runtime/Unity.UIWidgets.asmdef
  5. 8
      Runtime/foundation/basic_types.cs
  6. 7
      Runtime/ui/txt/linebreaker.cs
  7. 2
      Runtime/InternalBridge/NoAllocHelpersBridge.cs.meta
  8. 8
      Runtime/InternalBridge.meta
  9. 12
      Runtime/InternalBridge/InternalBridge.asmdef
  10. 7
      Runtime/InternalBridge/InternalBridge.asmdef.meta
  11. 35
      Runtime/InternalBridge/NoAllocHelpersBridge.cs
  12. 66
      Runtime/ui/painting/NoAllocHelpers.cs
  13. 0
      /Runtime/InternalBridge/NoAllocHelpersBridge.cs.meta

2
README-ZH.md


当一个Unity项目运行在Android设备上时,状态栏是默认隐藏且无法在编辑内进行调整的。
如果您希望在您的UIWidgets App中显示状态栏,您可以使用这个[解决方案](https://github.com/Over17/UnityShowAndroidStatusBar)。我们将尽快推出我们自己的解决方案,并保证届时开发者可以进行无缝切换。
此外,为了让上述插件在Android P及以上Android系统中正常工作,请勾选上"Player Settings"中的"Render Outside Safe Area"选项。
#### 七、自动调节帧率
如果要使得构建出的应用能够自动调节帧率,请打开Project Settings,将构建目标平台对应的Quality选项卡中的V Sync Count设置为Don't Sync。
默认的逻辑是在界面静止时将帧率降低为25,在界面变动时将帧率提高至60。

8
README.md


want to show the status bar in your App, this
[solution](https://github.com/Over17/UnityShowAndroidStatusBar) seems to be
compatible to UIWidgets, therefore can be used as a good option before we release our
full support solution on this issue.
full support solution on this issue.
Besides,
please set "Render Outside Safe Area" to true in the "Player Settings" to make this plugin working properly on Android P or later.
#### Automatically Adjust Frame Rate

13
Runtime/Plugins/platform/android/view/UIWidgetsViewController.java


private boolean keyboardOpen;
private void setup() {
Log.i("tag", "On Setup");
//Log.i("tag", "On Setup 2");
keyboardOpen = false;
viewMetrics = new UIWidgetsViewMetrics();

} catch (Exception e) {
e.printStackTrace();
}
//Log.i("UIWidgetsDebug", " hasBar: " + hasBar);
return hasBar;
}

unityView.getWindowVisibleDisplayFrame(rect);
//Log.i("UIWidgetsDebug", "calculation: " + unityView.getRootView().getHeight() + " " + rect.bottom + " " + rect.top);
rect.bottom = unityView.getRootView().getHeight() - (rect.bottom - rect.top) - rect.top;
rect.right = unityView.getRootView().getWidth() - (rect.right - rect.left) - rect.left;

ZeroSides zeroSides = ZeroSides.NONE;
if (navigationBarHidden) {
zeroSides = calculateShouldZeroSides(unityView);
} else {
rect.bottom -= getNavigationBarHeight();
rect.bottom = rect.bottom > 0 ? rect.bottom : 0;
}
viewMetrics.padding_top = rect.top;

viewMetrics.insets_right = 0;
viewMetrics.insets_bottom = navigationBarHidden? calculateBottomKeyboardInset(rect) : rect.bottom;
viewMetrics.insets_left = 0;
//Log.i("UIWidgetsDebug", "checks: " + navigationBarHidden + " " + rect.bottom);
//Log.i("UIWidgetsDebug", " padding: " + viewMetrics.padding_top + " " + viewMetrics.padding_right + " " + viewMetrics.padding_bottom + " " + viewMetrics.padding_left);
//Log.i("UIWidgetsDebug", " insets: " + viewMetrics.insets_top + " " + viewMetrics.insets_right + " " + viewMetrics.insets_bottom + " " + viewMetrics.insets_left);
}
public void setupViewMetricsChangedListener() {

4
Runtime/Unity.UIWidgets.asmdef


{
"name": "Unity.UIWidgets",
"references": [],
"references": [
"Unity.InternalAPIEngineBridge.024"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],

8
Runtime/foundation/basic_types.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.InternalBridge;
using UnityEngine;
using Object = UnityEngine.Object;

}
public static void reset<T>(this List<T> list, int size) {
NoAllocHelpers<T>.EnsureListElemCount(list, size);
NoAllocHelpersBridge<T>.EnsureListElemCount(list, size);
var array = NoAllocHelpers<T>.ExtractArrayFromListT(list);
var array = NoAllocHelpersBridge<T>.ExtractArrayFromListT(list);
return NoAllocHelpers<T>.ExtractArrayFromListT(list);
return NoAllocHelpersBridge<T>.ExtractArrayFromListT(list);
}
}
}

7
Runtime/ui/txt/linebreaker.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using Unity.UIWidgets.InternalBridge;
using UnityEngine;
namespace Unity.UIWidgets.ui {

public void resize(int size) {
if (this._charWidths.Count < size) {
NoAllocHelpers<float>.ResizeList(this._charWidths, size);
NoAllocHelpersBridge<float>.ResizeList(this._charWidths, size);
}
}

2
Runtime/InternalBridge/NoAllocHelpersBridge.cs.meta


fileFormatVersion: 2
guid: 2facb9d73ce7146b9942f8e22d4a04a3
guid: ae100515a41a04d9f8426e6d7c4b2d04
MonoImporter:
externalObjects: {}
serializedVersion: 2

8
Runtime/InternalBridge.meta


fileFormatVersion: 2
guid: 6692331a428d6455c97baf446a850594
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

12
Runtime/InternalBridge/InternalBridge.asmdef


{
"name": "Unity.InternalAPIEngineBridge.024",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

7
Runtime/InternalBridge/InternalBridge.asmdef.meta


fileFormatVersion: 2
guid: 4c951e9ffe25e41eabcc32758a061e70
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

35
Runtime/InternalBridge/NoAllocHelpersBridge.cs


using System.Collections.Generic;
namespace Unity.UIWidgets.InternalBridge {
public static class NoAllocHelpersBridge<T> {
public static T[] ExtractArrayFromListT(List<T> list) {
return UnityEngine.NoAllocHelpers.ExtractArrayFromListT(list);
}
public static void ResizeList(List<T> list, int size) {
if (size < list.Count) {
list.RemoveRange(size, list.Count - size);
return;
}
if (size == list.Count) {
return;
}
if (list.Capacity < size) {
list.Capacity = size;
}
UnityEngine.NoAllocHelpers.ResizeList(list, size);
}
public static void EnsureListElemCount(List<T> list, int size) {
list.Clear();
if (list.Capacity < size) {
list.Capacity = size;
}
ResizeList(list, size);
}
}
}

66
Runtime/ui/painting/NoAllocHelpers.cs


using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
namespace Unity.UIWidgets.ui {
public static class NoAllocHelpers<T> {
static Func<List<T>, T[]> _extractArrayFromListDelegate;
static Action<List<T>, int> _resizeListDelegate;
public static T[] ExtractArrayFromListT(List<T> list) {
if (_extractArrayFromListDelegate == null) {
var ass = Assembly.GetAssembly(typeof(Mesh));
var type = ass.GetType("UnityEngine.NoAllocHelpers");
var methodInfo = type.GetMethod(
"ExtractArrayFromListT",
BindingFlags.Static | BindingFlags.Public)
.MakeGenericMethod(typeof(T));
_extractArrayFromListDelegate = (Func<List<T>, T[]>)
Delegate.CreateDelegate(typeof(Func<List<T>, T[]>), methodInfo);
}
return _extractArrayFromListDelegate(list);
}
public static void ResizeList(List<T> list, int size) {
if (size < list.Count) {
list.RemoveRange(size, list.Count - size);
return;
}
if (size == list.Count) {
return;
}
if (list.Capacity < size) {
list.Capacity = size;
}
if (_resizeListDelegate == null) {
var ass = Assembly.GetAssembly(typeof(Mesh)); // any class in UnityEngine
var type = ass.GetType("UnityEngine.NoAllocHelpers");
var methodInfo = type.GetMethod(
"ResizeList",
BindingFlags.Static | BindingFlags.Public)
.MakeGenericMethod(typeof(T));
_resizeListDelegate = (Action<List<T>, int>)
Delegate.CreateDelegate(typeof(Action<List<T>, int>), methodInfo);
}
_resizeListDelegate(list, size);
}
public static void EnsureListElemCount(List<T> list, int size) {
list.Clear();
if (list.Capacity < size) {
list.Capacity = size;
}
ResizeList(list, size);
}
}
}

/Runtime/ui/painting/NoAllocHelpers.cs.meta → /Runtime/InternalBridge/NoAllocHelpersBridge.cs.meta

正在加载...
取消
保存