It’s hard to fight off fungus gnats and chameleon enclosures, because they thrive in moist environments. For house plants you can change the potting medium to ensure that it drains well and allows some air pockets, and that the top 2 inches dry out before you re-water. That’s a good practice anyway to avoid root rot.
What has been most successful for me in my chameleon enclosures is hatching mantis ooths. I occasionally have bouts with white fly, which are about the size of soil gnats but… White! They’re a pain in the butt, but the mantids hatch, munch on the gnats or white flies for a few days before becoming a snack for the Chameleon. It’s also a great enrichment for the Chameleon! When one or two mantis escape… I don’t mind because they’ll chill on my house plants and continue to do the good work.