SkillAgentSearch skills...

OxGKit

The OxGKit is a system tool kit commonly used in game development based on Unity design (all are independent tools).

Install / Use

/learn @michael811125/OxGKit

README

<p align="center"> <img width="384" height="384" src="Docs/OxGKit_Logo_v1.png"> </p>

License


基本介紹

OxGKit 是基於 Unity 設計於遊戲開發常用的系統工具組 (皆為獨立工具)。

TODO 未來會補充 OxGKit 的文檔

Coding Style wiki

目前包含以下

[會持續擴充工具系統組]


工具系統介紹

LoggingSystem (dependence LWMyBox)

日誌系統,支持 Cipher & Plaintext (可以任意轉換),支持動態配置與覆寫原有的日誌器功能,其他還有全域開關配置、全域級別配置、全域顏色配置、個別開關配置、個別級別配置、個別顏色配置。

  • 透過 Right-Click Create/OxGKit/Logging System/Create loggersconfig.conf (自動存於 StreamingAssets) 建立配置文件,方便真機修改 loggersconfig.conf 配置進行調適。
  • 透過 LoggingLauncher 進行配置或只直接修改 StreamingAssets/loggersconfig.conf 文件。

Build 激活宏

  • OXGKIT_LOGGER_ON

配置文件編碼格式轉換。

  • 提醒:發布建議使用 Cipher。

LoggingLauncher 配置介面,可以配置 logActive (開關)、logLevel (級別)、logColor (顏色)。

  • 透過 Package Manager -> Samples 匯入 LoggingLauncher Prefab,再拖曳至場景上激活環境配置 (僅需激活一次),會自動嘗試加載 StreamingAssets/loggersconfig.conf 進行日誌開關控制。

Log Level 可切換為以下:

  • LogDebug (Print)
  • LogInfo (PrintInfo)
  • LogWarning (PrintWarning)
  • LogError (PrintError)
  • LogException (PrintException)

表格符號說明:

  • G = Global (全域設定 / Master Logging Level)。
  • P = Per-Logger (個別 Logger 的設定)。
  • Gx = 單一全域級別:LogDebug / LogInfo / LogWarning / LogError / LogException。
  • Px = 單一個別級別:LogDebug / LogInfo / LogWarning / LogError / LogException。
  • G ∩ P = 旗標交集 (bitwise AND),代表同時被全域與個別允許的級別集合。

總結規則:只有當 G 與 P 都包含該級別時,該級別 (Log Level) 才會進行輸出。

| 全域 (G) | 個別 (P) | 生效級別 (輸出) | | ----------- | ---------- | ---------------------------------------------- | | Off | Any | ✗ | | Any | Off | ✗ | | All | All | DEBUG / INFO / WARNING / ERROR / EXCEPTION → ✓ | | All | 單一 Px | Px → ✓ | | 單一 Gx | All | Gx → ✓ | | 單一 Gx | 單一 Px | 若 Gx = PxGx → ✓;否則 ✗ | | 任意集合 G | 任意集合 P | G ∩ P → ✓;若無交集 → ✗ |

Log Color 可切換為以下:

  • Disabled
  • Enabled
  • EditorOnly (發布時,不進行 RichText 上色處理)

| 全域 (G) | 個別 (P) | 生效模式 | Editor | Player / 發布 | | ----------- | ---------- | ---------- | ------ | --------- | | Disabled | Any | Disabled | ✗ | ✗ | | Enabled | Disabled | Disabled | ✗ | ✗ | | EditorOnly | Disabled | Disabled | ✗ | ✗ | | Enabled | Enabled | Enabled | ✓ | ✓ | | Enabled | EditorOnly | EditorOnly | ✓ | ✗ | | EditorOnly | Enabled | EditorOnly | ✓ | ✗ | | EditorOnly | EditorOnly | EditorOnly | ✓ | ✗ |

新增 Logger 或移除 Logger,皆需呼叫 LoggingLauncher.TryLoadLoggers() 進行重載 (建議定義一個 default constructor,避免搭配 HybridCLR + Activator.CreateInstance(type) 出現錯誤)。

using OxGKit.LoggingSystem;

[LoggerName("MyLogger")]
public class MyLogger1 : Logging 
{
    // If use HybridCLR must create a default constructor
    public MyLogger1() { }
}

進行原有 Logger 的 Override

// Use same name to override MyLogger1
[LoggerName("MyLogger", true)]
public class OverrideMyLogger1 : Logging 
{
    // If use HybridCLR must create a default constructor
    public OverrideMyLogger1() { }

    public override void Log(object message)
    {
        UnityEngine.Debug.Log("[Override]" + message);
    }

