Created
June 7, 2021 20:17
-
-
Save GoodBoyNinja/41346c112d9b359fe3f31a1e312acaa3 to your computer and use it in GitHub Desktop.
You can remove all the children of a group or a panel in a scriptUI panel using this function. Just pass that object to the function call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function RemoveAllChildrenFromPanel (panelObj) { | |
var panelObj = panelObj || undefined; | |
if (!panelObj || !panelObj.children || !panelObj.children.length) { | |
// no panel, or no children found | |
return; | |
} | |
for (var i = panelObj.children.length - 1; i >= 0; i--) { | |
var crntChildren = panelObj.children[i]; | |
if (!crntChildren) { | |
continue; | |
} | |
try { | |
panelObj.remove(crntChildren); | |
} catch (e) { | |
// something went wrong with removing this children, you can print or alert an error here | |
continue; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment