Skip to content

Steps to add a new Component

Zsuró Tibor edited this page May 11, 2023 · 5 revisions

Components allow you add additional data or functionality to a GameObject. See existing components here. Developing a new Component for GameObjects requires multiple steps:

  • Add your new component's value into enum in Component class.

  • Create your new Component class in the com.mbrlabs.mundus.commons.scene3d.components package.

  • In your new Component class you could implement Component interface but there is an AbstractComponent you can extend from for convenience. If your component is designed to be rendered (contains a ModelInstance) then consider extending from CullableComponent so that it can be culled for performance. Use your enum value in type field.

  • Update GameObjectInspector.kt to include your Component class in the Inspector Widget (right pane). You can create a new Widget class for your component which displays any relevant fields for your component and allows users to alter the data within it.

  • Update AddComponentDialog.kt to enable adding your component to GameObjects from the UI (if applicable)

  • Mundus uses DTO objects for saving data. You will want to create a DTO java object for your new Component, and update both GameObjectConverter.java classes (one in editor module, one in runtime module) to handle converting your DTO -> Component and Component -> DTO for saving.

  • Add your DTO class to https://github.com/JamesTKhan/Mundus/blob/master/commons/src/main/commons.gwt.xml for GWT

  • Test your component. Make sure the component data persists when closing and reopening the editor. Make sure the component data loads when in the runtime, and that GWT is working.