Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Thundernerd/Unity3D-AutoHook
A property drawer that automagically assigns a reference to your field
https://github.com/Thundernerd/Unity3D-AutoHook
Last synced: about 1 month ago
JSON representation
A property drawer that automagically assigns a reference to your field
- Host: GitHub
- URL: https://github.com/Thundernerd/Unity3D-AutoHook
- Owner: Thundernerd
- License: mit
- Created: 2020-09-09T13:14:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-12-11T08:59:18.000Z (about 1 year ago)
- Last Synced: 2024-11-13T23:41:29.725Z (about 2 months ago)
- Language: C#
- Homepage:
- Size: 27.3 KB
- Stars: 61
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Auto Hook
Auto Hook is a property drawer that automagically assigns a reference to your field.
## Installation
1. The package is available on the [openupm registry](https://openupm.com). You can install it via [openupm-cli](https://github.com/openupm/openupm-cli).
```
openupm add net.tnrd.autohook
```2. Installing through a [Unity Package](http://package-installer.glitch.me/v1/installer/package.openupm.com/net.tnrd.autohook?registry=https://package.openupm.com) created by the [Package Installer Creator](https://package-installer.glitch.me) from [Needle](https://needle.tools)
[](http://package-installer.glitch.me/v1/installer/package.openupm.com/net.tnrd.autohook?registry=https://package.openupm.com)
## Usage
Using Auto Hook is easy. You just have to add the `[AutoHook]` attribute to any field that wants a component and it'll try to assign it.```csharp
public class Foo : MonoBehaviour
{
[SerializeField, AutoHook]
private Rigidbody rigidbody;[...]
}
```There's some extra options that you can configure
| Option | Description |
|--------------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SearchArea | **Default**
Matches `GetComponent`
**Parent**
Matches `GetComponentInParent`
**Children**
Matches `GetComponentInChildren`
**DirectChildrenOnly**
Iterates over the direct children of the current object only, ignoring itself and any children below that
**AllChildrenOnly**
Iterates over all children of the current object recursively, ignoring only itself |
| HideWhenFound | Reduces the size of the property to 0 when a matching component has been found |
| ReadOnlyWhenFound | Marks the property as read-only when a matching component has been found |
| StopSearchWhenFound | Stops calling GetComponent (or other variants) when a matching component has been found. This is useful if you have many `[AutoHook]` usages in your file |## Support
**Auto Hook** is originally made by [LotteMakesStuff](https://github.com/LotteMakesStuff) and can be found [here](https://gist.github.com/LotteMakesStuff/d6a9a4944fc667e557083108606b7d22).
You can support **LotteMakesStuff** through her ko-fi or by becoming her Patreon
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/A08215TT)
If you're feeling generous and you like my version then you can support **me** here[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/J3J11GEYY)
## Contributing
Pull requests are welcomed. Please feel free to fix any issues you find, or add new features.