Component in component

Hi guys,
I’ve created a “section” component (with image, title, text and background colour management). I’d like to add a button to this “section” component. I’ve already created a “button” component, so I’d like to use it in the “section” component.
What’s more, I’d like to be able to activate or deactivate this button because sometimes sections don’t need a button.
Do you have any ideas?

Hi @cpennetier,

Thanks for reaching out.
It is not very clear what you are trying to acheive here. You can add components within another component. But if you want to show the child component in a special case, you need to add a condition to the component.
If that is not the case and you are trying to point out something else, please provide more information on this.

Thanks

Hi @tristup,
I’ll try to be much clearer with an example.


I create a first component called “A”, which is a button with the following parameters: text, url.
I create another component called “B”, which is a section with the following parameters: an image, a title and a paragraph.


I think I could add component “A” to component “B”. For example, after the “paragraph” parameter.


However, I don’t want to rewrite the “text, url” parameters of button “A” in “B”.
(In reality, my button has 12 parameters).


Let me rephrase my question: can I access the “A” parameter through “B” without rewriting everything?

Thanks

We have to update things on our end, but this was also a thing we wanted to do on the Personify project. I have a couple things to do before we can use a component in a component and still keep the parameters, but unfortunately no you can’t keep the parameters when exporting a component that exclusively uses a component. You could probably get around this by adding a div and having the component inside the div. Then setup the Div as a component and export it as a prefab. Have a great weekend.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.