Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thundernerd/unity3d-componentattribute
An attribute that let's you auto-load components
https://github.com/thundernerd/unity3d-componentattribute
Last synced: about 2 months ago
JSON representation
An attribute that let's you auto-load components
- Host: GitHub
- URL: https://github.com/thundernerd/unity3d-componentattribute
- Owner: Thundernerd
- License: mit
- Created: 2015-11-15T15:19:57.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-23T23:53:15.000Z (over 8 years ago)
- Last Synced: 2024-08-03T19:09:52.656Z (5 months ago)
- Language: C#
- Size: 68.4 KB
- Stars: 60
- Watchers: 11
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unity3D-ComponentAttribute
An attribute that let's you auto-load components* Works on fields and properties
* Load components on awake, start, or enable, or whenever else you feel like it
* Get component from other GameObjects (optional)
* Add component if missing (optional)
* Disable component on error (optional)*Credits go to [@ChevyRay](https://twitter.com/ChevyRay) for inspiring me to make this by this [tweet](https://twitter.com/ChevyRay/status/665673463856664576)*
The way of this.LoadComponents()
-------------------------------
The only thing you have to do is add the component attribute to fields and/or properties that you want and call *this.LoadComponents();* in the awake, start, on enable, or any other place for that matter and you are good to go.Pros:
* You don't have to do all those GetComponent calls to get the components you need
* The more components you want, the less you have to doCons:
* You have to write *[Component]* on top the of the Components you want this to work on
* You also have to call *this.LoadComponents();*### Fields Example
![Imgur](http://i.imgur.com/BSnZNWt.png)### Properties Example
![Imgur](http://i.imgur.com/P3HrXcB.png)