{"id":18996800,"url":"https://github.com/ailhc/scriptableasset_example","last_synced_at":"2026-06-21T02:31:47.519Z","repository":{"id":237359074,"uuid":"794371174","full_name":"AILHC/scriptableasset_example","owner":"AILHC","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-07T05:32:12.000Z","size":1524,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T12:26:15.392Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/AILHC.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":"2024-05-01T02:10:06.000Z","updated_at":"2024-11-07T05:32:16.000Z","dependencies_parsed_at":"2024-05-01T03:25:35.139Z","dependency_job_id":"e1ae2776-d06c-4e54-8092-44cf919c00bf","html_url":"https://github.com/AILHC/scriptableasset_example","commit_stats":null,"previous_names":["ailhc/scriptableasset_example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AILHC/scriptableasset_example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AILHC%2Fscriptableasset_example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AILHC%2Fscriptableasset_example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AILHC%2Fscriptableasset_example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AILHC%2Fscriptableasset_example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AILHC","download_url":"https://codeload.github.com/AILHC/scriptableasset_example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AILHC%2Fscriptableasset_example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34592050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"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":[],"created_at":"2024-11-08T17:37:04.484Z","updated_at":"2026-06-21T02:31:47.504Z","avatar_url":"https://github.com/AILHC.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ScriptableAsset\n\n\n## 简介\n\n提供和**Unity**的**ScriptableObject**的一样的功能\n\n方便配置复杂结构的数据，方便协作，方便引用其他资源\n\n和平时配置`prefab`的`component`数据一样，但不需要节点，不需要挂组件\n\n## 引擎版本支持\n\n`\u003e= 3.7.0`\n3.7.x的对于显示有些问题\n![](https://testingcf.jsdelivr.net/gh/ailhc/picture/img/202406161041418.png)\n不影响正常使用\n\n## 测试的发布平台\n\n| H5  | 微信小游戏 | Android原生 | iOS原生 | 抖音小游戏 | OPPO小游戏 | vivo小游戏 |\n| --- | --------- | ----------- | ------- | -------- | ------- | ------- |\n| ✔   | ✔        | ✔           | ✔       | ✔       | ✔       | ✔       |\n\n## 特性和规划\n- [x] 自定义ScriptableAsset类型\n- [x] 预览和编辑\n- [x] 拖拽赋值到组件字段(指定自定义ScriptableAsset类型)识别\n- [x] 使用装饰器添加右键创建按钮\n- [x] 兼容3.7.x\n- [x] 测试更多发布平台\n- [ ] 支持搜索\n- [ ] 支持自定义ScriptableAsset的Inspector\n\n\n## 使用\n### 示例项目\n\nGitee [scriptableasset_example](https://gitee.com/AIGAMESTUDIO.AILHC/scriptableasset_example)\nGitHub [scriptableasset_example](https://github.com/AILHC/scriptableasset_example)\n### 创建\n\u003e自动添加到右键菜单，创建自定义类型数据文件\n\u003eps:需要复制示例的脚本模板到项目中：`.creator\\asset-template\\typescript\\ScriptableAssetScriptTemplate`\n\n![创建资源.gif](https://testingcf.jsdelivr.net/gh/ailhc/picture/img%E5%88%9B%E5%BB%BA%E8%B5%84%E6%BA%90.gif)\n\n\n### 可视化修改配置\n\u003e修改配置和修改Component的字段数据一样\n\n可以使用任何CocosCreator提供的属性装饰器\n\n![修改资源.gif](https://testingcf.jsdelivr.net/gh/ailhc/picture/img%E4%BF%AE%E6%94%B9%E8%B5%84%E6%BA%90.gif)\n\n\n参考更多用法：[Cocos Creator 3.8 手册 - 装饰器使用](https://docs.cocos.com/creator/manual/zh/scripting/decorator.html#type-%E5%8F%82%E6%95%B0)\n\n\n### 引用和加载\n\u003e和其他资源(cc.Prefab、cc.AudioClip、等)一样，进行引用和加载，以及对依赖资源加载，无需而外处理\n\n#### 被引用\n```typescript\nimport { _decorator, Component, Node } from 'cc';\nimport { bh } from 'db://scriptable-asset/scriptable_runtime';\nimport { CharSA } from './scripts/CharSA';\nimport { CharRender } from './scripts/CharRender';\n\n\nconst { ccclass, property } = _decorator;\n\n@ccclass('TestRefScriptableAsset')\nexport class TestRefScriptableAsset extends Component {\n    // private _charData: CharSA;\n    // @property(bh.ScriptableAsset)\n    // get charData(): CharSA{\n    //     return this._charData;\n    // };\n    // set charData(value: CharSA){\n    //     debugger\n    //     this._charData = value;\n    // }\n    // @bh.scriptableAsset\n    // charData: CharSA;\n    @property(CharRender)\n    charRender: CharRender;\n\n    @property(CharSA)\n    charData: CharSA;\n    start() {\n        console.log(this.charData.charName);\n        this.charRender.setCharAsset(this.charData);\n    }\n    update(deltaTime: number) {\n\n    }\n}\n```\n界面\n![image.png](https://testingcf.jsdelivr.net/gh/ailhc/picture/img202404302045386.png)\n\n\n\n#### 动态加载\n\n```typescript\nimport { _decorator, assetManager, Component, director, Node } from 'cc';\nimport { CharRender } from './CharRender';\nimport { CharSA } from './CharSA';\nconst { ccclass, property } = _decorator;\n\n@ccclass('TestLoadScriptableAssetDynamic')\nexport class TestLoadScriptableAssetDynamic extends Component {\n    /**\n     * \n    \n    */\n    @property(CharRender)\n    charRender: CharRender = null;\n    @property\n    assetPath: string = \"char/char_datas/CharSA\"\n    start() {\n\n    }\n\n    update(deltaTime: number) {\n\n    }\n    loadScriptableAsset() {\n        \n        assetManager.loadBundle('scriptable_asset_test_res', (err, bundle) =\u003e {\n            if (err) {\n                console.error(err);\n                return;\n            }\n            bundle.load(this.assetPath, (err, asset:CharSA) =\u003e {\n                if (err) {\n                    console.error(err);\n                    return;\n                }\n                console.log(asset);\n                this.charRender.setCharAsset(asset);\n\n            });\n        });\n    }\n}\n```\n\n## 已知问题\n\n- 自定义且用ccclass装饰器的类，非继承Component的，比如CustomClasss，需要赋予初始值\n\n- 使用具体的ScriptableAsset类型会字段赋值旁边的打开搜索功能会搜索不到，需要使用基类ScriptableAsset作为字段装饰器类型，或者直接使用`@bh.scriptableAsset`来标记\n\t```ts\n\t@bh.scriptableAsset\n    charData: CharSA;\n\t```\n- 删除ScriptableAsset脚本，会让依赖的地方显示为UnknownType，恢复脚本后，重启编辑器即可\n\n\n## 其他作品\n\n- 编辑器控制台增强插件 [EditorConsoleEnhancer](https://store.cocos.com/app/detail/6147)\n- 让你5000+资源的项目开发如燕般轻盈流畅。 [Aswallow](https://store.cocos.com/app/zh/detail/2948)\n- [完美typescript插件模板][Cocos Store](https://store.cocos.com/app/detail/2736)\n\n## 联系\n### 邮件反馈\n\n505126057@qq.com\n### Discord 频道 \u0026 QQ 频道\n[点击链接加入QQ频道【游戏开发者联盟】](https://pd.qq.com/s/12xollzi9)\n\n[**Join Our Discord Channel**](https://discord.com/channels/1233676496049274890/1233676883409768468)\n\n### 加群交流反馈\n\nQQ群:1103157878\n\n### 关注作者获取更多内容\n\n微信搜索公众号:玩转游戏开发\n\n或扫码关注：\u003cimg src=\"https://testingcf.jsdelivr.net/gh/ailhc/picture/img202404011944623.png\" alt=\"img\" style=\"zoom:50%;\" /\u003e\n\n## 版权声明\n\n本引擎插件(以下简称\"插件\")由本人开发。插件的所有权和知识产权均归本人所有。不得重复发布本插件。\n\n## 购买须知\n\n本产品为付费虚拟商品，一经购买成功概不退款，请在购买前谨慎确认购买内容。\n\n## 更新日志\n### `v1.0.5`\n- 修复打包压缩bug\n### `v1.0.4`\n- 优化文档\n- package.json中编辑器的兼容性修改\n\n### `v1.0.3`\n- 兼容 3.7.x\n- 修复文档图片链接失效问题\n\n### `v1.0.2`\n\n兼容3.8.3\n\n### `v1.0.1`\n\n初次发布版本","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Failhc%2Fscriptableasset_example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Failhc%2Fscriptableasset_example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Failhc%2Fscriptableasset_example/lists"}