Enable custom component

Thomas 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 3

Hi there

I have the specific case that I have to enable / disable a component / monobehavior on a game object. Is there any solution for this? I didn't found anything useful and had to came up with my own solution. One of the key problems were, when I used the "GetComponent" unit the output was always the gameobject not the monobehavior / component which I looked up. And even if would have the correct type, I didn't found anything to update a component property. How do I do that?

For now I ended up with a helper class which finds the component and enables the monobehavior "enabled"-flag. Is there any proper solution for this? Did I missunterstood something? I have a coding background and really new to the visual scripting concept.

And within the code I have following:

 ((MonoBehaviour)gm.GetComponent(componentToFind)).enabled = true;

Thank you in advance for any suggestions!

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

You don't have to use GetComponent in Bolt.  Bolt will auto get the component for you if you start accessing a units for the component!  (I've never used a GetComponent once in five months of working with Bolt!)

However, for enable/disable, you're looking for Set Enabled, I believe. (or enabled, if using programmer naming)

Oh dear... I was totally confused and overlooked that there are always 2 options. One for input and one for output. Somehow I always took the wrong one and got even more confused. I think I will choose the human readable style over the programmer naming from now. So sorry for bothering you guys :/.

I need to get the component to switch between an image effect on the camera to turn it on or off which depends on the cameras y-axis :).