{"id":13660924,"url":"https://github.com/EmmetOT/StructableObject","last_synced_at":"2025-04-24T23:31:05.112Z","repository":{"id":219325728,"uuid":"370427251","full_name":"EmmetOT/StructableObject","owner":"EmmetOT","description":"StructableObject is a wrapper for Unity's ScriptableObject system. It basically just lets you manipulate a data struct as if it were a ScriptableObject. This has been useful in my own development as it allows you to create systems which work well with both procedural data and designed data.","archived":false,"fork":false,"pushed_at":"2021-10-29T23:32:48.000Z","size":19,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-10T15:44:46.148Z","etag":null,"topics":["procedural-data","unity","unity-editor","unity-scriptableobject","unity3d","wrapper"],"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/EmmetOT.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}},"created_at":"2021-05-24T17:06:11.000Z","updated_at":"2024-09-19T08:45:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f3cf40b-e36a-4065-8471-9fa00aa33f6d","html_url":"https://github.com/EmmetOT/StructableObject","commit_stats":null,"previous_names":["emmetot/structableobject"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmmetOT%2FStructableObject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmmetOT%2FStructableObject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmmetOT%2FStructableObject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmmetOT%2FStructableObject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EmmetOT","download_url":"https://codeload.github.com/EmmetOT/StructableObject/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250727527,"owners_count":21477325,"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":["procedural-data","unity","unity-editor","unity-scriptableobject","unity3d","wrapper"],"created_at":"2024-08-02T05:01:27.485Z","updated_at":"2025-04-24T23:31:05.107Z","avatar_url":"https://github.com/EmmetOT.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"# StructableObject\nStructableObject is a wrapper for Unity's ScriptableObject system. It basically just lets you manipulate a data struct as if it were a ScriptableObject. This has been useful in my own development as it allows you to create systems which work well with both procedural data and designed data.\n\n# Why\n\nLet's say you have a simple struct which represents some data package. This could be damage information (how much HP, whether it's poison, the damage source...), an enemy AI profile, any small bit of data. \n\nYou want to make it so your designers can easily modify this information, so you put it in a ScriptableObject. However, your programmers also want to be able to easily create instances of these data objects at runtime with any kind of modification. Maybe your player gets a damage buff so all your projectiles now take 2x HP. There are many solutions for this. You can create ScriptableObjects without saving them as Unity assets, but that has a lot of overhead. You can make interfaces, but that could require some refactoring and it's a pain when you want to add or remove variables to your data.\n\nI often found myself just putting this information in a struct and serializing that struct in a ScriptableObject. Over time, I began writing custom editors for these ScriptableObjects to make it appear that the struct's contents *were* the ScriptableObject, to make the experience seamless for designers. Finally, I wrote this generic solution.\n\n# How\n\nAll you have to do is write a serializable struct:\n\n![image](https://user-images.githubusercontent.com/18707147/119384110-1bba4d80-bcbc-11eb-939f-fca8244a5556.png)\n\nInherit from StructableObject, giving this struct as a type parameter:\n\n![image](https://user-images.githubusercontent.com/18707147/119384154-2e348700-bcbc-11eb-85e9-0f5c8464ff43.png)\n\nAnd likewise, create a Custom Editor class:\n\n![image](https://user-images.githubusercontent.com/18707147/119385001-6b4d4900-bcbd-11eb-83cb-45862862aa22.png)\n\nThe final ScriptableObject appears and works exactly as though you had put the fields right in a ScriptableObject, including supporting undo.\n\n![image](https://user-images.githubusercontent.com/18707147/119384277-5c19cb80-bcbc-11eb-8b0e-6693f1a2cba3.png)\n\nThe struct can be accessed in code via the .Data property on the StructableObject, but sometimes I add passthrough properties to make it even more seamless.\n\n![image](https://user-images.githubusercontent.com/18707147/119384440-a00cd080-bcbc-11eb-83b4-e090dfb85ff9.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEmmetOT%2FStructableObject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEmmetOT%2FStructableObject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEmmetOT%2FStructableObject/lists"}