component constructor parameters
is there any way to create a component that takes parameters? eg.
the component is only ever constructed by calling
the component is only ever constructed by calling
components.addComponent()Solution
Late but there is a simple way to do it with a macro:
This just takes the component you want to create, whatever attributes you want to attach to it (which should align with the ones it requires) and optionally an instance to attach it to and uses the macro api to get the ID of the component you passed. You could probably also use the passed component to assert required attributes or get intellisense for them but I am too lazy. This is better than explicitly passing parameters to components since the component will not get those parameters if it's just constructed by a preexisting tagged object, and having multiple ways a component can get constructed is confusing. Hopefully this helps anyone searching for an answer
This just takes the component you want to create, whatever attributes you want to attach to it (which should align with the ones it requires) and optionally an instance to attach it to and uses the macro api to get the ID of the component you passed. You could probably also use the passed component to assert required attributes or get intellisense for them but I am too lazy. This is better than explicitly passing parameters to components since the component will not get those parameters if it's just constructed by a preexisting tagged object, and having multiple ways a component can get constructed is confusing. Hopefully this helps anyone searching for an answer
