public void Compile() { AssetDatabase.SaveAssets(); if (!IsValid()) { throw new InvalidDataException("One or more nodes are invalid."); } var path = Path.ChangeExtension(AssetDatabase.GetAssetPath(this), ".cs"); using (var stream = File.Exists(path) ? File.Open(path, FileMode.Truncate) : File.Create(path)) { using (var writer = new SchemaWriter(stream)) { writer.BeginTypeDeclaration(Name, BaseType.FullName); var functionDeclarations = GetFunctionDeclarations(); for (int i = 0; i < functionDeclarations.Length; i++) { functionDeclarations[i].Write(writer); } writer.EndTypeDeclaration(); } } AssetDatabase.Refresh(); }