Skip to content

Thundernerd/Unity3D-AutoHook

Repository files navigation

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. You can install it via openupm-cli.
openupm add net.tnrd.autohook
  1. Installing through a Unity Package created by the Package Installer Creator from Needle

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.

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 and can be found here.

You can support LotteMakesStuff through her ko-fi or by becoming her Patreon

ko-fi Become a Patron!

If you're feeling generous and you like my version then you can support me here

ko-fi

Contributing

Pull requests are welcomed. Please feel free to fix any issues you find, or add new features.

About

A property drawer that automagically assigns a reference to your field

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages