Skip to content

flingengine/imgui_entt_entity_editor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imgui_entt_entity_editor

A drop-in, single-file entity editor for EnTT, with ImGui as graphical backend.

demo-code (live)

example usage

struct Transform {
	float x = 0.f;
	float y = 0.f;
};

struct Velocity {
	float x = 0.f;
	float y = 0.f;
};

namespace Widgets {
	void Velocity(::Velocity& v) {
		ImGui::DragFloat("x##Velocity", &v.x, 0.1f);
		ImGui::DragFloat("y##Velocity", &v.y, 0.1f);
	}
} // Widgets

entt::registry reg;

MM::ImGuiEntityEditor<decltype(reg)> editor;

// "registerTrivial" registers the type, name, create and destroy functions for trivialy costructable(and destroyable) types.
// you just need to provide a "widget" function if you use this method.
editor.registerTrivial<Transform>(reg, "Transform");
editor.registerTrivial<Velocity>(reg, "Velocity");

editor.registerComponentWidgetFn(
	reg.type<Transform>(),
	[](entt::registry& reg, auto e) {
		auto& t = reg.get<Transform>(e);

		// the "##Transform" ensures that you can use the name "x" in multiple lables
		ImGui::DragFloat("x##Transform", &t.x, 0.1f);
		ImGui::DragFloat("y##Transform", &t.y, 0.1f);
	});

editor.registerComponentWidgetFn(
	reg.type<Velocity>(),
	[](entt::registry& reg, auto e) {
		auto& v = reg.get<Velocity>(e);
		Widgets::Velocity(v);
	});

dependencies

The editor uses (the latest) EnTTv3.1.0 interface and ImGui 1.72b but should work with prior versions. (tested with ImGui 1.68) To use it with EnTTv3.0.0, use the dedicated branch.

About

A drop-in entity editor for EnTT with ImGui

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 97.0%
  • CMake 3.0%