浏览代码

fix inactive

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
243a1ae7
共有 1 个文件被更改,包括 13 次插入11 次删除
  1. 24
      com.unity.uiwidgets/Runtime/painting/image_provider.cs

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


using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using Unity.UIWidgets.async2;

using UnityEngine;
using UnityEngine.Networking;
using Codec = Unity.UIWidgets.ui.Codec;
using Image = Unity.UIWidgets.ui.Image;
using Window = Unity.UIWidgets.ui.Window;
namespace Unity.UIWidgets.painting {
public static partial class painting_ {

public static ImageProvider resizeIfNeeded(int? cacheWidth, int? cacheHeight, ImageProvider provider) {
if (cacheWidth != null || cacheHeight != null) {
return new ResizeImage((ImageProvider<object>) provider, width: cacheWidth.Value, height: cacheHeight.Value);
return new ResizeImage((ImageProvider<object>) provider, width: cacheWidth.Value,
height: cacheHeight.Value);
}
return provider;

var completer = Completer.create();
var isolate = Isolate.current;
var panel = UIWidgetsPanel.current;
panel.StartCoroutine(_loadCoroutine(key.url, completer, isolate));
return completer.future.to<byte[]>().then_<byte[]>(data => {
if (data != null && data.Length > 0) {
return decode(data);
}
if (panel.IsActive()) {
panel.StartCoroutine(_loadCoroutine(key.url, completer, isolate));
return completer.future.to<byte[]>().then_<byte[]>(data => {
if (data != null && data.Length > 0) {
return decode(data);
}
throw new Exception("not loaded");
}).to<Codec>();
throw new Exception("not loaded");
}).to<Codec>();
}
return new Future<Codec>(Future.create(() => FutureOr.value(null)));
}
IEnumerator _loadCoroutine(string key, Completer completer, Isolate isolate) {

正在加载...
取消
保存