siyao
4 年前
当前提交
e6ff42eb
共有 8 个文件被更改,包括 104 次插入 和 7 次删除
-
4Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs
-
13com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanelWrapper.cs
-
2engine/Build.bee.cs
-
14engine/src/assets/directory_asset_bundle.cc
-
42com.unity.uiwidgets/Runtime/engine2/AndroidUnpackStreamingAsset.cs
-
3com.unity.uiwidgets/Runtime/engine2/AndroidUnpackStreamingAsset.cs.meta
-
17engine/src/shell/platform/unity/android_unpack_streaming_asset.cc
-
16engine/src/shell/platform/unity/android_unpack_streaming_asset.h
|
|||
using UnityEngine; |
|||
using AOT; |
|||
using System; |
|||
using System.IO; |
|||
using System.Runtime.InteropServices; |
|||
using NativeBindings = Unity.UIWidgets.ui.NativeBindings; |
|||
|
|||
public static class AndroidUnpackStreamingAssets { |
|||
|
|||
[DllImport(NativeBindings.dllName)] |
|||
internal static extern void InitUnpackFile(UnpackFileCallback unpack); |
|||
|
|||
internal delegate bool UnpackFileCallback(string file); |
|||
|
|||
[MonoPInvokeCallback(typeof(UnpackFileCallback))] |
|||
internal static bool unpackFile(string file) { |
|||
if (Application.platform == RuntimePlatform.Android) { |
|||
var dir = Application.temporaryCachePath + "/"; |
|||
if (!File.Exists(dir + file)) { |
|||
WWW unpackerWWW = new WWW("jar:file://" + Application.dataPath + "!/assets/" + file); |
|||
while (!unpackerWWW.isDone) { |
|||
} // This will block in the webplayer.
|
|||
|
|||
if (!string.IsNullOrEmpty(unpackerWWW.error)) { |
|||
Debug.Log("Error unpacking 'jar:file://" + Application.dataPath + "!/assets/" + file + |
|||
"'"); |
|||
dir = ""; |
|||
return false; |
|||
} |
|||
File.WriteAllBytes(dir + file, unpackerWWW.bytes); // 64MB limit on File.WriteAllBytes.
|
|||
} |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public static void OnEnable() |
|||
{ |
|||
InitUnpackFile(unpackFile); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 76a442e0d2934484b6b95ed3b22889f2 |
|||
timeCreated: 1616467811 |
|
|||
#include "android_unpack_streaming_asset.h"
|
|||
#include <stdarg.h>
|
|||
|
|||
namespace uiwidgets { |
|||
|
|||
bool AndroidUnpackStreamingAsset::Unpack(const char* file) { |
|||
return _unpack(file); |
|||
} |
|||
|
|||
UnpackFileCallback AndroidUnpackStreamingAsset::_unpack; |
|||
|
|||
UIWIDGETS_API(void) |
|||
InitUnpackFile(UnpackFileCallback _unpack) { |
|||
AndroidUnpackStreamingAsset::_unpack = _unpack; |
|||
} |
|||
|
|||
} |
|
|||
#pragma once |
|||
#include "runtime/mono_api.h" |
|||
|
|||
namespace uiwidgets { |
|||
|
|||
typedef bool (*UnpackFileCallback)(const char* file); |
|||
|
|||
|
|||
class AndroidUnpackStreamingAsset{ |
|||
public: |
|||
static UnpackFileCallback _unpack; |
|||
|
|||
static bool Unpack(const char* file); |
|||
}; |
|||
|
|||
} // namespace uiwidgets |
撰写
预览
正在加载...
取消
保存
Reference in new issue