浏览代码

file load

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
ad1e9d15
共有 2 个文件被更改,包括 7 次插入7 次删除
  1. 1
      Samples/UIWidgetsSamples_2019_4/Assets/Script/ImageTest.cs
  2. 13
      com.unity.uiwidgets/Runtime/painting/image_provider.cs

1
Samples/UIWidgetsSamples_2019_4/Assets/Script/ImageTest.cs


public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new ExampleApp(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(

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


Future<Codec> _loadAsync(FileImage key, DecoderCallback decode) {
#if UNITY_ANDROID && !UNITY_EDITOR
var path = Path.Combine(Application.streamingAssetsPath, key.file);
WWW unpackerWWW = new WWW(Path.Combine(Application.streamingAssetsPath, key.file));
#else
var path = "file://" + Path.Combine(Application.streamingAssetsPath, key.file);
#endif
WWW unpackerWWW = new WWW(path);
byte[] bytes = unpackerWWW.bytes;
#else
byte[] bytes = File.ReadAllBytes(Path.Combine(Application.streamingAssetsPath, key.file));
#endif
if (bytes.Length > 0) {
return decode(bytes);
if (unpackerWWW.bytes.Length > 0) {
return decode(unpackerWWW.bytes);
}
throw new Exception("not loaded");

正在加载...
取消
保存