{"id":21358880,"url":"https://github.com/gameframex/com.gameframex.unity.mono","last_synced_at":"2025-03-16T06:17:59.450Z","repository":{"id":232532657,"uuid":"784181731","full_name":"GameFrameX/com.gameframex.unity.mono","owner":"GameFrameX","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-21T09:42:58.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-22T18:51:07.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GameFrameX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-04-09T10:52:15.000Z","updated_at":"2024-09-21T09:43:02.000Z","dependencies_parsed_at":"2024-04-10T06:32:43.214Z","dependency_job_id":"3ca62f42-831b-4804-838c-529ea664cb92","html_url":"https://github.com/GameFrameX/com.gameframex.unity.mono","commit_stats":null,"previous_names":["alianblank/com.alianblank.gameframex.unity.mono","gameframex/com.gameframex.unity.mono"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.mono","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.mono/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.mono/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.mono/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GameFrameX","download_url":"https://codeload.github.com/GameFrameX/com.gameframex.unity.mono/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830950,"owners_count":20354856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-22T05:22:45.217Z","updated_at":"2025-03-16T06:17:59.423Z","avatar_url":"https://github.com/GameFrameX.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿## HOMEPAGE\n\nGameFrameX 的 Mono 生命周期组件\n\n**Mono 生命周期组件 (Mono Component)** - 用于管理游戏中 MonoBehaviour 的事件和更新周期，例如 FixedUpdate、LateUpdate、OnDestroy\n等，并提供了一种简便的方式来添加和移除这些事件的监听。\n\n# 使用文档(文档编写于GPT4)\n\n关于 `MonoComponent` 类的说明文档如下：\n\n## 概述\n\n`MonoComponent` 类是基于 Unity 引擎的一个自定义 C# 脚本，它扩展自 `GameFrameworkComponent` 类。它用于管理游戏中 MonoBehaviour 的事件和更新周期，例如 FixedUpdate、LateUpdate、OnDestroy\n等，并提供了一种简便的方式来添加和移除这些事件的监听。\n\n## 功能特点\n\n- **MonoManager 集成**: 该类与 `MonoManager` 协作，MonoManager 是用来管理 MonoBehaviour 生命周期相关事件的。\n- **事件管理器**: 利用 `IEventManager` 实例来发布和订阅游戏事件。\n- **生命周期监听**: 通过公共方法，允许添加和移除不同生命周期事件的监听，例如更新（Update）、固定更新（FixedUpdate）等。\n\n## 使用方法\n\n1. **初始设置**: 在类初始化时（`Awake` 方法内），会尝试获取 `IMonoManager` 和 `IEventManager` 模块。（如果获取失败，会记录一个致命错误并停止进一步执行。）\n\n2. **事件注册和注销**:\n    - **FixedUpdate**: 使用 `AddFixedUpdateListener(Action fun)` 来添加 FixedUpdate 事件的监听，使用 `RemoveFixedUpdateListener(Action fun)` 来移除监听。\n    - **LateUpdate**: 使用 `AddLateUpdateListener(Action fun)` 来添加 LateUpdate 事件的监听，使用 `RemoveLateUpdateListener(Action fun)` 来移除监听。\n    - **OnDestroy**: 使用 `AddDestroyListener(Action fun)` 来添加 OnDestroy 事件的监听，使用 `RemoveDestroyListener(Action fun)` 来移除监听。\n    - **OnApplicationFocus**: 使用 `AddOnApplicationFocusListener(Action\u003cbool\u003e fun)` 来添加 OnApplicationFocus 事件的监听，使用 `RemoveOnApplicationFocusListener(Action\u003cbool\u003e fun)` 来移除监听。\n    - **OnApplicationPause**: 使用 `AddOnApplicationPauseListener(Action\u003cbool\u003e fun)` 来添加 OnApplicationPause 事件的监听，使用 `RemoveOnApplicationPauseListener(Action\u003cbool\u003e fun)` 来移除监听。\n\n3. **监听器方法**: 以上添加和移除监听的方法都会进行非空检查，如果传入的回调函数是 `null`，会记录一个致命错误。这是为了维护程序的健壮性。\n\n## 开发者提示\n\n- 调用公共方法之前请确保 `MonoComponent` 实例已处于激活状态。\n- 当编写监听器回调函数时，请注意不要在这些函数中执行耗时操作，以免影响游戏性能。\n- 正确管理事件监听器的注册和注销可以帮助避免内存泄露等问题。\n\n注意：此组件依赖于Event 组件：https://github.com/AlianBlank/com.alianblank.gameframex.unity.event\n\n# 使用方式(任选其一)\n\n1. 直接在 `manifest.json` 的文件中的 `dependencies` 节点下添加以下内容\n   ```json\n      {\"com.gameframex.unity.mono\": \"https://github.com/AlianBlank/com.gameframex.unity.mono.git\"}\n    ```\n2. 在Unity 的`Packages Manager` 中使用`Git URL` 的方式添加库,地址为：https://github.com/AlianBlank/com.gameframex.unity.mono.git\n\n3. 直接下载仓库放置到Unity 项目的`Packages` 目录下。会自动加载识别","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgameframex%2Fcom.gameframex.unity.mono","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgameframex%2Fcom.gameframex.unity.mono","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgameframex%2Fcom.gameframex.unity.mono/lists"}