Skip to main content

Module Intro

Important Attention Reminder

Coding Style wiki


Basic Instructions

Notice system (also known as Red Dot System). Supports dynamically adding and removing notice conditions, allows custom notice conditions, and registers held conditions on NoticeItem — when any condition held by a NoticeItem matches, the icon (red dot) is shown.

  • Version: v1.0.5 (com.michaelo.oxgkit.noticesystem)
  • Namespace: OxGKit.NoticeSystem

Attention This module depends on LoggingSystem for log output — OxGKit.LoggingSystem must be installed first.


Application Description

Implementing Notice Conditions

Implement notice conditions via Right-Click Create/OxGKit/Notice System/Template Notice Condition.cs. The following templates are available:

  • Template Notice Condition Registers.cs (Manually): condition register template (static class) for registering all notice conditions in one place.
  • Template Notice Condition.cs (Manually): notice condition template; must be registered manually via NoticeManager.RegisterCondition<T>().
  • Template Notice Condition.cs (RuntimeInitializeLoadType.BeforeSceneLoad): notice condition template that auto-registers the condition before the scene loads.

NoticeItem Condition Registration

  • Drag the NoticeItem prefab onto the UI, assign your own ICON, then get the NoticeItem component and register conditions on it.
  • Import the NoticeItem Prefab via Package Manager -> Samples.

Attention When a NoticeItem is OnDestroy, it will automatically Deregister (removing its own held conditions).

Notify on Data Changes

  • When data state changes, you must Notify the specific condition IDs — the system looks up the NoticeItems holding those conditions by ID and refreshes their display.

Important After data changes you must Notify the related condition IDs, otherwise the red dot display will not refresh.


Simple Usage

Implementing a Notice Condition

Inherit NoticeCondition and implement the ShowCondition check (by convention, define a static id property to get the auto-assigned condition ID):

using OxGKit.NoticeSystem;

public class NewMailCond : NoticeCondition
{
#region Default
public static int id { get { return NoticeManager.GetConditionId<NewMailCond>(); } }
#endregion

public override bool ShowCondition(object data)
{
if (data != null)
{
MailBox mailBox = data as MailBox;

// Show the red dot when there is unread mail
if (mailBox.unreadCount > 0) return true;
}

return false;
}
}

Registering Notice Conditions

Register conditions in one place via a condition register (static class), and manually trigger the static constructor at the game entry point:

using OxGKit.NoticeSystem;

public static class NoticeConditionRegister
{
static NoticeConditionRegister()
{
NoticeManager.RegisterCondition<NewMailCond>();
NoticeManager.RegisterCondition<CoinInWalletCond>();
}

/// <summary>
/// Manually trigger static constructor
/// </summary>
public static void Init() { }
}
private void Awake()
{
// Manually trigger the static constructor to complete condition registration
NoticeConditionRegister.Init();
}

Reminder Alternatively, use the RuntimeInitializeLoadType.BeforeSceneLoad template to auto-register conditions before the scene loads.

Registering Conditions on a NoticeItem

After getting the NoticeItem component, register conditions with NoticeInfo (condition ID + data). Registration automatically checks conditions and refreshes the display:

using OxGKit.NoticeSystem;

public NoticeItem mailNoticeItem;

private MailBox _mailBox = new MailBox();

private void Awake()
{
// A single NoticeItem can hold multiple conditions (the red dot shows when any condition matches)
this.mailNoticeItem.RegisterNotice
(
new NoticeInfo(NewMailCond.id, this._mailBox)
);
}

Notifying to Refresh on Data Changes

// Data changes
this._mailBox.unreadCount++;

// Way 1: Notify condition IDs via NoticeManager (best efficiency)
NoticeManager.Notify(NewMailCond.id);

// Way 2: RegisterNotice again with the condition and data (renews the data and auto-refreshes)
this.mailNoticeItem.RegisterNotice(new NoticeInfo(NewMailCond.id, this._mailBox));

// Way 3: Notify via NoticeManager with NoticeItems
NoticeManager.Notify(this.mailNoticeItem);

// Way 4: Notify directly from the NoticeItem for its own held conditions
this.mailNoticeItem.Notify();

Reminder Efficiency: Way 1 > Way 2 > Way 3 > Way 4; Convenience: Way 2 > Way 3 > Way 4 > Way 1.

Important For value-type data (such as int), NoticeInfo.data stores a snapshot — after the data changes, you must first update it via RenewNotice or by calling RegisterNotice again, then Notify; reference-type data is held by reference, so Notify alone is enough after changes.

// Value-type data: RenewNotice to update the data first, then Notify to refresh (Method Chaining)
this._coin++;
this.coinNoticeItem.RenewNotice(new NoticeInfo(CoinInWalletCond.id, this._coin)).Notify();

[Refer to Example]


Installation

Install via git URL
Add https://github.com/michael811125/OxGKit.git?path=Assets/OxGKit/NoticeSystem/Scripts to Package Manager

Third-Party Libraries (must be installed manually)

Samples (Package Manager -> Samples)

  • AI Agent Skills (refer to AI Agent Skills)
  • NoticeItem Prefab
  • NoticeSystem Demo

Module API


Demo

NoticeSystem Demo