silverua / slay-the-spire-map-in-unity

Implementation of the Slay the Spire Map in Unity3d
MIT License
273 stars 65 forks source link

PlatformNotSupportedException When Build for Windows #4

Closed newcreativegamer closed 4 years ago

newcreativegamer commented 4 years ago

Hi!

Can I lead by saying I love this map and thank you for sharing it!

So, I'm having an issue when I build it for Windows and run the built file; it works fine in the editor. Seems to be related to json Serialize:

Any guidance would be great. Stacktrace below:

PlatformNotSupportedException: Operation is not supported on this platform.
  at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod (System.String name, System.Type returnType, System.Type[] parameterTypes, System.Type owner) [0x00018] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateParameterizedConstructor (System.Reflection.MethodBase method) [0x00029] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.Serialization.JsonObjectContract.set_ParametrizedConstructor (System.Reflection.ConstructorInfo value) [0x00013] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x000e5] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x000e1] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x00038] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe (System.Object value) [0x00016] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00028] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00253] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00028] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.Formatting formatting, Newtonsoft.Json.JsonSerializerSettings settings) [0x0000e] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, Newtonsoft.Json.Formatting formatting, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, Newtonsoft.Json.Formatting formatting) [0x00000] in <97722d3abc9f4cf69f9e21e6770081b3>:0 
  at Map.Map.ToJson () [0x00000] in <967488ac67ea45468895b0576879d422>:0 
  at Map.MapManager.GenerateNewMap () [0x00013] in <967488ac67ea45468895b0576879d422>:0 
  at Map.MapManager.Start () [0x0006c] in <967488ac67ea45468895b0576879d422>:0 
silverua commented 4 years ago

Hi! Thanks for the kind words about the package. It is related to Json.Net not working properly with API compatibility level 2.0. So, I updated it to NET 4.x in ProjectSettings and pushed. The build works for me. If you have time to give it a try, please let me know how it goes.

newcreativegamer commented 4 years ago

Hi, That's fixed it! Fantastic, thank you. Appreciate the speedy response also :)

This is a little off-topic, but how would I go about making the map the width of the screen when left-to-right and not scroll?

Alan.

silverua commented 4 years ago

Nice!

Width of the screen when left to right: You can make the map more condensed in the MapConfig in your Assets folder. Set distanceFromPreviousLayer on all layers to something smaller so that the entire map fits onto the screen.

This code in MapView.cs adds a scrolling component to the map. You can just remove it:

var scrollNonUi = mapParent.AddComponent<ScrollNonUI>();
scrollNonUi.freezeX = orientation == MapOrientation.BottomToTop || orientation == MapOrientation.TopToBottom;
scrollNonUi.freezeY = orientation == MapOrientation.LeftToRight || orientation == MapOrientation.RightToLeft;
newcreativegamer commented 4 years ago

That's perfect, thank you!