I'd like to ask a case when developing a game using Unity.
There are many UI elements in the game.
These UI elements normally disappear from scenes when the purpose is achieved.
However, the Destroy
or SetActive
methods provided by Unity greatly affect game objects and sometimes lead to errors, especially when using coroutines, causing stability problems.
When making and using UI, is it standard and stable to use Alpha values of the UI's Image
/panel component or Text
component to make it disappear or appear?
Or is it standard and stable to use the SetActive
function, passing true or false?
Destroy
orSetActive
are leading to errors, you have written your code wrong, or made an error in your scene setup. API methods don't throw errors randomly — they obey a specific contract, and if you use them out of contract leading to unwanted behaviour, that's your error, and something you can fix. If you'd like help fixing those root problems, edit your question to document the steps to create a Minimal Complete Verifiable Example of one specific problem you've encountered when trying to use one of these methods. \$\endgroup\$Destroy
, but a result of using it under the wrong mental model. If you edit your question to show us what you did, there's a good chance we can show you how to fix it. \$\endgroup\$