浏览代码

Merge pull request #222 from Unity-Technologies/fix_runtime_debug

Fix runtime debug
/main
GitHub 3 年前
当前提交
a790e008
共有 4 个文件被更改,包括 10 次插入8 次删除
  1. 4
      README-ZH.md
  2. 4
      README.md
  3. 3
      com.unity.uiwidgets/Runtime/engine/UIWidgetsGlobalConfiguration.cs
  4. 7
      com.unity.uiwidgets/Runtime/foundation/debug.cs

4
README-ZH.md


## 调试UIWidgets应用程序
在编辑器菜单栏选择```UIWidgets->EnableDebug```
Editor模式下,编辑器菜单栏选择```UIWidgets->EnableDebug```
如果想在runtime开启debug模式,请在项目代码中设置```UIWidgetsGlobalConfiguration.EnableDebugAtRuntime = true```。在默认情况下debug模式为关闭状态
在Runtime模式下,Debug/Development build会自动开启Debug,Release build则会自动关闭Debug
## 使用Window Scope保护外部调用
如果您在调试时遇到 `AssertionError: Window.instance is null` 或者在调用 `Window.instance` 时得到空指针, 那么您需要

4
README.md


## Debug UIWidgets Application
In Unity editor, you can switch debug/release mode by “UIWidgets->EnableDebug”.
In the Editor, you can switch debug/release mode by “UIWidgets->EnableDebug”.
You can also enable debug mode in runtime by setting ```UIWidgetsGlobalConfiguration.EnableDebugAtRuntime = true``` in your project. Note that this value is set to false by default.
In the Player, the debug/development build will enable debug mode. The release build will disable debug mode automatically.
## Using Window Scope
If you see the error `AssertionError: Window.instance is null` or null pointer error of `Window.instance`,

3
com.unity.uiwidgets/Runtime/engine/UIWidgetsGlobalConfiguration.cs


//disable incremental gc by default
public static bool EnableIncrementalGC = false;
//disable debug at runtime by default
public static bool EnableDebugAtRuntime = false;
}
}

7
com.unity.uiwidgets/Runtime/foundation/debug.cs


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Unity.UIWidgets.engine;

throw new AssertionError(message != null ? message() : "");
}
}
[Conditional("UNITY_ASSERTIONS")]
public static void assert(bool result, Func<string> message = null) {
if ( enableDebug && !result ) {

#if UNITY_EDITOR
static bool? _enableDebug = null;
public static bool enableDebug {
get {
if (_enableDebug == null) {

}
}
#else
public static bool enableDebug => UIWidgetsGlobalConfiguration.EnableDebugAtRuntime;
//In the runtime, we use the Conditional decorator instead of this to enable/disable debug mode
//The rule is simple: the debug mode is on for Debug/Development build, and is off for Release build
public static bool enableDebug => true;
#endif
public static void _debugDrawDoubleRect(Canvas canvas, Rect outerRect, Rect innerRect, Color color) {

正在加载...
取消
保存