If enabled, all Gradle daemons stop when the Unity Editor exits.
using UnityEngine; using UnityEditor; using UnityEditor.Android;
public class GradleDaemonSample { [MenuItem("Build/Toggle Gradle Daemons Stop On Exit")] public static void ToggleStopGradleDaemonsOnExit() { // Get the current state of the setting bool currentState = AndroidExternalToolsSettings.stopGradleDaemonsOnExit; // Toggle the setting to change its current state) AndroidExternalToolsSettings.stopGradleDaemonsOnExit = !currentState; // Log the result
if (AndroidExternalToolsSettings.stopGradleDaemonsOnExit) { Debug.Log("Gradle Daemons will stop automatically when you exit the Editor."); } else { Debug.Log("Gradle Daemons will not stop automatically when you exit the Editor."); } } }