# Customize note instance in runtime

### Overview

You can link up your own method to do a custom logic when a note is being initialized.

![](https://32629026-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M76iL7-CNlRUwW2lAqS%2F-Mi-S7Abxq_Tg9iEM6QM%2F-Mi-WqPaM5QR4-boZK2X%2Fimage.png?alt=media\&token=ac3ddf40-ed6b-446c-adb1-8c05bef19571)

Examples from the Colorful Demo, check out the Colorful Notes Handler, which linked up with multiple event callbacks from RhythmCore.

![](https://32629026-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M76iL7-CNlRUwW2lAqS%2F-Mi-S7Abxq_Tg9iEM6QM%2F-Mi-XJitxPM4RRkKbtL9%2Fimage.png?alt=media\&token=8b11de6c-d133-4dd8-8ac6-66780eb81b84)

Example code to set the note to a random color on init.

{% code title="ColorfulNotesHandler.cs OnNoteInit method" %}

```csharp
//For receiving call back from the TrackManager's (onNoteInit) event, when a note is being init
public void OnNoteInit(Note note)
{
    var selectedColor = randomColors[Random.Range(0, randomColors.Count)];
    //Loop through all the notes, then assign a random color to them
    foreach (var renderer in note.GetComponentsInChildren<SpriteRenderer>())
    {
        if (renderer.name != "Swipe Indicator")
            renderer.color = selectedColor.color;
    }
    //We appends the color name to the the note object, so we can recognize it back later on
    note.name = selectedColor.name;
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bennykok.gitbook.io/rhythm-game-starter/note-prefab/customize-note-instance-in-runtime.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
