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

https://github.com/andersonmarquess/am_di

An alternative to drag and drop for serialized fields in unity.
https://github.com/andersonmarquess/am_di

plugin unity unity-asset unity-editor

Last synced: 2 months ago
JSON representation

An alternative to drag and drop for serialized fields in unity.

Awesome Lists containing this project

README

          

How to install?

Add as custom git package with package manager:

1. Open package manager
2. Click on the plus (➕) button
3. Choose "Add package from git URL"
4. Past the url:
```
https://github.com/AndersonMarquess/AM_DI.git?path=/Packages/DependencyInitializer
```

or

Set direct reference in manifest.json:
```json
"com.andersonmarques.dependencyinitializer": "https://github.com/AndersonMarquess/AM_DI.git?path=/Packages/DependencyInitializer"
```

How to use?


1 - Just add the desired attribute on the field that will be filled.


2 - In the transform of the gameobject, just click on "Find"

![Transform component image with custom editor showing the Find button](https://raw.githubusercontent.com/AndersonMarquess/AM_DI/main/AM_DI.jpg)

3 - Done!

Usage example in code



```cs
[SerializeField, FindInScene]
private Light _sceneMainLight = null;

[SerializeField, FindInScene(ActiveOnly = true)]
private SphereCollider _activeSphereInScene = null;

[SerializeField, FindInParent]
private MockComponent _parentComponent = null;

[SerializeField, FindInParent(IgnoreSelf = false)]
private Transform _firstAvailableTransform = null;

[SerializeField, FindInComponent]
private NavMeshAgent _myNavMeshAgent = null;

[SerializeField, FindInChild]
private Renderer _childRenderer = null;

[SerializeField, FindInChild(Path = "Plane/InnerChild")]
private Renderer _specifChildRenderer = null;

[SerializeField, Initializable]
private MyDefaultCsharpClass _compositionClass = null;

[Serializable]
class MyDefaultCsharpClass
{
[SerializeField, FindInChild]
private Renderer _childRenderer = null;
}
```



Currently supported operations

- Find In Scene
- Active
- Find In Parent
- Ignore Self
- Find In Component
- Find In Child
- Active
- With Path
- Default class initialization

Why was it created?


Drag and drop can be time consuming when done over and over again, having a button to fill dependencies saved me a lot of time.

License

- Yes, can be used commercially.
- No, you don't have to credit me, but that would be nice.
- MIT License.