Skip to content

Latest commit

 

History

History
75 lines (45 loc) · 2.28 KB

README.md

File metadata and controls

75 lines (45 loc) · 2.28 KB

Component Connector ✨

Automatically connect "correct components" in Unity

cc_img_1

Setup ⛏

  1. Copy ComponentConnector.cs to your project.
  2. Attach ComponentConnector component to root game object.

cc_img_2

How to use ⚡️

  • Component Connect

Just add [ComponentConnect] attribute to your public field.

// Match with field name
[ComponentConnect] public GameObject someObject;

// Match with "AwesomeObj"
[ComponentConnect("AwesomeObj")] public GameObject awesomeObject;
  • Get Component

Just add [GetComponent] attribute to your public field.

[GetComponent] public SpriteRenderer spriteRenderer;

cc_img_3

  • Button OnClick Event Connect (Bonus but not recommended)

Add [OnClick] attribute to method, and extend IComponentConnector interface to class.

public class SomeClass : MonoBehaviour, IComponentConnector {

    [OnClick("SomeButton")]
    public void OnClickSomeButton() { ... }
    
}

cc_img_4

Performance issue 😅

Component Connector basically performs a full scan operation after the change of the editor is detected or compiled.

Therefore, if there are many objects in the scene, performance degradation may occur within the editor, and in this case I recommend the following methods.

  1. Disable the ComponentConnector script that exists in the scene
  2. Perform a scan job directly using the Context Menu of the desired component

I have plan to change to a better algorithm in the future.

cc_img_5

Warning ⚠

I do not responsibility for the issue that you encountered by using this code. But I saved my time for the projects below.

Projects using Component Connector 👀

License

Component Connector is under MIT license. See the LICENSE file for more info.