COZY Documentation
  • Welcome!
    • πŸ‘‹Hello!
    • πŸ—ΊοΈRoadmap
    • πŸ†˜Support & Community
    • πŸŽ“Changelog
  • Getting Started
    • πŸ”ŒInstallation
    • πŸ› οΈSetting Up Your Project
    • 🌐Creating a New Scene
    • πŸ“¦COZY Samples
  • How it works
    • βš™οΈThe System Perspective
    • ⏱️Meridiem Time
    • 🌈Gradients & Curves
    • βš–οΈWeighted Random Chance (WRC)
    • πŸ§‘β€πŸ«Weather Selection & Forecasting
    • The Weather Sphere
      • 🌌The Sky Dome
      • ☁️The Cloud Dome
        • COZY Desktop Clouds
        • COZY Mobile Clouds
        • Soft Clouds
        • Painted Skies
        • Ghibli Desktop & Mobile Clouds
        • Single Texture Clouds
        • Luxury Clouds
      • 🌫️The Fog Dome
    • Modules
      • 🌌Atmosphere Module
      • πŸ•‘Time Module
      • 🌦️Weather Module
      • πŸƒAmbience Module
      • 🌑️Climate Module
      • ⚑Events Module
      • 🎨Interactions Module
      • ☁️Buto Module
      • 🌎MicroSplat Module
      • 🌳The Vegetation Engine (TVE) Module
      • πŸͺžReflections Module
      • πŸŒ™Satellite Module
      • πŸ—ƒοΈSave & Load Module
      • πŸŒ„Transit Module
      • πŸ’¨Wind Module
      • πŸ•‘System Time Module
      • πŸ›Debug Module
      • ☁️Plume Module
      • πŸŒ‡Blocks Module
      • πŸŒ‘Eclipse Module
      • πŸ“†Habits Module
      • 🎼ReSound Module
      • πŸ”—Link Module
    • Profiles
      • Ambience Profile
      • Atmosphere Profile
      • Forecast Profile
      • Perennial Profile
      • Satellite Profile
      • Material Profile
      • Weather Profile
      • FX Profiles
        • Audio FX
        • Climate FX
        • Cloud FX
        • Event FX
        • Filter FX
        • Multi FX
        • Particle FX
        • Precipitation FX
        • Thunder FX
        • Visual FX
        • Wind FX
      • Climate Profile
    • Biomes
    • Settings
  • Extending COZY
    • Stopping Indoor FX
    • Developing the Render Queue
    • Utilities
  • Integrations
    • Crest Water 4 (URP Only)
    • Crest Water 5
    • Stylized Water 2
    • KWS Water System
    • Generic Shader Graph
    • The Vegetation Engine
    • MicroSplat
  • Appendix
    • Frequently Asked Questions (FAQs)
    • Improving Performance With COZY 3
Powered by GitBook
On this page
  • Overview
  • Key Features
  • Profiles
  • Habits Year
  • Cozy Habit Profile
  • Usage Examples
  • Understanding the UI
  • Habits Listeners
  • API
  • C# Event Listeners

Was this helpful?

  1. How it works
  2. Modules

Habits Module

PreviousEclipse ModuleNextReSound Module

Last updated 1 year ago

Was this helpful?

Overview

Habits overrides the calendar section of the allowing for more precise and extensible events within the COZY ecosystem. Automatically setup repeat patterns, start and end times, multi-day events, routines, and multiple calendars all without leaving the COZY editor. Habits is a "no-code-required" event system, but you can also extend in it easily with Habit listeners via the .

Key Features

  • Setup robust events

  • Manage time with a realistic Gregorian calendar and weekdays.

  • Link events to your world using the Habit Listener script

Profiles

Habits Year

The Habits Year Profile holds references to all of the months of the year (with display names and number of days), the start day of the week, and a list of all of the events used by this calendar. This profile is the core of Habits and provides the module with most of the setup data.

Cozy Habit Profile

The Cozy Habit Module defines the actual events or habits that are triggered in your world. Define repeating patterns, start and end dates, start and end times, and determine when the Habit event is triggered.

While these can be edited in the profiles, it is best to edit them in the actual module UI.

Usage Examples

Understanding the UI

Habits is visible in three different sections that all have different levels of detail and have pros and cons when it comes to editing.

The Toolbar

Each view has a toolbar in the bottom-right corner that lets you add a Habit (new or existing), see and edit the full list of active Habits, and edit the global editor settings to show/hide calendars.

Month View

See the whole month at a glance. See the number of events on all of the days of the month as well as track the weekdays. Select a new day on the calendar to swap to that day. Select the month name at the top of the screen to change the month or use the [ + ] and [ - ] buttons to raise or lower the current month.

Week View

See the current week at a glance. See a few details about each day and look at the Habits that play on each. The white line across all of the days shows you the current time, clicking the day initial will swap to that day and clicking on each Habit's name will let you edit that Habit.

Day View

See all the Habits for today in detail. The white line across all of the days shows you the current time, clicking the plus and minus buttons will increase and decrease the current day, and clicking on each Habit's name will let you edit that Habit.

Habits Listeners

COZY Habit Listeners let you link your Habits directly to Unity Events in the inspector with no code.

Select the Habit that you want to use for the event in the first field and setup your Unity Events in the fields below it. Start Event will be called when the Habit starts playing, Update Event is called every frame that the Habit is active, and End Event is called the last frame that the Habit is active.

API

C# Event Listeners

You can also set up events using C# instead of Cozy Habit Listeners. This is the format that you need to follow to include Habits in your scripts

//Be sure to include the Cozy Namespace
using DistantLands.Cozy;

//...
    
//Reference your habit here:
public CozyHabitProfile habitToUse;

//Add your methods to the event listener when the object is enabled and clean them up when the object is disabled:
void OnEnable()
{
    habitToUse.onStart += StartMethod;
    habitToUse.onUpdate += UpdateMethod;
    habitToUse.onEnd += EndMethod;
}
void OnDisable()
{
    habitToUse.onStart -= StartMethod;
    habitToUse.onUpdate -= UpdateMethod;
    habitToUse.onEnd -= EndMethod;
}


public void StartMethod()
{
    //This method will run when the habit starts.
}
public void UpdateMethod()
{
    //This method will run every frame during the time that the habit is running.
}
public void EndMethod()
{
    //This method will run when the habit ends.
}
πŸ“†
Time Module
API
Page cover image