Adam's Lair Forum

game development and casual madness
It is currently 2019/11/12, 02:26

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 2015/12/04, 10:06 
Member
Member
User avatar

Joined: 2015/10/29, 18:52
Posts: 69
Location: Finland
Role: Hobbyist
Hey community!

I noticed while developing TileD Plugin, that when "reloading" my scene it has forgotten the data it loads into the TiledMap component - or forgets the property path to an XmlData file and fails to load it?

Image
Link to image.

So my question is, what am I missing when this happens? Do I need custom PropertyEditor system to keep track of the data? Do I need to create a custom exporter for the component? I'm so confuse... :(

_________________
.
..
...
....
What?


Top
 Profile  
 
PostPosted: 2015/12/04, 11:09 
Forum Adept
Forum Adept

Joined: 2015/07/08, 16:41
Posts: 414
Role: Gamer
Hm, I took a look at the sources on GitHub and I also think that the XML data is failing to load, because it's failing in the constructor of the component class. Not really sure, though. Maybe add some logging for that, and see if that's the case?
I'm building your plugin right now, to see if I can reproduce this. What can I say, I'm bored.
P.S: Since SirePi's Data plugin is a dependency, could you maybe mention that on the git repository readme? Someone who doesn't know about that plugin could be confused at that.

The last error (TiledLoader) is caused by the other component (TiledMap) being nonexistent, right?

EDIT: Well, it appears I can't use your plugin; I get an error on adding a TiledLoader component, a MissingMethodException for Duality.Resources.ShaderProgram.Compile(). Here's the full error: http://pastebin.com/raw.php?i=8j0J3EXH

I also can't import any TSX files. When I drag a file into the project view, nothing happens, not even an error.

I think this might be because of the missing TiledImporter in the EditorPlugin project, but it's not on the Git repository?

I'm using a Duality version freshly compiled from the master branch on the Duality Git repository (commit fc1fb80719ff22d854dd2f8ffbff1d0f1b070b28).

Sorry if you haven't got around to updating the repository: I was just bored and tried to see if I could help.


Top
 Profile  
 
PostPosted: 2015/12/04, 12:05 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
misthema wrote:
Do I need custom PropertyEditor system to keep track of the data? Do I need to create a custom exporter for the component?

No and no. Don't panic :D

misthema wrote:

The reason for your problem is likely one of the logged errors - or maybe even a result of previous errors that are no longer in the log because they may have occurred when saving the Scene, or even before when adding objects to it. Logged errors are never a good thing and should always be investigated.

In any case, the immediate problem here is, as hsnabn said, in your constructor. More specifically, when deserializing the Scene, i.e. turning the saved file into a runtime object again, Duality tries to create an instance of your object TiledMap. Apparently, this object doesn't have a trivial (parameterless) constructor, so it picks the other one it finds, which takes an XmlData object. Because Duality has of course no idea what this parameter means, it tries what happens when it assigns the default value to all parameters, e.g. null in this case. It appears though as your constructor doesn't like this and fails - Duality catches the exception and concludes that it isn't able to construct objects of your Type. It returns null and leaves deserialization with a missing object.

So, one way to fix this is to provide a trivial constructor that can be used during deserialization and cloning operations. You can make it private if you don't want it to be used otherwise.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2015/12/04, 12:16 
Member
Member
User avatar

Joined: 2015/10/29, 18:52
Posts: 69
Location: Finland
Role: Hobbyist
hsnabn wrote:
EDIT: Well, it appears I can't use your plugin; I get an error on adding a TiledLoader component, a MissingMethodException for Duality.Resources.ShaderProgram.Compile(). Here's the full error: http://pastebin.com/raw.php?i=8j0J3EXH

I wonder why it tries to compile shaders.. Although I can't see how that relates to my plugin? :S


hsnabn wrote:
I also can't import any TSX files. When I drag a file into the project view, nothing happens, not even an error.

Here's an explanation for users willing to test the plugin. (I really should add some readmes and such!)

hsnabn wrote:
I think this might be because of the missing TiledImporter in the EditorPlugin project, but it's not on the Git repository?

I will have a look on that. I thought I did commit it.. :)

hsnabn wrote:
Sorry if you haven't got around to updating the repository: I was just bored and tried to see if I could help.

No problem. I've been struggling with collision shapes so I haven't got it updated properly into GitHub.

Adam wrote:
In any case, the immediate problem here is, as hsnabn said, in your constructor. More specifically, when deserializing the Scene, i.e. turning the saved file into a runtime object again, Duality tries to create an instance of your object TiledMap. Apparently, this object doesn't have a trivial (parameterless) constructor, so it picks the other one it finds, which takes an XmlData object. Because Duality has of course no idea what this parameter means, it tries what happens when it assigns the default value to all parameters, e.g. null in this case. It appears though as your constructor doesn't like this and fails - Duality catches the exception and concludes that it isn't able to construct objects of your Type. It returns null and leaves deserialization with a missing object.

So, one way to fix this is to provide a trivial constructor that can be used during deserialization and cloning operations. You can make it private if you don't want it to be used otherwise.

Looks like I need to revisit the structure of my plugin.


Thanks guys!

_________________
.
..
...
....
What?


Top
 Profile  
 
PostPosted: 2015/12/04, 12:28 
Forum Adept
Forum Adept

Joined: 2015/07/08, 16:41
Posts: 414
Role: Gamer
misthema wrote:
Here's an explanation for users willing to test the plugin. (I really should add some readmes and such!)
Sorry, can't test it out now. I actually deleted the local repository clone half an hour ago, and am too lazy to clone it again. I will test it out later, when I get some time.

Adam wrote:
Because Duality has of course no idea what this parameter means, it tries what happens when it assigns the default value to all parameters, e.g. null in this case.
It would be a nice feature to be able to configure this, and also being able to fix component name change errors in-editor. Isn't there an issue on the GitHub issue tracker for that already?


Top
 Profile  
 
PostPosted: 2015/12/04, 12:38 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
hsnabn wrote:
Adam wrote:
Because Duality has of course no idea what this parameter means, it tries what happens when it assigns the default value to all parameters, e.g. null in this case.
It would be a nice feature to be able to configure this, and also being able to fix component name change errors in-editor. Isn't there an issue on the GitHub issue tracker for that already?


For the renaming thing, yes ^^

The other one is unlikely to change, as it is really easy to deal with (just provide a trivial constructor, or one that works with default parameters) and would introduce a whole new level of complexity to serialization and cloning. It's not even an implementation thing, but adding a feature like this wouldn't really solve the problem - but just add another, more complicated way of dealing with it where a simple one already exists.

Also, you can actually do this with just regular C#:
Code:
public class MyCustomObject
{
   // Hey Duality! Need a parameterless constructor?
   private MyCustomObject() : this("I'm a default value for deserialization") {}

   // For public usage
   public MyCustomObject(object someData)
   {
      // ...
   }
}


Which is, I think, very similar ^^

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2015/12/04, 15:29 
Member
Member
User avatar

Joined: 2015/10/29, 18:52
Posts: 69
Location: Finland
Role: Hobbyist
It's funny that it actually worked. :D Now I haven't got those errors at all. Thanks!

_________________
.
..
...
....
What?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group