Skip to content
This repository has been archived by the owner on Jan 9, 2022. It is now read-only.

Creating new feedbacks

Guillem Sunyer Caldú edited this page Nov 11, 2020 · 8 revisions

Home >> Usage guide >> Creating new feedbacks

Creating new feedbacks

Creating new feedbacks is very easy if you know what you are doing. In this section, you will learn all the necessary steps!

Setup:

To start, you need to create a new class that inherits from Feedback. For the feedback to be shown by the FeedbacksPlayer, you will need to add the FeedbackIdentifier attribute, where the first value is the name of the feedback, and the second one is the category.

Next you will need to override the following functions:

  • GetFeedbackErrors: allows the feedback to show error information on the editor, about something that is not properly set up. This error will be shown then as red text error under the feedback. Return true if there is an error and set the message error on the out string errors.

  • GetFeedbackTargetInfo: gets information about the target of the feedback. Normally this is the name of the GameObject, but it can be whatever you want. This text is going to be shown beside the name of the feedback.

  • GetFeedbackInfo: allows for showing important preview information about the feedback, that is going to be shown on the editor when the feedback is collapsed. For every property that you want to show, you need to add a new entry on the ref List infoList, so it's properly formatted.

  • OnExecute: function that is actually called when the feedback starts. We will see more information about this in the following sections.

Variables:

Next, you will need to define which variables do you need to use. The Feedbacks library normally follows the image pattern, but you can do what you please.

Also, you can see that we are using a custom type on the image named StartEndVector3Property. These are custom-made properties that have some extra functionality on the editor, and help keep the inspector clean and compact. Those are the list of custom properties:

  • EasingProperty
  • GraphicMaterialColorProperty
  • GraphicMaterialFloatProperty
  • LoopProperty
  • RendererMaterialColorProperty
  • RendererMaterialFloatProperty
  • StartEndColorNoAlphaProperty
  • StartEndColorProperty
  • StartEndFloatProperty
  • StartEndTransformVector3Property
  • StartEndUnitFloatProperty
  • StartEndVector2Property
  • StartEndVector3Property

There are examples of each of them on the code.

Scripting:

To make sure your new feedback can be modified through scripting, you need to create public acces to your variables, so they can be modified from the outside.

Functionality:

To see how to create functionality, we will follow the TransformPositionFeedback as an example.

Internally, the feedbacks work as a tweening sequence that stack one after the other, so the only thing that we need to do is add our functionality to the sequence stack.

First, we append the delay at the beginning, if there is any.

Next, we append the necessary tweens to create the expected functionality.

Finally, we set the easing and the looping properties.

The ExecuteResult class that is returned needs to receive two different types of sequences, so it shows the progress properly on the editor. First, it needs the delay sequence, and then, the sequence that has all the functionality of the tween.

If you don't have delay nor functionality, you can leave them to null.