o3de / sample-code-gems

Sample gems for how to create custom tools that extend the Editor, in both C++ and Python
Other
9 stars 6 forks source link

Added Day 1 ShapeExample tool written in C++ #1

Closed cgalvan closed 3 years ago

cgalvan commented 3 years ago

Added the Day 1 example of a custom tool written in C++. This example gem was built from the CustomTool template, with the following command:

scripts\o3de.bat create-gem -gp ShapeExample --template-name CustomTool

Most of the files are unchanged after creating the gem from the template. The only two files modified that are important to review are ShapeExampleWidget.cpp/h.

This simple tool finds all the registered components that provide the ShapeService, and then create buttons corresponding to all the shape components. When the user clicks one of the buttons, an entity is created and then the corresponding shape component is added to that entity. There is also a text input field for (optionally) setting a custom name when creating the entity, and a checkbox for appending a suffix of the name of the shape.

This is meant to introduce the user to some basic Qt concepts (e.g. buttons, text input, layouts), as well as how to listen to events using signals/slots (e.g. handling a button being clicked). This example also highlights some basic APIs for interacting with the Editor (e.g. creating an entity, adding a component).

ShapeExampleFinalDemo

Signed-off-by: Chris Galvan chgalvan@amazon.com