I quickly refused this solution and here are 2 main reasons:
- You can’t interact with disabled gameobjects and their components from script
- You can’t change states and send events to disabled gameobjects using PlayMaker FSMs
I started looking for some workaround…
There IS solution
I found solution which allow to hide GUI elements without disabling GameObjects using Canvas Group component. This component allows you to change transparency of GUI element and all its child objects (e.g. text on Button) as well as “Interactable“, “Blocks Raycasts” and “Ignore Parent Group” parameters. It works really well. You can easily access and manipulate all these parameters from script. Unfortunately, I didn’t find any action to modify Canvas Group component either inside PlayMaker or Hutong Wiki nor in Eco and Google. So I decided to write my own action.
“Set Canvas Group Properties” Playmaker action
To install this action:
- Download RAR-archieve
- Back-up your project
- Extract cs-file to your Assets folder (you must have Playmaker imported to your project)
- Wait until script compiled
Then go to Playmaker Action Browser and type “Canvas” in search field. You should see something like this:
And if you add this action to state it should look like this:
Rememberto make it works you must attach CanvasGroup component to GameObject!
Now you can easily change transparency of any uGUI element, access hidden elements from script or FSM and do a lot of cool stuff! If you encountered any problems with this Playmaker action please let me know in comments.
If you’ve found this article useful, please share it with your friends using social buttons below.
Thanks for reading, stay tuned!