Open MichaelvanDiest opened 1 week ago
Hi there, @MichaelvanDiest. Can I get a access to your project? That would be the easiest way for me to debug and figure out what has gone wrong here.
Hi @Seanba I've added you as a contributor to the repository.
You can open Scenes/Test
and then drag in one of the Tiled maps in Assets/Tiled/Resources/Levels/City/Easy
to get the error.
Hi again, @MichaelvanDiest. The issue is that your DiestSprite.SetGravityScale
method is throwing an exception because the RigidBody
property is null. My guess is this because that property getter is only non-null after Awake
is called. That Awake
method isn't invoked until the game enters play mode though.
I modified your property from this ...
public Rigidbody2D RigidBody { get { return cRigidBody; } }
to this ...
public Rigidbody2D RigidBody
{
get
{
if (cRigidBody == null)
{
cRigidBody = gameObject.GetComponent<Rigidbody2D>();
}
return cRigidBody;
}
}
and then I was able to reimport your TMX file without any warnings or errors.
I'll try to add some better error reporting to ST2U so that issues like this are easier to spot next time. I'll keep this bug open until that task is completed.
Let me know if you have further questions.
Amazing @Seanba , thank you so much.
I wasn't aware that SuperTiled2Unity runs the function at editor/import time, I thought only during runtime.
You're welcome. The next version of ST2U provides more information on this sort of thing:
SuperTiled2Unity version: 2.1.1, Unity version: 2022.3.20f1
Error invoking 'BarrelController.SetGravityScale(1)' method. Exception = 'Object reference not set to an instance of an object'
Error invoking 'BoxController.SetGravityScale(1)' method. Exception = 'Object reference not set to an instance of an object'
Error invoking 'BoxController.SetGravityScale(1)' method. Exception = 'Object reference not set to an instance of an object'
Error invoking 'BoxController.SetGravityScale(1)' method. Exception = 'Object reference not set to an instance of an object'
Error invoking 'BarrelController.SetGravityScale(1)' method. Exception = 'Object reference not set to an instance of an object'
That should help indicate the problem lies in the code being invoked and not necessarily in the ST2U plugin itself. (Not to say bugs haven't been found in ST2U, mind you.)
That looks great! The original error message made me think I set up the custom properties incorrectly, so I didn't even think to look at the SetGravityScale function. Though in hindsight I totally should have.
Hello, I'm currently attempting to use the Custom Properties feature of SuperTiled2Unity and running into the following error:
Identifier uniqueness violation: 'Name:_MapPrfab/Headquarters/Grid/Objects/Object_7 (TRS), Type:GameObject'. Multiple Objects with the same name/type are generated by this Importer. There is no guarantee that subsequent imports of this asset will properly re-link to these targets.
This error only appears when I place an object in my Tiled map with a custom property. I've followed the steps on the "Custom Properties Support" doc page.
When I open the level prefab in Unity, I can see that the importer has duplicated the objects, one is a![image](https://github.com/Seanba/SuperTiled2Unity/assets/6496843/bf32ce83-c0fb-48ab-b032-85c9f347a5d0)
Super Object
with theSuper Custom Properties
component. And the other being the prefab replacement. However the custom property is not set on the prefab replacement. Here is a screenshot of it:I do have the Object Types Xml set in the SuperTiled2Unity settings with the custom properties and everything seems to appear exactly as the "Custom Properties Support" documentation page. Here is a screenshot of my objecttypesxml with the custom properties shown:![image](https://github.com/Seanba/SuperTiled2Unity/assets/6496843/a0c3c424-c6ba-4b89-9a97-bffa082c6b6a)
Below is the full error: