SolidAlloy / GenericUnityObjects

Generic UnityEngine.Objects
Other
167 stars 13 forks source link

Add support for AddComponentMenu attribute on generic MonoBehaviours #6

Closed SolidAlloy closed 3 years ago

SolidAlloy commented 3 years ago

The plugin currently doesn't support custom paths and orders set in the AddComponentMenu attribute. It is not difficult to implement though. A general idea is like this: Copy the custom values set in generic MonoBehaviour's AddComponentMenu attribute to the AddComponentMenu attribute of BehaviourSelector and concrete classes. However, generic arguments must be added to the name. For example:

[AddComponentMenu("Scripts/CustomPath/CustomName", 0)
public class GenericBehaviour<T> { }

The path added to BehaviourSelector must be "Scripts/CustomPath/CustomName", and for each concrete class it will be like "Scripts/CustomPath/CustomName". Also, paths that don't start with Scripts must be prohibited because they don't allow setting custom names to components (the ones you see above the component fields in the inspector).

The workflow can be like this:

SolidAlloy commented 3 years ago

Resolved in 2.4.0