Skip to content

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

License

Notifications You must be signed in to change notification settings

AndersonMarquess/AM_DI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

"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

3 - Done!

Usage example in code


    [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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages