GodotECS/godex

Cannot add system

winston-yallow opened this issue · 3 comments

Description

When adding a system via UI it will not become available to use.

Steps to reproduce

  1. Create new Project
  2. Create scene with WorldECS node
  3. Create Pipeline
  4. Add gdscript file extending System
  5. Click on "New system / component" in the ECS plugin
  6. Enter script filename and click "Create"

Here is the system script I used:

extends System

func _prepare():
	with_databag(ECS.FrameTime, IMMUTABLE)
	with_component(ECS.TransformComponent, MUTABLE)

func _for_each(frame_time, transform):
	var new_basis = transform.transform.basis.rotated(Vector3.UP, frame_time.delta)
	transform.transform.basis = new_basis

System/Version

OS: Solus x86_64 (Kernel 5.11.6-174.current)
Godot: godotengine/godot@ae6b2d6e
Godex: 59a955b

Additional Information

I tried debugging this a bit but did not find a solution yet (and don't have much time to investigate further). Here is what I found so far:

  • the system seems to validate fine
  • everything works up to the point where EditorEcs::save_script() is called
  • when the setting is read into the array, it will result in an empty array

This is a snippet from my project.godot file after trying to register the system:

[ECS]
System/scripts="MySystem.gd"

To me this looks like it is saved as a string instead of an array. Could this be a hint to the problem?

I just noticed that when I manually edit the project.godot file to use an array then it works:

[ECS]
System/scripts=[ "MySystem.gd" ]

This will show up correctly in the UI and reading the setting into an array works.

The components are taken but are not available too.

Nice catch, it was adding p_script_path instead of the array scripts.

@ bool EditorEcs::save_script(const String &p_setting_list_name, const String &p_script_path) {
	....
	scripts.push_back(p_script_path);
-	ProjectSettings::get_singleton()->set_setting(p_setting_list_name, p_script_path);
+	ProjectSettings::get_singleton()->set_setting(p_setting_list_name, scripts);

Fixed with: #128