From 8006c7b4b966af151db35032e2e3ae5e1c80df17 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 30 Dec 2015 14:55:05 +0800 Subject: [PATCH] [Unity] Fix for Unity UWP/Windows Phone https://github.com/EsotericSoftware/spine-runtimes/issues/495 --- spine-csharp/src/SkeletonBinary.cs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/spine-csharp/src/SkeletonBinary.cs b/spine-csharp/src/SkeletonBinary.cs index 04d65bfa2..f72bb83ae 100644 --- a/spine-csharp/src/SkeletonBinary.cs +++ b/spine-csharp/src/SkeletonBinary.cs @@ -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 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.");