{"id":24857397,"url":"https://github.com/pspkurara/external-selection-state","last_synced_at":"2026-05-09T14:41:14.759Z","repository":{"id":217430126,"uuid":"533474647","full_name":"pspkurara/external-selection-state","owner":"pspkurara","description":"The system allows external access to Selection.SelectionState, which is a protected Enum of uGUI.","archived":false,"fork":false,"pushed_at":"2022-09-21T13:00:59.000Z","size":215,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-31T17:53:25.236Z","etag":null,"topics":["ugui","ui","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","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/pspkurara.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2022-09-06T19:31:50.000Z","updated_at":"2022-09-07T06:08:30.000Z","dependencies_parsed_at":"2024-01-16T11:53:52.726Z","dependency_job_id":null,"html_url":"https://github.com/pspkurara/external-selection-state","commit_stats":null,"previous_names":["pspkurara/external-selection-state"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pspkurara%2Fexternal-selection-state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pspkurara%2Fexternal-selection-state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pspkurara%2Fexternal-selection-state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pspkurara%2Fexternal-selection-state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pspkurara","download_url":"https://codeload.github.com/pspkurara/external-selection-state/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245689455,"owners_count":20656414,"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":["ugui","ui","unity"],"created_at":"2025-01-31T17:53:23.076Z","updated_at":"2026-05-09T14:41:09.719Z","avatar_url":"https://github.com/pspkurara.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# External Selection State (ESS)\r\n\r\nThe system allows external access to Selection.SelectionState, which is a protected Enum of uGUI.\u003c/br\u003e\r\nYou need to create your own UI (CustomButton, CustomToggle, etc.) classes that inherit from components that inherit from Selection classes such as Button and Toggle, and implement this library.\r\n\r\n[![](https://img.shields.io/npm/v/com.pspkurara.external-selection-state?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.pspkurara.external-selection-state/)\r\n[![](https://img.shields.io/github/v/release/pspkurara/external-selection-state)](https://github.com/pspkurara/external-selection-state/releases/)\r\n[![](https://img.shields.io/github/watchers/pspkurara/external-selection-state?style=social)](https://github.com/pspkurara/external-selecion-state/subscription)\r\n\r\n## Usage\r\n\r\n### Creating a UI that inherits from \"UnityEngine.UI.Selectable\"\r\n\r\n1. Create a script that extends the UI (e.g. UnityEngine.UI.Button etc.) class to which you want to add ESS functionality. (Selection is limited to components that have UnityEngine.UI.)\r\n2. Add \"using Pspkurara.UI\" and \"using Pspkurara.UI.ESS\", \r\n3. Make it inherit the \"ISelectableWithESS\" interface and implementation functions.\r\n4. Override the \"Selection.DoStateTransition\" function and call \"this.DoStateTransitionFromSelectable\" function.\r\n```\r\nusing UnityEngine;\r\nusing UnityEngine.UI;\r\nusing Pspkurara.UI;\r\nusing Pspkurara.UI.ESS;\r\n\r\npublic class CustomButton : Button, ISelectableWithESS\r\n{\r\n\t// Use UnityEvent to register in the inspector and execute in the editor.\r\n\t[SerializeField]\r\n\tprivate OnDoStateTransitionEvent m_OnDoStateTransitionEvent = new OnDoStateTransitionEvent();\r\n\t\r\n\tpublic ExternalSelectionState currentExternalSelectionState\r\n\t{ \t// Convert protected Selectable.SelectionState to public.\r\n\t\tget { return (ExternalSelectionState)(int)base.currentSelectionState; } \r\n\t}\r\n\t\r\n\tpublic OnDoStateTransitionEvent onDoStateTransition\r\n\t{\t// Callback executed when DoStateTransition is called.\r\n\t\tget { return m_OnDoStateTransitionEvent ; } \r\n\t}\r\n\t\r\n\tprotected override void DoStateTransition(SelectionState state, bool instant)\r\n\t{\r\n\t\tbase.DoStateTransition(state, instant);\r\n\t\t// Trigger from UnityEngine.UI.Selectable.\r\n\t\tthis.DoStateTransitionFromSelectable((int)state, instant);\r\n\t}\r\n}\r\n```\r\n\r\n### Create a script to add functionality to an extended \"UnityEngine.UI.Selectable\"\r\n\r\n1. Create a new script and add \"using Pspkurara.UI\".\r\n2. Add an implementation to receive \"ISelectableWithESS\".\r\n3. Implement a function with the same arguments as \"Selectable.DoStateTransition\". (OnDoStateTransition thereafter)\r\n4. Added implementation to register with ESS callbacks upon generation or activation.\r\n5. Added implementation to release ESS callback on destroy or disable.\r\n6. Add \"immediate reflection\" call just before adding callback.\r\n7. Implement the function or effect you want to have in the ”OnDoStateTransition”.\r\n```\r\nusing UnityEngine;\r\nusing UnityEngine.UI;\r\nusing UnityEngine.EventSystems;\r\nusing Pspkurara.UI;\r\n\r\npublic class SampleLink : UIBehaviour\r\n{\r\n\t// Own Selectable.\r\n\tprivate ISelectableWithESS m_Selectable;\r\n\r\n\t/// \u003csummary\u003e\r\n\t/// Own Selectable.\r\n\t/// ISelectableWithESS must be inherited.\r\n\t/// \u003c/summary\u003e\r\n\tpublic ISelectableWithESS selectable {\r\n\t\tget {\r\n\t\t\t// interface cannot be Serialized, so it should be acquired automatically.\r\n\t\t\tif (m_Selectable == null)\r\n\t\t\t{\r\n\t\t\t\tm_Selectable = GetComponent\u003cISelectableWithESS\u003e();\r\n\t\t\t}\r\n\t\t\treturn m_Selectable;\r\n\t\t}\r\n\t}\r\n\r\n\tprotected override void OnEnable()\r\n\t{\r\n\t\tif (selectable == null) return;\r\n\r\n\t\t// Immediate reflection at initialization.\r\n\t\tOnDoStateTransition(selectable.currentExternalSelectionState, true);\r\n\r\n\t\t// Callback Registration.\r\n\t\tselectable.onDoStateTransition.AddListener(OnDoStateTransition);\r\n\t}\r\n\r\n\tprotected override void OnDisable()\r\n\t{\r\n\t\tif (selectable == null) return;\r\n\t\t\r\n\t\t// Callback Release.\r\n\t\tselectable.onDoStateTransition.RemoveListener(OnDoStateTransition);\r\n\t}\r\n\r\n\t// Called when there is an actual change in state.\r\n\tprivate void OnDoStateTransition(ExternalSelectionState state, bool instant)\r\n\t{\r\n\t\t// any processing.\r\n\t\tDebug.Log(state);\r\n\t}\r\n\r\n}\r\n```\r\n\r\n### Use the components you have created\r\n\r\n1. Attach an effect adaptation component (SampleLink in the example) to an object with an extended Selectable (CustomButton in the example).\r\n2. Execute or change parameters and check if they are reflected correctly.\r\n\r\n### Full API references\r\n* https://pspkurara.github.io/external-selection-state/\r\n\r\n## Installation\r\n\r\n### Using OpenUPM\r\nGo to Unity's project folder on the command line and call:\r\n\r\n```\r\nopenupm add com.pspkurara.external-selection-state\r\n```\r\n\r\n### Using Unity Package Manager (For Unity 2018.3 or later)\r\nFind the manifest.json file in the Packages folder of your project and edit it to look like this:\r\n\r\n```\r\n{\r\n  \"dependencies\": {\r\n    \"com.pspkurara.external-selection-state\": \"https://github.com/pspkurara/external-selection-state.git#upm\",\r\n    ...\r\n  },\r\n}\r\n```\r\n\r\n#### Requirement\r\nUnity 2018.1 or later\u003cbr\u003e\r\nMay work in Unity5, but unofficial.\r\n\r\n## License\r\n\r\n* [MIT](https://github.com/pspkurara/external-selection-state/blob/master/Packages/ExternalSelectionState/LICENSE.md)\r\n\r\n## Author\r\n\r\n* [pspkurara](https://github.com/pspkurara) \r\n[![](https://img.shields.io/twitter/follow/pspkurara.svg?label=Follow\u0026style=social)](https://twitter.com/intent/follow?screen_name=pspkurara) \r\n\r\n## See Also\r\n\r\n* GitHub page : https://github.com/pspkurara/external-selection-state\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpspkurara%2Fexternal-selection-state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpspkurara%2Fexternal-selection-state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpspkurara%2Fexternal-selection-state/lists"}