Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit ee1717b

Browse files
author
Yuncong Zhang
committed
Merge branch 'yczhang' into gallery
2 parents 6a8c8b7 + 65a0e61 commit ee1717b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3364
-272
lines changed

README-ZH.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,29 @@ UIWidgets也支持Gif!
181181

182182
#### 七、自动调节帧率
183183
如果要使得构建出的应用能够自动调节帧率,请打开Project Settings,将构建目标平台对应的Quality选项卡中的V Sync Count设置为Don't Sync。
184-
默认的逻辑是在界面静止时将帧率降低为15,在界面变动时将帧率提高至60。
184+
默认的逻辑是在界面静止时将帧率降低为25,在界面变动时将帧率提高至60。
185185
如果您需要修改帧率升高或降低时的行为,请将`Window.onFrameRateSpeedUp`和/或`Window.onFrameRateCoolDown`设置为您自己的函数。
186186

187+
#### 八、WebGL Canvas分辨率调整插件
188+
因为浏览器中Canvas的宽高和其在显示器上的像素数可能不一致,所以构建出的WebGL程序中画面可能会模糊。
189+
插件`Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib`解决了这个问题。
190+
如果您因为任何原因需要禁止此插件,请在Project面板中选中该插件,在Inspector面板中的Define Constraints参数中,输入任意(没有被Unity定义为宏)的字符串(例如`ENABLE_CANVAS_DEVICE_PIXEL_RATIO_PLUGIN`),使得只有在Player Settings中定义了这个宏,此插件才会启用。
191+
192+
此插件覆盖了Unity WebGL构建模块中的如下参数:
193+
```
194+
JS_SystemInfo_GetWidth
195+
JS_SystemInfo_GetHeight
196+
JS_SystemInfo_GetCurrentCanvasWidth
197+
JS_SystemInfo_GetCurrentCanvasHeight
198+
$Browser
199+
$JSEvents
200+
```
201+
如果您需要实现自己的WebGL插件,并且您的插件覆盖了这些参数中的至少一种,您需要采用上文中提到的方法禁用`UIWidgetsCanvasDevicePixelRatio`插件,以防止可能的冲突。
202+
如果您仍然需要此插件所提供的功能,您可以手动将此插件对Unity WebGL构建模块的修改应用到您的插件中。
203+
`UIWidgetsCanvasDevicePixelRatio`插件中所有的修改之处都以`////////// Modification Start ////////////``////////// Modification End ////////////`标识。
204+
在被标识的代码中,所有乘/除以`devicePixelRatio`都来自于我们的修改。
205+
若您需要详细了解此插件所修改的脚本,请参考您的Unity Editor安装目录下的`PlaybackEngines/WebGLSupport/BuildTools/lib`文件夹中的`SystemInfo.js``UnityNativeJS/UnityNative.js`
206+
187207
## 调试UIWidgets应用程序
188208

189209
#### 定义UIWidgets_DEBUG

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,29 @@ Status bar is always hidden by default when an Unity project is running on an An
213213
#### Automatically Adjust Frame Rate
214214

215215
To build an App that is able to adjust the frame rate automatically, please open Project Settings, and in the Quality tab, set the "V Sync Count" option of the target platform to "Don't Sync".
216-
The default logic is to set the frame rate to 15 when the screen is static, and change the frame rate to 60 whenever the screen changes.
216+
The default logic is to set the frame rate to 25 when the screen is static, and change the frame rate to 60 whenever the screen changes.
217217
If you would like to modify the behavior of speeding up or cooling down the frame rate, please set `Window.onFrameRateSpeedUp` and/or `Window.onFrameRateCoolDown` to your own functions.
218+
219+
#### WebGL Canvas Device Pixel Ratio Plugin
220+
The width and height of the Canvas in browser may differ from the number of pixels the Canvas occupies on the screen.
221+
Therefore, the image may blur in the builded WebGL program.
222+
The Plugin `Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib` solves this issue.
223+
If you need to disable this plugin for any reason, please select this plugin in the **Project** panel, and put an arbitrary string (that is not defined as a macro by Unity) in the **Define Constraints** field in the **Inspector** panel (for example, `ENABLE_CANVAS_DEVICE_PIXEL_RATIO_PLUGIN`), so that the plugin is enabled only if this macro is defined in **Player Settings**, which effectively disables the plugin.
224+
225+
This plugin overrides the following parameters in the Unity WebGL building module:
226+
```
227+
JS_SystemInfo_GetWidth
228+
JS_SystemInfo_GetHeight
229+
JS_SystemInfo_GetCurrentCanvasWidth
230+
JS_SystemInfo_GetCurrentCanvasHeight
231+
$Browser
232+
$JSEvents
233+
```
234+
If you would like to implement your own WebGL plugin, and your plugin overrides at least one of the above parameters, you need to disable the `UIWidgetsCanvasDevicePixelRatio` plugin in the above mentioned way to avoid possible conflicts.
235+
If you still need the function provided by this plugin, you can mannually apply the modification to Unity WebGL building module introduced in this plugin.
236+
All the modifications introduced in `UIWidgetsCanvasDevicePixelRatio` are marked by `////////// Modifcation Start ////////////` and `////////// Modifcation End ////////////`.
237+
In the marked codes, all the multiplications and divisions with `devicePixelRatio` are introduced by our modification.
238+
To learn about the original script in detail, please refer to `SystemInfo.js` and `UnityNativeJS/UnityNative.js` in `PlaybackEngines/WebGLSupport/BuildTools/lib` in your Unity Editor installation.
218239

219240
## Debug UIWidgets Application
220241

Runtime/Plugins/platform/android/editing/TextInputPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public static TextInputPlugin getInstance() {
4242
public TextInputPlugin() {
4343
ViewGroup contentView = (ViewGroup)UnityPlayer.currentActivity.findViewById(android.R.id.content);
4444
mView = new TextInputView(UnityPlayer.currentActivity);
45+
mView.requestFocus();
4546
contentView.addView(mView, 0, 0);
4647
mImm = (InputMethodManager) mView.getContext().getSystemService(
4748
Context.INPUT_METHOD_SERVICE);

0 commit comments

Comments
 (0)