{"id":13664649,"url":"https://github.com/Dartteon/UnityHealthBar","last_synced_at":"2025-04-26T01:33:01.352Z","repository":{"id":67586966,"uuid":"83073420","full_name":"Dartteon/UnityHealthBar","owner":"Dartteon","description":"This is a starter kit for a health bar system in Unity.","archived":false,"fork":false,"pushed_at":"2017-02-24T20:22:30.000Z","size":19,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-02T05:22:29.710Z","etag":null,"topics":["unity","unity-asset"],"latest_commit_sha":null,"homepage":null,"language":null,"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/Dartteon.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":"2017-02-24T19:00:47.000Z","updated_at":"2024-07-24T03:17:09.000Z","dependencies_parsed_at":"2023-02-22T12:16:01.875Z","dependency_job_id":null,"html_url":"https://github.com/Dartteon/UnityHealthBar","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dartteon%2FUnityHealthBar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dartteon%2FUnityHealthBar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dartteon%2FUnityHealthBar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dartteon%2FUnityHealthBar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dartteon","download_url":"https://codeload.github.com/Dartteon/UnityHealthBar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224022376,"owners_count":17242755,"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":["unity","unity-asset"],"created_at":"2024-08-02T05:03:02.263Z","updated_at":"2025-04-26T01:33:01.279Z","avatar_url":"https://github.com/Dartteon.png","language":null,"funding_links":[],"categories":["miscellaneous"],"sub_categories":[],"readme":"# UnityHealthBar\nThis is a starter kit for a health bar system in Unity.\n\n\n![alt text][sampleImage]\n[sampleImage]: https://github.com/Dartteon/UnityHealthBar/blob/master/GithubImage.PNG \"Sample\"\n\n##Importing to Your Project\nSimply open your Unity project, and then double-click the package file (HealthBarStarterPack.unitypackage).  \nA popup will appear in Unity to prompt you - click \"Import\", and all the needed files will be inside your project.\n\n##Example\nTo view the example, drag the TestEnemy (HealthBarStarterPack/Prefabs/TestEnemy) prefab into your scene.  \nWhen you press Play, a HealthBar should spawn above it. When you hold SpaceBar down, it should get damaged gradually, and the health bar should reflect that!\n\n##Using the Health System\nThe Health class is lightweight and simple to use. To use it, attach it to the GameObject you want it on.  \nThe Health system must be initialized with ```Initialize(float maxHealthAmount)```.  \nTo deal damage, call ```Damage (float amount)```.\n\n##Using the BarUI System with Health System\n1) Drag and drop the HealthBar prefab into your scene  \n2) Attach the HealthBar gameObject from (1) onto the gameObject you want (i.e Player)  \n3) Attach the Health script onto the same gameObject from (2)  \n4) Inside the master script of the gameObject (e.g Player), add this chunk to ```Start()``` (or Initialize() if you made your own)  \n(Please change the value inside `Initialize(100f)` to whatever Health amount you want)\n```\n    health = transform.GetComponent\u003cHealth\u003e ();  \n    health.Initialize (100f);  \n    BarUI barUi = GameObject.Instantiate(healthBarPrefab, transform).GetComponent\u003cBarUI\u003e ();  \n    barUi.transform.localPosition = new Vector3 (0f, .4f, 0f);  \n    barUi.Initialize (health);\n```\n\n###Using BarUI on Other Things\nIf you wish to use this on other systems (e.g Mana Systems), follow these steps:  \n1) Ensure your new class inherits from `ObservableRatio` class (i.e `public class ManaSystem : ObservableRatio`)  \n2) Override `GetRatio()` by making a new method in the class,  \ni.e `public override float GetRatio() { //calculate ratio here }`  \n3) Drag HealthBar to your gameObject, and rename it accordingly (i.e ManaSystem)  \n4) Ensure that the BarUI in HealthBar gets initialized to observe your class. Here is an example, for a class `ManaSystem`, with the HealthBar gameObject renamed to ManaBar\n```\n    ManaSystem manaSystem = transform.GetComponent\u003cManaSystem\u003e ();  \n    manaSystem.Initialize (100f);  \n    BarUI barUi = transform.Find(\"ManaBar\").GetComponent\u003cBarUI\u003e ();  \n    barUi.Initialize (manaSystem);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDartteon%2FUnityHealthBar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDartteon%2FUnityHealthBar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDartteon%2FUnityHealthBar/lists"}