Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

# Auto Hook


GitHub package.json version

GitHub issues


GitHub pull requests


GitHub license

GitHub last commit

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) Become a Patron!


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.