|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using AOT; |
|
|
|
using Unity.UIWidgets.foundation; |
|
|
|
|
|
|
using UnityEngine.UI; |
|
|
|
using Canvas = UnityEngine.Canvas; |
|
|
|
public partial class UIWidgetsPanel : RawImage { |
|
|
|
public partial class UIWidgetsPanel : MonoBehaviour { |
|
|
|
public class UIWidgetRawImage : RawImage { |
|
|
|
UIWidgetsPanel _uiWidgetsPanel; |
|
|
|
|
|
|
|
protected override void OnRectTransformDimensionsChange() { |
|
|
|
_uiWidgetsPanel.OnRectTransformDimensionsChange(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
UIWidgetRawImage _rawImage; |
|
|
|
RectTransform rectTransform { |
|
|
|
get { return _rawImage.rectTransform; } |
|
|
|
} |
|
|
|
|
|
|
|
Canvas canvas { |
|
|
|
get { return _rawImage.canvas; } |
|
|
|
} |
|
|
|
|
|
|
|
Texture texture { |
|
|
|
set { _rawImage.texture = value; } |
|
|
|
} |
|
|
|
|
|
|
|
public static UIWidgetsPanel current { |
|
|
|
get { return Window.instance._panel; } |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnEnable() { |
|
|
|
base.OnEnable(); |
|
|
|
|
|
|
|
void OnEnable() { |
|
|
|
_rawImage = gameObject.AddComponent<UIWidgetRawImage>(); |
|
|
|
_recreateRenderTexture(_currentWidth, _currentHeight, _currentDevicePixelRatio); |
|
|
|
|
|
|
|
_handle = GCHandle.Alloc(this); |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnRectTransformDimensionsChange() { |
|
|
|
protected void OnRectTransformDimensionsChange() { |
|
|
|
if (_ptr != IntPtr.Zero) { |
|
|
|
if (_recreateRenderTexture(_currentWidth, _currentHeight, _currentDevicePixelRatio)) { |
|
|
|
UIWidgetsPanel_onRenderTexture(_ptr, |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnDisable() { |
|
|
|
protected void OnDisable() { |
|
|
|
Input_OnDisable(); |
|
|
|
|
|
|
|
UIWidgetsPanel_onDisable(_ptr); |
|
|
|
|
|
|
_handle.Free(); |
|
|
|
_handle = default; |
|
|
|
|
|
|
|
_destroyRenderTexture(); |
|
|
|
Destroy(_rawImage); |
|
|
|
|
|
|
|
base.OnDisable(); |
|
|
|
} |
|
|
|
|
|
|
|
bool _recreateRenderTexture(int width, int height, float devicePixelRatio) { |
|
|
|