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

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

NullReferenceException #11

Closed juaguecar closed 3 years ago

juaguecar commented 3 years ago

Hi mate, love you work. I have imported the project as a package to my project but when i add the MapObjects to a new empty scene i get this error:

NullReferenceException: Object reference not set to an instance of an object Map.MapNode.SetUp (Map.Node node, Map.NodeBlueprint blueprint) (at Assets/Scripts/MapNode.cs:37) Map.MapView.CreateMapNode (Map.Node node) (at Assets/Scripts/MapView.cs:146) Map.MapView.CreateNodes (System.Collections.Generic.IEnumerable`1[T] nodes) (at Assets/Scripts/MapView.cs:136) Map.MapView.ShowMap (Map.Map m) (at Assets/Scripts/MapView.cs:88) Map.MapManager.Start () (at Assets/Scripts/MapManager.cs:30)

silverua commented 3 years ago

Line 37 in MapNode.cs is: sr.sprite = blueprint.sprite;

Things that can go null: 1) sr is null. Then check out the Node prefab in the assets folder and make sure that the sr field is not null in the inspector. If it's null or missing, compare to how it's set up in the original repo. 2) blueprint is null. Have you added the DefaultMapConfig from the assets folder into the AllMapConfigs on the MapView object in the scene?

juaguecar commented 3 years ago

Pressing Regenerate on MapManager fixed the problem, thanks a lot!