Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleted Component cause error for the blueprints editor #49

Open
donxu29 opened this issue May 5, 2017 · 3 comments
Open

Deleted Component cause error for the blueprints editor #49

donxu29 opened this issue May 5, 2017 · 3 comments
Labels

Comments

@donxu29
Copy link

donxu29 commented May 5, 2017

Correct me if I'm wrong, I thought the advantage of the ECS is that if I want to delete a feature, I just need to delete the folder. But I notice that when I renamed a certain component, it causes the blueprint editor to fail to open. And I need to open the XML file to delete the component from the entities it attaches with to make the editor working again. Is there a way, maybe a new feature that once a component is missing, the entity blueprints just automatically detach the component? Good idea? ;) Bad idea? :o

@coeing
Copy link
Member

coeing commented May 7, 2017

Hi Don,
It's okay that there is some kind of warning if you delete a component that is still used by a blueprint. But it should still be possible to open the blueprint editor anyway. So I will have a look at it :)
Automatically detaching it is not the best idea, because a dev may think that a component isn't used anymore, deletes it and doesn't realize immediately that a blueprint was still using it. There should be at least a warning about it.

@coeing coeing added the bug label May 7, 2017
@coeing
Copy link
Member

coeing commented Jul 24, 2017

I can confirm that an exception is thrown

TypeLoadException: Unable to find type Slash.Examples.HelloWorld.Components.PositionComponent.
Slash.Reflection.Utils.ReflectionUtils.FindType (System.String fullName) (at Assets/SlashFramework/Slash.Reflection/Utils/ReflectionUtils.cs:62)
System.Linq.Enumerable+c__Iterator102[System.String,System.Type].MoveNext () System.Collections.Generic.List1[System.Type].AddEnumerable (IEnumerable1 enumerable) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:128) System.Collections.Generic.List1[System.Type]..ctor (IEnumerable1 collection) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:65) System.Linq.Enumerable.ToList[Type] (IEnumerable1 source)
Slash.ECS.Blueprints.Blueprint.set_ComponentTypesSerialized (System.String[] value) (at Assets/SlashFramework/Slash.ECS.Blueprints/Blueprint.cs:122)
Slash.ECS.Blueprints.Blueprint.ReadXml (System.Xml.XmlReader reader) (at Assets/SlashFramework/Slash.ECS.Blueprints/Blueprint.cs:311)

The question is how the case should be handled that a component type doesn't exist anymore when the blueprint xml is loaded.

Requirements for a solution:

  • The user is informed about the missing type, otherwise a component may be removed by accident
  • The blueprint editor is still usable and the component can be removed there if it is really not necessary anymore

Therefore the blueprint editor has to work without the types, but with the serialized type names.

@coeing
Copy link
Member

coeing commented Jul 24, 2017

Adjusting the Blueprint class would mean that it had to store a list of type names as well as the list of the component types. But the list of type names is only required in the editor and shouldn't be loaded at runtime.

This means we need a separate data class (BlueprintData?) which is used for the editor and for the serialization/deserialization. A positive side effect would be that this class could be used for Json serialization as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants