浏览代码

fix show debug mode

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
83501781
共有 11 个文件被更改,包括 98 次插入82 次删除
  1. 1
      Samples/UIWidgetsSamples_2019_4/Assets/Editor/EditorWindowSample/GalleryMain.cs
  2. 1
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs
  3. 13
      com.unity.uiwidgets/Editor/UIWidgetsEditorPanel.cs
  4. 4
      com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs
  5. 86
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs
  6. 42
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanelWrapper.cs
  7. 15
      com.unity.uiwidgets/Runtime/foundation/debug.cs
  8. 1
      com.unity.uiwidgets/Runtime/painting/image_provider.cs
  9. 15
      com.unity.uiwidgets/Runtime/scheduler2/binding.cs
  10. 1
      com.unity.uiwidgets/Runtime/services/asset_bundle.cs
  11. 1
      com.unity.uiwidgets/Runtime/ui2/window.cs

1
Samples/UIWidgetsSamples_2019_4/Assets/Editor/EditorWindowSample/GalleryMain.cs


protected override void onEnable()
{
DisableDebugLog();
AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
AddFont("CupertinoIcons", new List<string> {"CupertinoIcons.ttf"}, new List<int> {0});
AddFont("GalleryIcons", new List<string> {"gallery/GalleryIcons.ttf"}, new List<int> {0});

1
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs


protected override void onEnable()
{
DisableDebugLog();
AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
AddFont("CupertinoIcons", new List<string> {"CupertinoIcons.ttf"}, new List<int> {0});
AddFont("GalleryIcons", new List<string> {"gallery/GalleryIcons.ttf"}, new List<int> {0});

13
com.unity.uiwidgets/Editor/UIWidgetsEditorPanel.cs


using System.Collections;
using System.Collections.Generic;
using Unity.UIWidgets.editor2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;

onEnable();
_wrapper.Initiate(this, width: _currentWidth, height: _currentHeight, dpr: _currentDevicePixelRatio,
_configurations: _configurations);
_configurations._internalTextFonts.Clear();
_configurations.Clear();
Input_OnEnable();
}

protected virtual void onEnable() {
}
protected void SetShowDebugLog(bool showDebugLog) {
_configurations._showDebugLog = showDebugLog;
}
protected void AddFont(string family, List<string> assets, List<int> weights) {
if (assets.Count != weights.Count) {
Debug.LogError($"The size of {family}‘s assets should be equal to the weights'.");

}
textFont.fonts = fonts;
_configurations._internalTextFonts[key: family] = textFont;
_configurations.AddFont(family,textFont);
public void DisableDebugLog() {
_configurations.DisableDebugLog();
}
Vector2? _getPointerPosition(Vector2 position) {
return new Vector2(x: position.x, y: position.y);

4
com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs


EditorGUILayout.PropertyField(antiAliasingProperty);
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(ShowDebugLog);
if (EditorGUI.EndChangeCheck()) {
/*if (EditorGUI.EndChangeCheck()) {
}
}*/
UIWidgetsPanel panel = (UIWidgetsPanel)target;
serializedObject.ApplyModifiedProperties();

86
com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs


using System;
using System.Collections;
using System.Collections.Generic;
using Unity.UIWidgets.editor2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;

UIWidgetsWindowType getWindowType();
}
public class Configurations {
private Dictionary<string, TextFont> _textFonts = new Dictionary<string, TextFont>();
public class ConfigurationSettings {
public static Dictionary<IntPtr, bool> _internalShowDebugLog = new Dictionary<IntPtr, bool>();
}
bool _debugMode = true;
public bool debugMode {
get { return _debugMode; }
}
public void Clear() {
_textFonts.Clear();
_debugMode = true;
}
public void AddFont(string family, TextFont font) {
_textFonts[key: family] = font;
}
public object fontsToObject() {
Dictionary<string, TextFont> settings = _textFonts;
if (settings == null || settings.Count == 0) {
return null;
}
public class Configurations {
public Dictionary<string, TextFont> _internalTextFonts = new Dictionary<string, TextFont>();
public bool _showDebugLog;
var result = new object[settings.Count];
var i = 0;
foreach (var setting in settings) {
var font = new Dictionary<string, object>();
font.Add("family", value: setting.Key);
var dic = new Dictionary<string, object>[setting.Value.fonts.Length];
for (var j = 0; j < setting.Value.fonts.Length; j++) {
dic[j] = new Dictionary<string, object>();
if (setting.Value.fonts[j].asset.Length > 0) {
dic[j].Add("asset", value: setting.Value.fonts[j].asset);
}
if (setting.Value.fonts[j].weight > 0) {
dic[j].Add("weight", value: setting.Value.fonts[j].weight);
}
}
font.Add("fonts", value: dic);
result[i] = font;
i++;
}
return result;
}
public void DisableDebugLog() {
_debugMode = false;
}
public void EnableDebugLog() {
_debugMode = true;
}
}
public partial class UIWidgetsPanel : RawImage, IUIWidgetsWindow {

return currentDpi / 96;
}
}
public static bool ShowDebugLog { get; set; }
protected virtual void Update() {
Input_Update();
}

_configurations = new Configurations();
_wrapper = new UIWidgetsPanelWrapper();
onEnable();
if (m_ShowDebugLog) {
EnableDebugLog();
}
_configurations._internalTextFonts.Clear();
_configurations.Clear();
texture = _wrapper.renderTexture;
Input_OnEnable();
panels.Add(this);

_wrapper?.Destroy();
_wrapper = null;
texture = null;
//ConfigurationSettings._internalTextFonts.Clear();
Input_OnDisable();
base.OnDisable();
panels.Remove(this);

protected virtual void onEnable() {
}
public void EnableDebugLog() {
_configurations.EnableDebugLog();
}
public void DisableDebugLog() {
_configurations.DisableDebugLog();
}
_configurations._internalTextFonts[key: family] = font;
_configurations.AddFont(family,font);
}
protected void AddFont(string family, List<string> assets, List<int> weights) {

textFont.fonts = fonts;
AddFont(family: family, font: textFont);
}
protected void SetShowDebugLog(bool showDebugLog) {
_configurations._showDebugLog = showDebugLog || m_ShowDebugLog;
}
protected virtual void main() {
}
}

42
com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanelWrapper.cs


using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.editor2 {
namespace Unity.UIWidgets.engine2 {
#region Platform: Windows Specific Functionalities
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN

get { return Window.instance._panel; }
}
public IntPtr _ptr;
IntPtr _ptr;
GCHandle _handle;
int _width;

window = host;
var fontsetting = new Dictionary<string, object>();
fontsetting.Add("fonts", fontsToObject(settings: _configurations._internalTextFonts));
fontsetting.Add("fonts", _configurations.fontsToObject());
ShowDebugLog = _configurations._showDebugLog;
ShowDebugLog = _configurations.debugMode;
NativeConsole.OnEnable();
}

}
}
}
public object fontsToObject(Dictionary<string, TextFont> settings) {
if (settings == null || settings.Count == 0) {
return null;
}
var result = new object[settings.Count];
var i = 0;
foreach (var setting in settings) {
var font = new Dictionary<string, object>();
font.Add("family", value: setting.Key);
var dic = new Dictionary<string, object>[setting.Value.fonts.Length];
for (var j = 0; j < setting.Value.fonts.Length; j++) {
dic[j] = new Dictionary<string, object>();
if (setting.Value.fonts[j].asset.Length > 0) {
dic[j].Add("asset", value: setting.Value.fonts[j].asset);
}
if (setting.Value.fonts[j].weight > 0) {
dic[j].Add("weight", value: setting.Value.fonts[j].weight);
}
}
font.Add("fonts", value: dic);
result[i] = font;
i++;
}
return result;
}
ShowDebugLog = true;
_handle.Free();
_handle = default;

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


