{"id":13786318,"url":"https://github.com/baba-s/UniSceneDataTransfer","last_synced_at":"2025-05-11T22:30:53.587Z","repository":{"id":110295239,"uuid":"234838004","full_name":"baba-s/UniSceneDataTransfer","owner":"baba-s","description":"Unity package to easily pass data at scene transition.","archived":false,"fork":false,"pushed_at":"2020-04-19T09:17:14.000Z","size":22,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-12T00:02:09.861Z","etag":null,"topics":["kogane-unity-lib","unity","unity-package","unity-package-manager","unity-scripts","unity3d"],"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/baba-s.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}},"created_at":"2020-01-19T04:03:18.000Z","updated_at":"2024-09-05T12:19:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"50f45a22-747d-4109-bdf4-b221595717f8","html_url":"https://github.com/baba-s/UniSceneDataTransfer","commit_stats":null,"previous_names":["baba-s/unity-scene-data-transfer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baba-s%2FUniSceneDataTransfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baba-s%2FUniSceneDataTransfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baba-s%2FUniSceneDataTransfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baba-s%2FUniSceneDataTransfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baba-s","download_url":"https://codeload.github.com/baba-s/UniSceneDataTransfer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253645103,"owners_count":21941311,"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":["kogane-unity-lib","unity","unity-package","unity-package-manager","unity-scripts","unity3d"],"created_at":"2024-08-03T19:01:13.683Z","updated_at":"2025-05-11T22:30:52.689Z","avatar_url":"https://github.com/baba-s.png","language":"C#","readme":"[日本語の Readme はこちら](https://github.com/baba-s/unity-scene-data-transfer/blob/master/README_JP.md)  \n\n# Uni Scene Data Transfer\n\n![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20200119/20200119140300.png)\n\nUnity package to easily pass data at scene transition.  \n\n## Usages\n\n![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20200119/20200119135440.png)\n\nThe name of the scene and the name of the component that controls the scene must be the same.  \n\n```cs\npublic class ResultData\n{\n    public int Score;\n    public int Rank;\n}\n```\n\nDefine the data class to be passed to the scene.  \n\n```cs\nusing UnityEngine;\n\npublic class ResultScene : MonoBehaviour\n{\n```\n\nMonoBehaviour to control the scene,   \n\n```cs\nusing KoganeUnityLib;\nusing UnityEngine;\n\npublic class ResultScene : SimpleSceneBase\u003cResultScene, ResultData\u003e\n{\n```\n\nChange to inheritance SimpleSceneBase.  \n\n- Add `using KoganeUnityLib;` .\n\n```cs\nusing KoganeUnityLib;\nusing UnityEngine;\n\npublic class ResultScene : SimpleSceneBase\u003cResultScene, ResultData\u003e\n{\n    private void Start()\n    {\n        Debug.Log( entryData.Score );\n        Debug.Log( entryData.Rank );\n    }\n```\n\nThen, the passed data can be referenced by entryData property.  \n\n```cs\nvar data = new ResultData\n{\n    Score = 5000,\n    Rank  = 3,\n};\nResultScene.Load( data );\n```\n\nAfter that, by writing the above code in another scene, you can transition the scene while passing data.  \n\n## Remarks: Awake, OnEnable\n\n```cs\npublic class ResultScene : SimpleSceneBase\u003cResultScene, ResultData\u003e\n{\n    // Cannot\n    private void Awake()\n    {\n        Debug.Log( entryData.Score );\n        Debug.Log( entryData.Rank );\n    }\n    \n    // Cannot\n    private void OnEnable()\n    {\n        Debug.Log( entryData.Score );\n        Debug.Log( entryData.Rank );\n    }\n```\n\n- entryData property is not available for Awake, OnEnable.  \n\n## Remarks: Launch directly\n\nWhen launching the scene directly, entryData is null.  \n\n```cs\npublic class ResultScene : SimpleSceneBase\u003cResultScene, ResultData\u003e\n{\n    private void Start()\n    {\n        var data = entryData ?? new ResultData();\n\n        Debug.Log( data.Score );\n        Debug.Log( data.Rank );\n    }\n```\n\nTherefore, by writing the above code,  \nWhen the scene is started directly, the dummy data can be used.  \n\n```cs\nusing System;\n\n[Serializable]\npublic class ResultData\n{\n    public int Score;\n    public int Rank;\n}\n```\n\nAlternatively, by applying the Serializable attribute to the data class,  \n\n![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20200119/20200119135443.png)\n\nentryData used when launching the scene directly can be set in Unity Inspector.  ","funding_links":[],"categories":["Script Utility"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaba-s%2FUniSceneDataTransfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaba-s%2FUniSceneDataTransfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaba-s%2FUniSceneDataTransfer/lists"}