浏览代码

fix mono_isolate nullptr

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
3fc3e49f
共有 3 个文件被更改,包括 45 次插入47 次删除
  1. 28
      com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs
  2. 54
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs
  3. 10
      engine/src/lib/ui/ui_mono_state.cc

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


using UnityEditor.UI;
namespace Unity.UIWidgets.Editor {
// [CustomEditor(typeof(UIWidgetsPanel.UIWidgetRawImage), true)]
// [CanEditMultipleObjects]
// public class UIWidgetsPanelEditor : RawImageEditor {
// public override void OnInspectorGUI() {
// base.OnInspectorGUI();
// var pixelRatioProperty = serializedObject.FindProperty("devicePixelRatioOverride");
// var antiAliasingProperty = serializedObject.FindProperty("hardwareAntiAliasing");
// EditorGUILayout.PropertyField(pixelRatioProperty);
// EditorGUILayout.PropertyField(antiAliasingProperty);
// serializedObject.ApplyModifiedProperties();
// }
// }
[CustomEditor(typeof(UIWidgetsPanel), true)]
[CanEditMultipleObjects]
public class UIWidgetsPanelEditor : RawImageEditor {
public override void OnInspectorGUI() {
base.OnInspectorGUI();
var pixelRatioProperty = serializedObject.FindProperty("devicePixelRatioOverride");
var antiAliasingProperty = serializedObject.FindProperty("hardwareAntiAliasing");
EditorGUILayout.PropertyField(serializedObject.FindProperty("fonts"), true);
EditorGUILayout.PropertyField(pixelRatioProperty);
EditorGUILayout.PropertyField(antiAliasingProperty);
serializedObject.ApplyModifiedProperties();
}
}
}

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


using NativeBindings = Unity.UIWidgets.ui.NativeBindings;
namespace Unity.UIWidgets.engine2 {
public partial class UIWidgetsPanel : MonoBehaviour{
public partial class UIWidgetsPanel : RawImage{
public class TextFont {
public struct TextFont {
public List<TextFont> fonts;
public TextFont[] fonts;
public class UIWidgetRawImage : RawImage {
public void SetPanel(UIWidgetsPanel panel) {
_uiWidgetsPanel = panel;
}
UIWidgetsPanel _uiWidgetsPanel;
public float devicePixelRatioOverride;
protected override void OnRectTransformDimensionsChange() {
_uiWidgetsPanel.OnRectTransformDimensionsChange();
}
}
RawImage _rawImage;
RectTransform rectTransform {
get { return _rawImage.rectTransform; }
}
public float hardwareAntiAliasing;
// RectTransform rectTransform {
// get { return rectTransform; }
// }
Canvas canvas {
get { return _rawImage.canvas; }
}
// Canvas canvas {
// get { return canvas; }
// }
Texture texture {
set { _rawImage.texture = value; }
}
// Texture texture {
// set { texture = value; }
// }
public static UIWidgetsPanel current {
get { return Window.instance._panel; }

}
protected void OnEnable() {
_rawImage = gameObject.GetComponent<RawImage>();
if (_rawImage == null) {
_rawImage = gameObject.AddComponent<UIWidgetRawImage>();
((UIWidgetRawImage)_rawImage).SetPanel(this);
}
base.OnEnable();
_recreateRenderTexture(_currentWidth, _currentHeight, _currentDevicePixelRatio);
_handle = GCHandle.Alloc(this);

}
}
protected void OnRectTransformDimensionsChange() {
protected override void OnRectTransformDimensionsChange() {
if (_ptr != IntPtr.Zero) {
if (_recreateRenderTexture(_currentWidth, _currentHeight, _currentDevicePixelRatio)) {
UIWidgetsPanel_onRenderTexture(_ptr,

}
}
protected void OnDisable() {
protected override void OnDisable() {
Input_OnDisable();
UIWidgetsPanel_onDisable(_ptr);

_handle.Free();
_handle = default;
_destroyRenderTexture();
Destroy(_rawImage);
// _destroyRenderTexture();
// Destroy(_rawImage);
base.OnDisable();
}
bool _recreateRenderTexture(int width, int height, float devicePixelRatio) {

10
engine/src/lib/ui/ui_mono_state.cc


UIWIDGETS_API(void)
UIMonoState_postTaskForTime(MonoMicrotaskQueue::CallbackFunc callback,
Mono_Handle handle, int64_t target_time_nanos) {
auto const weak_mono_state = MonoState::Current()->GetWeakPtr();
[callback, handle]() -> void { callback(handle); },
[callback, handle, weak_mono_state]() -> void {
if (auto mono_state = weak_mono_state.lock()) {
MonoState::Scope mono_scope(mono_state.get());
callback(handle);
}
},
fml::TimePoint::FromEpochDelta(
fml::TimeDelta::FromNanoseconds(target_time_nanos)));
}

正在加载...
取消
保存