[Feature Request] Set variable to public with Blueprint

Feature Request on future updates or versions.

A Node that would set variables to public in Construction Script

An example is to Switch on Enum and toggle a specified variable public or not.
This way we can hide / unhide the variable depending on it is used or not.
Can be also used with Branch / Select / … or anything that switches things.

The Node would more or less look like this :

223498-ue-02.png

Sets a variable to public. Target is Variable. Target type is Wildcard. Using boolean “Is Public”. Node would toggle the “eye” (public variable).
Might be called only in Construction Script.

Material / Material Instance looks like already having this feature using Static Bool Param / Switch.

We hope it would be possible.
Thank you in advance.

You cannot change access modifiers at runtime since they are created at compile time and will be immutable during runtime. Since construction scripts get called at runtime, this would not be possible. Even if it was possible, it would be a bad idea since it would brake all references to this variable from other blueprints. The access modifier is not only used for visibility in the editor.
But being able to set the visibility in the editor could be a useful feature though.

Why do you even want to do this ?

I’ve also seen another user asking the same question :

Since I was not the only one, I thought it would be possible. But you’re probably right about it.

Working on mostly procedual stuffs. Having too much unused parameters is sometimes annoying.

1 Like

Well, changing the actual access modifier is impossible by design. However I definitely think it would be useful if you could change the visibility in the editor without having to set the variable to private.