{"id":14961116,"url":"https://github.com/erkerkiii/gum","last_synced_at":"2025-10-13T04:09:51.708Z","repository":{"id":65189556,"uuid":"442507823","full_name":"erkerkiii/gum","owner":"erkerkiii","description":"Gum is a collection of tools focusing mainly on game development with the goal of getting rid of the boilerplate code.","archived":false,"fork":false,"pushed_at":"2025-04-27T16:24:09.000Z","size":2788,"stargazers_count":33,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-19T17:05:08.842Z","etag":null,"topics":["csharp","csharp-library","networking","object-pooling","observer","observer-pattern","pooling","unity","unity3d","unity3d-plugin"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erkerkiii.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-12-28T15:38:52.000Z","updated_at":"2025-04-27T16:24:13.000Z","dependencies_parsed_at":"2023-11-23T13:40:18.002Z","dependency_job_id":"debaf3da-644a-45a2-8dfb-2d845fd04fbf","html_url":"https://github.com/erkerkiii/gum","commit_stats":{"total_commits":125,"total_committers":12,"mean_commits":"10.416666666666666","dds":0.496,"last_synced_commit":"9f5a908acc2ca09281d192b042a1aae02969c0d8"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/erkerkiii/gum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkerkiii%2Fgum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkerkiii%2Fgum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkerkiii%2Fgum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkerkiii%2Fgum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erkerkiii","download_url":"https://codeload.github.com/erkerkiii/gum/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkerkiii%2Fgum/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265995706,"owners_count":23861508,"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":["csharp","csharp-library","networking","object-pooling","observer","observer-pattern","pooling","unity","unity3d","unity3d-plugin"],"created_at":"2024-09-24T13:23:54.184Z","updated_at":"2025-10-13T04:09:46.663Z","avatar_url":"https://github.com/erkerkiii.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gum\n\nGum is a collection of tools focusing mainly on game development with the goal of getting rid of the boilerplate code.\n\n## Table Of Contents\n\n- [Installation](#installation)\n- [Pooling](#pooling)\n- [Composer](#composer)\n- [Signals(pub/sub)](#signals)\n\n# Trusted By\n\n| [GoArt Metaverse](https://www.goartmetaverse.com/) | [Roof Stacks](https://roofstacks.com/) | [Gleam Games](https://www.gleamgames.com/) |\n| :---: | :---: | :---: |\n| \u003cimg src=\"Resources/goart.png\" width=\"250\" title=\"GoArt Metaverse\"\u003e   | \u003cimg src=\"Resources/roof.png\" width=\"250\" title=\"Roof Stacks\"\u003e | \u003cimg src=\"Resources/gleamgames.png\" width=\"250\" title=\"Gleam Games\"\u003e |\n\nYou can create a pull request or email me directly to display your game/company here emrefistikcioglu@gmail.com\n\n## Installation\n\n# Unity Installation\nAdd this to the ```Packages\\manifest.json```\n\n```\n\"scopedRegistries\": [\n    {\n        \"name\": \"NPM\",\n        \"url\": \"https://registry.npmjs.org\",\n        \"scopes\": [\n        \"com.erkerkiii.gum\"\n        ]\n    }\n]\n```\n\nDependencies\n```\n \"dependencies\": {\n    \"com.erkerkiii.gum\":  \"1.0.25\"\n    }\n```\n\n# Nuget Installation\n\nNuget packages are available for C# projects. Installation with the dotnet CLI:\n\n```\ndotnet add package Gum.Core\ndotnet add package Gum.Composer\ndotnet add package Gum.Pooling\ndotnet add package Gum.Signal\ndotnet add package Gum.WebRequest\n```\n\n\u003e :warning: Nuget installation **doesn't** include any Unity features.\n\n## Pooling\nThis is a very basic implementation of the pooling system.\n```CSharp\nPoolBuilder\u003cFoo\u003e poolBuilder = new PoolBuilder\u003cFoo\u003e();\nIPool\u003cFoo\u003e pool = _poolBuilder\n                .SetPoolType(PoolType.Stack) //this is the default pool type\n                .FromPoolableInstanceProvider(new FooInstanceProvider())\n                .WithInitialSize(10) //this is 0 by default\n                .Build();\n```\n\nAlternatively, you can use ```FromMethod```\n```CSharp\nIPool\u003cFoo\u003e pool = _poolBuilder\n                .SetPoolType(PoolType.Stack)\n                .FromMethod(Create)\n                .Build();\n```\n\nPool usage\n```CSharp\nFoo foo = pool.Get(); //gets an object from the pool, if it doesn't exists it creates one\n\npublic class Foo : IPoolable\n{\n    public event Action OnReturnToPoolRequested;\n\n    public void Reset()\n    {\n        //reset object's values   \n    }\n\n    public void Erase()\n    {\n        //delete the object\n        GC.SuppressFinalize(this);\n    }\n}\n```\n\nPool usage with Unity's MonoBehaviour\n\n```CSharp\npublic class Foo : MonoBehaviour, IPoolable\n{\n    public event Action OnReturnToPoolRequested;\n\n    public Reset()\n    {\n        gameObject.SetActive(true);  \n    }\n    \n    public void ReturnToPool()\n    {\n        gameObject.SetActive(false);\n        OnReturnToPoolRequested.Invoke();      \n    }\n\n    public void Erase()\n    {\n        if(this == null) //to avoid race conditions with Unity's object life-time\n        {\n            return;\n        }\n    \n        Destroy(gameObject);\n    }\n}\n```\n\nPoolCollection\u003cTKey, TValue\u003e usage\n```CSharp\nPoolBuilder\u003cFoo\u003e poolBuilder = new PoolBuilder\u003cFoo\u003e();\n//configuring the builder\npoolBuilder\n          .FromPoolableInstanceProvider(new FooInstanceProvider())\n          .SetPoolType(PoolType.Stack);\n\nPoolCollection\u003cint, Foo\u003e poolCollection = new PoolCollection\u003cint, Foo\u003e(poolBuilder);\n\nint key = 0;\n\nFoo foo = _poolCollection.Get(key); //gets an object from the pool with the specific key, creates one if the pool is empty\n```\n\n## Composer\n\u003cp\u003eComposer allows you to work with data compositions instead of inheritance thus allowing you to create data agnostic systems and cleaner, decoupled code.\u003c/p\u003e\n\u003cp\u003eIn order to work with the Composer, you have to use the aspect system.\u003c/p\u003e\n\n1. Go to ```Gum.Composer\\Aspects```\n2. Create a file with extension \".gum\"\n3. Start typing your aspect\n4. Run the codegen using ```CompositionCodeGenerator.Run()``` or use [editor tool](#aspect-creator-tool) for calling codegen.\n\n\u003e **_NOTE:_**  Editor tool is available for creating aspects. Check out [editor tool](#aspect-creator-tool) for more information.\n\nExample aspect file\nMyAspect.gum\n```\naspect MyAspect \n{\n    int MyInt;\n    \n    string MyAspect;\n    \n    double MyDouble;\n    \n    Transform MyTransform;\n    \n    Vector3 MyVector3;\n}\n```\nYou can use ANY object type while creating aspects.\n\n```CSharp\nprivate void Run()\n{\n    //you can call this method from anywhere (from unity editor or a console application)\n    CompositionCodeGenerator.Run(); \n}\n```\n\nYou can use the ```Gum.Composer\\UserConfig.cs``` to configure the codegen.\n\n```CSharp\npublic struct Foo : IComposable\n{\n    public int foo;\n    \n    public string bar;\n    \n    public Vector3 baz;\n\n    public Composition GetComposition() //this part has to be written manually\n    {\n        //use array pools to allocate less\n\t//3 = length of the requested array\n        IAspect[] aspects = ArrayPool\u003cIAspect\u003e.GetPool(3).Get();\n        aspects[0] = new FooAspect(foo);\n        aspects[1] = new BarAspect(bar);\n        aspects[2] = new BazAspect(baz);\n        return Composition.Create(aspects);\n    }\n}\n\npublic class Bar : IComposable\n{\n    public double qux;\n    \n    public string bar;\n    \n    public Composition GetComposition()\n    {\n\t//2 = length of the requested array\n        IAspect[] aspects = ArrayPool\u003cIAspect\u003e.GetPool(2).Get();\n        aspects[0] = new QuxAspect(qux);\n        aspects[1] = new BarAspect(bar);\n        return Composition.Create(aspects);\n    }\n}\n\n//as you can see this method can use both Foo and and Bar to operate\npublic void UseAspects(IComposable composable)\n{\n    //always use the disposable pattern or manually dispose composition\n    using (Composition composition = composable.GetComposition())\n    {\n        BarAspect barAspect = _composition.GetAspect\u003cBarAspect\u003e();\t\t\t\t\n    }\n}\n```\n\n### MonoComposable \n\nComposition is also available for Unity `MonoBehaviours `. Deriving from the abstract `MonoComposable` class enables using composition on Unity objects. `MonoComposable` class handles creation of composable, deriving classes only responsible for implementing the `GetAspects()` absrtact method to assign aspects.\n\n```CSharp\npublic class FooMonoComposable : MonoComposable\n{\n    private int _value = 12;\n\n    protected override IAspect[] GetAspects() // Deriving class implements GetAspects method.\n    {\n\t//1 = length of the requested array\n        IAspect[] aspects = ArrayPool\u003cIAspect\u003e.GetPool(1).Get();\n        aspects[0] = new FooAspect(_value);\n        return aspects;\n    }\n}\n```\n\n### Other usages\n```CSharp\ncomposition\n    .GetAspectFluent(out FooAspect fooAspect)\n    .GetAspectFluent(out BarAspect barAspect);\n\t\nBarAspect barAspect = (BarAspect)_composition[BarAspect.ASPECT_TYPE];\n\ncomposition.AddAspect(new BarAspect());\n\ncomposition.SetAspect(new BarAspect());\n\ncomposition.RemoveAspect(BarAspect.ASPECT_TYPE);\n\nforeach (IAspect aspect in composition)\n{\n    BarAspect barAspect = (BarAspect)aspect;\n}\n```\n## Aspect Creator Tool\n\nEditor tool for aspect creation is located on Gum/Composition/AspectCreator on the editor menu. Aspect creator automates adding new aspects to the project. It generates aspects with given name to aspects folder with \".gum\" extention. In order to generate aspect, it's required add least one field including it's Type and field name. Aspect generator includes built-in types but it can be extendable via adding new types.  \n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"Resources/Aspect-Creator-1.png?raw=true width=\"350\" height=\"350\" title=\"Aspect Creator\"\u003e\n\u003c/p\u003e\n\nBasic usage:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"Resources/Aspect-Create.gif?raw=true width=\"350\" height=\"350\" title=\"Aspect Creator\"\u003e\n\u003c/p\u003e\n\nAdding new types for extending:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"Resources/Aspect-Type-Create.gif?raw=true width=\"350\" height=\"350\" title=\"Aspect Creator\"\u003e\n\u003c/p\u003e\n\n## Signals\n```Gum.Signals``` is a very light-weight and simple pub/sub system.\n\nUsage\n\n```Csharp\npublic readonly struct FooSignal\n{\n    public readonly int Value;\n\n    public FooSignal(int value)\n    {\n        Value = value;\n    }\n}\n```\n\t\n```Csharp\nSignalCenter signalCenter = new SignalCenter(); //pass this reference to places of usage (preferably with a DI framework)\n\nprivate void Bar(FooSignal fooSignal)\n{\n    //do stuff\n}\n\nsignalCenter.Subscribe\u003cFooSignal\u003e(Action); //to subscribe\nsignalCenter.Unsubscribe\u003cFooSignal\u003e(Action); //to unsubscribe\nsignalCenter.Fire(new FooSignal()); //to fire signals\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferkerkiii%2Fgum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferkerkiii%2Fgum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferkerkiii%2Fgum/lists"}