This commit is contained in:
Xingwei Zhu 2022-03-08 12:06:35 +08:00
Родитель f94a4ebff3
Коммит 1c34251cdc
1 изменённых файлов: 6 добавлений и 7 удалений

Просмотреть файл

@ -1,6 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.engine { namespace Unity.UIWidgets.engine {
public partial class UIWidgetsPanelWrapper { public partial class UIWidgetsPanelWrapper {
@ -29,18 +29,17 @@ namespace Unity.UIWidgets.engine {
foreach(var texturePair in externalTextures) { foreach(var texturePair in externalTextures) {
var curInternalTextureId = texturePair.Value; var curInternalTextureId = texturePair.Value;
if (curInternalTextureId == internalTextureId) { if (curInternalTextureId == internalTextureId) {
if (externalTexturePtr != IntPtr.Zero) { D.assert(externalTexturePtr == IntPtr.Zero, () => $"The internal texture id {internalTextureId} is shared by different external textures {externalTexturePtr} and {curInternalTextureId}");
Debug.LogError($"The internal texture id {internalTextureId} is shared by different external textures {externalTexturePtr} amd {curInternalTextureId}");
return;
}
externalTexturePtr = texturePair.Key; externalTexturePtr = texturePair.Key;
} }
} }
if (externalTexturePtr != IntPtr.Zero) {
ReleaseExternalTexture(externalTexturePtr); ReleaseExternalTexture(externalTexturePtr);
}
} }
public int RegisterExternalTexture(IntPtr externalTexturePtr) { public int RegisterExternalTexture(IntPtr externalTexturePtr) {
D.assert(externalTexturePtr != IntPtr.Zero, () => "Cannot register null external texture");
if (!externalTextures.ContainsKey(externalTexturePtr)) { if (!externalTextures.ContainsKey(externalTexturePtr)) {
var internalTextureId = registerTexture(externalTexturePtr); var internalTextureId = registerTexture(externalTexturePtr);
externalTextures[externalTexturePtr] = internalTextureId; externalTextures[externalTexturePtr] = internalTextureId;