    public override void LogInfo(object message)
    {
        UnityEngine.Debug.Log("[Override]" + message);
    }

    public override void LogWarning(object message)
    {
        UnityEngine.Debug.LogWarning("[Override]" + message);
    }

    public override void LogError(object message)
    {
        UnityEngine.Debug.LogError("[Override]" + message);
    }

    public override void LogException(Exception exception)
    {
        UnityEngine.Debug.LogException(exception);
    }
}

如果搭配 HybridCLR 有主工程跟熱更工程的區分,必須手動拆分創建 AOT 跟 Hotfix 的 Loggers 初始流程,可以參考以下:

// HybridCLR (必須取消 LoggingLauncher 上的 "Initialize On Awake" 選項):
LoggingLauncher.CreateLogger<LoggingDemoLogger1>();
LoggingLauncher.CreateLogger<LoggingDemoLogger2>();
LoggingLauncher.CreateLogger<LoggingDemoLogger3>();
LoggingLauncher.CreateLogger<LoggingDemoLogger4>();
LoggingLauncher.TryLoadLoggers();

動態配置日誌器,參考如下:

// Reload LoggersConfig at Runtime (方式一)
var loggersConfig = new LoggersConfig
(
    new LoggerSetting("LoggingDemo.Logger1", true, LogLevel.Log),
    new LoggerSetting("LoggingDemo.Logger2", true, LogLevel.LogWarning),
    new LoggerSetting("LoggingDemo.Logger3", true, LogLevel.Off)
);
LoggingLauncher.SetLoggersConfig(loggersConfig);

// Reload LoggersConfig at Runtime (方式二)
LoggingLauncher.ConfigureLogger("LoggingDemo.Logger1", false);
LoggingLauncher.ConfigureLogger("LoggingDemo.Logger2", true, LogLevel.LogWarning | LogLevel.LogError);
LoggingLauncher.ConfigureLogger("LoggingDemo.Logger3", false);

以下是在 AOT 工程中初始 AOT 工程的 Loggers (如果 Hotfix 工程的 Loggers 需要再 Hotfix 工程中初始)

[參考 Example]

Installation

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

第三方庫 (需自行安裝)

LoggingSystem Demo

https://github.com/michael811125/OxGKit/assets/30960759/51ecddd7-5241-43e9-9104-de45cbc5f68d

LoggingSystem Build Test

https://github.com/michael811125/OxGKit/assets/30960759/cef1a484-d617-466d-bf3e-6104032d7c3f


InfiniteScrollView (dependence UniTask, OxGKit.LoggingSystem)

無限列表 (魔改版),基於原生 UGUI 能夠簡單的繼承或使用現有的 Infinite ScrollView,以物件池的概念進行物件有效循環利用。

Reference: howtungtung - InfiniteScrollView

[參考 Example]

Installation

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

第三方庫 (需自行安裝)

  • 使用 UnitTask v2.5.0 or higher
  • 使用 OxGKit.LoggingSystem, Add https://github.com/michael811125/OxGKit.git?path=Assets/OxGKit/LoggingSystem/Scripts to Package Manager

※備註 : Right-Click Create/OxGKit/Infinite ScrollView... (Template cs)


ActionSystem (dependence UniTask, OxGKit.LoggingSystem)

動作序列系統,能夠自行定義 Action 並且自行組合運行組,預設 Actions 有 SequenceAction, ParallelAction, ParallelDelayAction, DelayAction, DelegateAction,另外如果針對動畫需要進行拼湊處理,也可以使用 ActionSystem 作為運行。

  • 透過 Right-Click Create/OxGKit/Action System/Template Action.cs 實作自定義 Action。

[參考 Example]

Installation

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

第三方庫 (需自行安裝)

  • 使用 UnitTask v2.5.0 or higher
  • 使用 OxGKit.LoggingSystem, Add https://github.com/michael811125/OxGKit.git?path=Assets/OxGKit/LoggingSystem/Scripts to Package Manager

ActionSystem Demo

https://github.com/michael811125/OxGKit/assets/30960759/169d91ea-3709-420c-8751-f50119e97d35

※備註 : Right-Click Create/OxGKit/Action System... (Template cs)


NoticeSystem or RedDotSystem (dependence OxGKit.LoggingSystem)

通知系統 (也稱紅點系統),支援動態新增刪除通知條件,可以自行定義通知條件,再針對 NoticeItem 進行條件持有註冊,當 NoticeItem 身上其中持有任一符合條件則通知顯示圖示 (紅點)。

View on GitHub
GitHub Stars56
CategoryDevelopment
Updated2mo ago
Forks10

Languages

C#

Security Score

100/100

Audited on Jan 25, 2026

No findings