// Updates the given file with wrapper code generated for the given action sets.
        // If the generated code is unchanged, does not touch the file.
        // Returns true if the file was touched, false otherwise.
        public static bool GenerateWrapperCode(string filePath, InputActionAsset asset, Options options)
        {
            if (!Path.HasExtension(filePath))
            {
                filePath += ".cs";
            }

            // Generate code.
            var code = GenerateWrapperCode(asset, options);

            // Check if the code changed. Don't write if it hasn't.
            if (File.Exists(filePath))
            {
                var existingCode = File.ReadAllText(filePath);
                if (existingCode == code || existingCode.WithAllWhitespaceStripped() == code.WithAllWhitespaceStripped())
                {
                    return(false);
                }
            }

            // Write.
            EditorHelpers.CheckOut(filePath);
            File.WriteAllText(filePath, code);
            return(true);
        }
        internal void SaveChangesToAsset()
        {
            Debug.Assert(importedAsset != null);

            // Update JSON.
            var asset = m_AssetObjectForEditing;

            m_ImportedAssetJson = asset.ToJson();

            // Write out, if changed.
            var assetPath    = path;
            var existingJson = File.ReadAllText(assetPath);

            if (m_ImportedAssetJson != existingJson)
            {
                EditorHelpers.CheckOut(assetPath);
                File.WriteAllText(assetPath, m_ImportedAssetJson);
                AssetDatabase.ImportAsset(assetPath);
            }

            m_IsDirty = false;
            onDirtyChanged(false);
        }