{"id":19489037,"url":"https://github.com/comradevanti/unitygameobjectaspect","last_synced_at":"2025-02-25T19:25:59.152Z","repository":{"id":174971480,"uuid":"653112624","full_name":"ComradeVanti/UnityGameObjectAspect","owner":"ComradeVanti","description":"Aspect-oriented programming for Unity GameObjects","archived":false,"fork":false,"pushed_at":"2024-03-19T10:32:10.000Z","size":25,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T08:34:19.869Z","etag":null,"topics":["aspect","aspect-oriented-programming","gameobject","package","unity","unity3d","utility"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ComradeVanti.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-06-13T12:33:00.000Z","updated_at":"2023-06-26T08:56:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"469535c9-f183-4905-893d-5bfe8f339be1","html_url":"https://github.com/ComradeVanti/UnityGameObjectAspect","commit_stats":null,"previous_names":["comradevanti/unitygameobjectaspect"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComradeVanti%2FUnityGameObjectAspect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComradeVanti%2FUnityGameObjectAspect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComradeVanti%2FUnityGameObjectAspect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComradeVanti%2FUnityGameObjectAspect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ComradeVanti","download_url":"https://codeload.github.com/ComradeVanti/UnityGameObjectAspect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240731484,"owners_count":19848531,"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":["aspect","aspect-oriented-programming","gameobject","package","unity","unity3d","utility"],"created_at":"2024-11-10T21:07:07.969Z","updated_at":"2025-02-25T19:25:59.110Z","avatar_url":"https://github.com/ComradeVanti.png","language":"C#","readme":"# Unity GameObject Aspect\n\nAspect-oriented programming for Unity GameObjects\n\n[![openupm](https://img.shields.io/npm/v/dev.comradevanti.gameobject-aspect?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/dev.comradevanti.gameobject-aspect/)\n\n[Changelog](./CHANGELOG.md)\n\n**⚠️ Development is paused ⚠️**  \nNo new features will be added or bugs fixed unless requested through an issue.  \nIf you wish to fork this repository and continue the work, you are very welcome\nto do so.\n\n---\n\nThis package allows the user to define types or classes of GameObjects.\nFor example you can say that all GameObjects witch contains a `RigidBody` and\na `Collider` are `PhysicsObjects`. Such a type of GameObject is called an\n**aspect**.\n\nYou can then test if GameObjects have a defined aspect in order to guarantee\nthat it has required components.\n\n```csharp\n\n// Aspects are interfaces\n// They must implement IGameObjectAspect\npublic interface IPhysicsObject : IGameObjectAspect {\n\n    // Add component requirements using read-only properties\n    \n    public RigidBody RigidBody { get; }\n    \n    public Collider Collider { get; }\n\n    // Any other types of members, such as methods, are not allowed\n}\n\n// Attempt to get the aspect from some GameObject\nvar physicsObject = someGameObject.TryAspect\u003cIPhysicsObject\u003e();\n\n// Will be null if game-object does not have the required components\nif(phyicsObject != null) {\n\n    // Do something with the components \n    physicsObject.RigidBody ...\n    phsysicsObject.Collider ...\n}\n\n```\n\n## Features\n\nCurrently properties of the following types are supported in aspects\n\n- GameObject - Will always point to the host game-object\n- Single Components - Searches for the component on the host game-object\n    - This also works with interfaces such as searching for `IXRInteractable`\n\nAttempt to get an aspect from a `GameObject` using the `TryAspect`extension\nmethod.\n\n```csharp\ngameObject.TryAspect\u003cIMyAspect\u003e();\n\n// You can also use TryAspect on components and other aspects\n\ntransform.TryAspect\u003cIMyAspect\u003e();\nsomeAspect.TryAspect\u003cIMyAspect\u003e();\n```\n\nYou can compare aspects using `Equals` which will be true if the stem from the\nsame game-object.\n\n## Installation\n\nInstall via OpenUpm using `openupm add dev.comradevanti.gameobject-aspect`\n\n### Compatibility\n\nDesigned with/for Unity 2021.3 and up. Should work on all build targets.\n\n## How it works\n\nWe use `System.Emit` to generate an implementation class for your\naspect-interfaces at runtime. This has a slight performance penalty and so the\ngenerated types are cached.\n\nThe `TryAspect` methods then attempt to populate all properties defined in the\naspect-interface by resolving the requested components on the given\nhost game-object.\n\n## Roadmap\n\n- Find game-objects\n- Find other aspects\n- Support searching on parents\n- Support searching in children\n- Support searching in custom locations\n- Array support\n- Nullable support\n- Live values\n- Setter support\n- Useful error messages\n- Allow to check if game-object has components without needing access to them (\n  tag-components)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomradevanti%2Funitygameobjectaspect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomradevanti%2Funitygameobjectaspect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomradevanti%2Funitygameobjectaspect/lists"}