2D Toolkit Forum
2D Toolkit => Support => Topic started by: Phuzz on January 08, 2015, 10:38:16 am
-
Hello,
I recently added XML level loading into my project from this tutorial [http://www.teambrookvale.com/tutorial-xml-level-unity/]
----------------------------
I am not able to get the DeserializedLevelsSaver Class to read the tk2dsprite component in my prefab, so whenever I load a level all transformation is correct and it loads properly, but the sprite is not set because the component is not being saved to XML.
I am Using Playmaker with 2dToolkit, so I use Playmaker actions for everything related to 2dToolkit, but im very new to scripting, that's where the problem lies even though I know its easy.
I am getting a bit confused about getting the sprite ID component into the XML, I know it goes here,
levelXml.items.prefab = item.name;
levelXml.items.x = toStringNullIfZero (item.transform.position.x);
levelXml.items.y = toStringNullIfZero (item.transform.position.y);
levelXml.items.rot = toStringNullIfZero (item.localRotation.eulerAngles.x);
levelXml.items.scale_x = toStringNullIfOne (item.localScale.x);
levelXml.items.scale_y = toStringNullIfOne (item.localScale.y);
levelXml.items.id = ToString (); <--------------------------------------------------------------- (The missing Part)
Please if someone can spare two minutes of their time and provide me with the missing part "Get sprite ID of current prefab", I am able to manager the other classes, but this is the only pickle. :-\
Thank you,
-
item.GetComponent<tk2dBaseSprite>().spriteId will get you the sprite id.
-
Great, works very well thank you :) 8)