Rhythm Game Starter
  • 🎹Rhythm Game Starter
  • 🌈Showcase
  • 💡FAQ
  • 💻Demo
  • Quick Start
  • ➡️Getting Started
    • Template Workflow
    • Bare Workflow
  • ⭐Components Overview
    • Input Handling [New]
    • Song Manager
    • Stats System
    • Track Manager
    • Track
  • 🎙️Importing Songs
  • 🎼Creating Song Map
    • Recording Mode [0.5+]
    • Sequence Editor
    • Midi Import
      • Track Mapping
      • Note Type Mapping
  • ⏯️Control Song Play / Pause
  • ✨Customization
    • Custom Notes
    • Customize note instance in runtime
    • Note Effects
  • Integration
    • Naninovel
  • Advance
    • Asmdef
  • Notices
    • ⚠️ Limitations
  • Development
    • 💡Development Tips
    • 🔧Changelog
  • Support
    • 💬Discord
    • Asset Store
    • Main Site
Powered by GitBook
On this page

Was this helpful?

  1. Customization

Customize note instance in runtime

PreviousCustom NotesNextNote Effects

Last updated 3 years ago

Was this helpful?

Overview

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

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

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

ColorfulNotesHandler.cs OnNoteInit method
//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;
}
✨