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.
- Host: GitHub
- URL: https://github.com/andersonmarquess/am_di
- Owner: AndersonMarquess
- License: mit
- Created: 2022-04-24T15:46:29.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-14T13:17:41.000Z (over 3 years ago)
- Last Synced: 2025-04-10T21:01:16.584Z (about 1 year ago)
- Topics: plugin, unity, unity-asset, unity-editor
- Language: C#
- Homepage:
- Size: 85 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
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"

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.