[Unity] Fix for Unity UWP/Windows Phone

https://github.com/EsotericSoftware/spine-runtimes/issues/495
This commit is contained in:
John 2015-12-30 14:55:05 +08:00
parent dd28645a0b
commit 8006c7b4b9

View File

@ -67,7 +67,9 @@ namespace Spine {
Scale = 1;
}
#if WINDOWS_STOREAPP
#if !(UNITY_5 || UNITY_4 || UNITY_WSA || UNITY_WP8 || UNITY_WP8_1)
#if WINDOWS_STOREAPP
private async Task<SkeletonData> ReadFile(string path) {
var folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
using (var input = new BufferedStream(await folder.GetFileAsync(path).AsTask().ConfigureAwait(false))) {
@ -80,26 +82,21 @@ namespace Spine {
public SkeletonData ReadSkeletonData (String path) {
return this.ReadFile(path).Result;
}
#else
#else
public SkeletonData ReadSkeletonData (String path) {
#if WINDOWS_PHONE
using (var input = new BufferedStream(Microsoft.Xna.Framework.TitleContainer.OpenStream(path)))
{
#else
#if UNITY_WP8 || UNITY_WP8_1
using (var input = new FileStream(path, FileMode.Open))
{
#else
using (var input = new BufferedStream(new FileStream(path, FileMode.Open)))
{
#endif
#endif
#if WINDOWS_PHONE
using (var input = new BufferedStream(Microsoft.Xna.Framework.TitleContainer.OpenStream(path))) {
#else
using (var input = new BufferedStream(new FileStream(path, FileMode.Open))) {
#endif // WINDOWS_PHONE
SkeletonData skeletonData = ReadSkeletonData(input);
skeletonData.name = Path.GetFileNameWithoutExtension(path);
return skeletonData;
}
}
#endif
#endif // WINDOWS_STOREAPP
#endif // !(UNITY)
public SkeletonData ReadSkeletonData (Stream input) {
if (input == null) throw new ArgumentNullException("input cannot be null.");