{"id":27096248,"url":"https://github.com/safakb/pixevent","last_synced_at":"2026-05-01T02:32:32.292Z","repository":{"id":284839533,"uuid":"956230926","full_name":"SafakB/PixEvent","owner":"SafakB","description":"PixEvent (Pub/Sub) – Lightweight Event System for Unity","archived":false,"fork":false,"pushed_at":"2025-03-27T23:14:01.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-06T21:42:20.190Z","etag":null,"topics":["event-driven","event-emitter","eventbus","unity","unity-3d","unity-package","unity3d"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SafakB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-27T23:01:28.000Z","updated_at":"2025-03-28T20:54:12.000Z","dependencies_parsed_at":"2025-03-28T00:35:58.959Z","dependency_job_id":null,"html_url":"https://github.com/SafakB/PixEvent","commit_stats":null,"previous_names":["safakb/pixevent"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SafakB/PixEvent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SafakB%2FPixEvent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SafakB%2FPixEvent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SafakB%2FPixEvent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SafakB%2FPixEvent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SafakB","download_url":"https://codeload.github.com/SafakB/PixEvent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SafakB%2FPixEvent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32483406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-driven","event-emitter","eventbus","unity","unity-3d","unity-package","unity3d"],"created_at":"2025-04-06T09:37:32.897Z","updated_at":"2026-05-01T02:32:32.277Z","avatar_url":"https://github.com/SafakB.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PixEvent (Pub/Sub) – Lightweight Event System for Unity\n\nPixEvent is a powerful and flexible **event management system** built for Unity projects. It allows developers to subscribe to events with priority, conditional logic, one-time execution, and synchronous/asynchronous delivery. Its simple structure makes it easy to integrate, extend, and test.\n\n## 🔧 Features (Index)\n\n1. [Event System Introduction](#1-event-system-introduction)\n2. [Subscription Mechanisms](#2-subscription-mechanisms)\n   - Standard Subscription\n   - One-Time Subscription\n   - Conditional Subscription\n3. [Publishing Events](#3-publishing-events)\n4. [Unsubscribing](#4-unsubscribing)\n5. [Using Empty Events](#5-using-empty-events)\n6. [Logging Support](#6-logging-support)\n7. [Helpful Utility Methods](#7-helpful-utility-methods)\n\n---\n\n## 1. Event System Introduction\n\nPixEvent enables communication via any class that implements the `IEvent` interface. This supports a loosely-coupled communication model across systems.\n\n---\n\n## 2. Subscription Mechanisms\n\n### Standard Subscription\n\n```csharp\nPixEvent.Subscribe\u003cMyEvent\u003e(OnMyEvent, priority: 10, async: false);\n```\n\nAllows setting callback priority and asynchronous execution.\n\n#### Asynchronous Subscription Example\n\nFor heavy or long-running tasks, use `async: true` to run the callback on a separate thread:\n\n```csharp\nPixEvent.Subscribe\u003cMyEvent\u003e(evt =\u003e { \n    Debug.Log(\"Heavy async process started...\");\n    Task.Delay(1000).Wait();\n    Debug.Log(\"Heavy async process done.\");\n}, async: true);\n```\n\n\u003e ⚠️ Note: In this example, `Task.Delay().Wait()` is used for demonstration. In Unity environments, using true `async/await` can require additional handling or libraries like UniTask.\n\n---\n\n### One-Time Subscription\n\n```csharp\nPixEvent.OneTimeSubscribe\u003cMyEvent\u003e(OnMyEvent);\n```\n\nCallback is triggered only once and then unsubscribed automatically.\n\n---\n\n### Conditional Subscription\n\n```csharp\nPixEvent.ConditionalSubscribe\u003cMyEvent\u003e(\n    condition: e =\u003e e.Value \u003e 5,\n    callback: OnMyEvent\n);\n```\n\nCallback is triggered only when the event data satisfies the given condition.\n\n---\n\n## 3. Publishing Events\n\n```csharp\nPixEvent.Publish(new MyEvent { Value = 10 }, delayMs: 200);\n```\n\nEvents can be published with an optional delay. Subscribers are called in descending order of priority.\n\n---\n\n## 4. Unsubscribing\n\n### Remove a Specific Callback\n\n```csharp\nPixEvent.Unsubscribe\u003cMyEvent\u003e(OnMyEvent);\n```\n\n### Remove All Subscribers\n\n```csharp\nPixEvent.UnsubscribeAll\u003cMyEvent\u003e();\n```\n\n---\n\n## 5. Using Empty Events\n\nFor simple event calls that don't require parameters, use the `EmptyEvent` class:\n\n```csharp\nPixEvent.Subscribe(() =\u003e Debug.Log(\"Triggered\"));\nPixEvent.Publish();\n```\n\n---\n\n## 6. Logging Support\n\nEnable logging for internal operations:\n\n```csharp\nPixEvent.LogEvents = true;\n```\n\n---\n\n## 7. Helpful Utility Methods\n\n### Check for Subscribers\n\n```csharp\nif (PixEvent.HasSubscribers\u003cMyEvent\u003e())\n{\n    // At least one subscriber exists\n}\n```\n\n---\n\n## 📌 Notes\n\n- Higher `priority` means the callback runs earlier.\n- Callbacks marked with `async = true` are executed on separate threads.\n- Exceptions are automatically logged via Unity’s `Debug.LogError`.\n\n---\n\n## 👨‍💻 Example Usage\n\n```csharp\npublic class MyEvent : IEvent\n{\n    public string Message;\n}\n\n// Subscribe\nPixEvent.Subscribe\u003cMyEvent\u003e(e =\u003e Debug.Log(e.Message));\n\n// Publish\nPixEvent.Publish(new MyEvent { Message = \"Hello World\" });\n```\n\n---\n\nThis system helps you build more modular, readable, and maintainable code structures.\n\n## 📄 License\n\nThis project is licensed under the MIT License. You are free to use, copy, distribute, and modify the software. However, the software is provided \"as is\", without warranty of any kind.\n\nAll rights reserved © 2025 Şafak Bahçe","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsafakb%2Fpixevent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsafakb%2Fpixevent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsafakb%2Fpixevent/lists"}