public static bool debugPrintMouseHoverEvents = false;
public static bool debugLog = true;
private static bool _disableDebugLog = false;
public static HSVColor debugCurrentRepaintColor =
HSVColor.fromAHSV(0.4f, 60.0f, 1.0f, 1.0f);

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

if (debugLog && !result) {
if ( !result && !_disableDebugLog ) {
public static void disableDebugLog() {
_disableDebugLog = true;
}
public static void setDebugLog(bool _debugLog) {
debugLog = _debugLog;
public static void resetDebugLog() {
_disableDebugLog = false;
}
public static void _debugDrawDoubleRect(Canvas canvas, Rect outerRect, Rect innerRect, Color color) {

1
com.unity.uiwidgets/Runtime/painting/image_provider.cs


using System.IO;
using System.Text;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.editor2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;

15
com.unity.uiwidgets/Runtime/scheduler2/binding.cs


using developer;
using Unity.UIWidgets.async;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.editor2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;

public void handleBeginFrame(TimeSpan? rawTimeStamp) {
Timeline.startSync("Frame");
D.setDebugLog(_debugLog: UIWidgetsPanelWrapper.current.ShowDebugLog);
if (!UIWidgetsPanelWrapper.current.ShowDebugLog) {
D.disableDebugLog();
}
_firstRawTimeStampInEpoch = _firstRawTimeStampInEpoch ?? rawTimeStamp;
_currentFrameTimeStamp = _adjustForEpoch(rawTimeStamp ?? currentSystemFrameTimeStamp);

_removedIds.Clear();
}
finally {
D.setDebugLog(true);
D.resetDebugLog();
D.setDebugLog(_debugLog: UIWidgetsPanelWrapper.current.ShowDebugLog);
if (!UIWidgetsPanelWrapper.current.ShowDebugLog) {
D.disableDebugLog();
}
D.assert(schedulerPhase == SchedulerPhase.midFrameMicrotasks);
Timeline.finishSync();
try {

}
}
finally {
D.setDebugLog(true);
D.resetDebugLog();
schedulerPhase = SchedulerPhase.idle;
D.assert(() => {
if (scheduler_.debugPrintEndFrameBanner) {

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


using System.Collections.Generic;
using System.Text;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.editor2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;

1
com.unity.uiwidgets/Runtime/ui2/window.cs


using System.Runtime.InteropServices;
using AOT;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.editor2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;

正在加载...
取消
保存