Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Added pre and post compiler callbacks for compiling UdonSharpProgramA…
Browse files Browse the repository at this point in the history
…sset.
  • Loading branch information
David Cormack committed Nov 28, 2020
1 parent 79f95eb commit 5bd9ca5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Assets/UdonSharp/Editor/UdonSharpCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public class CompileTaskResult
private CompilationModule[] modules;
private bool isEditorBuild = true;

public delegate void ProgramAssetCompileCallback(UdonSharpProgramAsset programAsset);
public static event ProgramAssetCompileCallback beforeProgramAssetCompile;
public static event ProgramAssetCompileCallback afterProgramAssetCompile;

private static int initAssemblyCounter = 0;

public UdonSharpCompiler(UdonSharpProgramAsset programAsset, bool editorBuild = true)
Expand Down Expand Up @@ -77,6 +81,9 @@ public void Compile()
if (programAsset == null || programAsset.sourceCsScript == null)
continue;

if (beforeProgramAssetCompile != null)
beforeProgramAssetCompile(programAsset);

programAssetsAndPaths.Add((programAsset, AssetDatabase.GetAssetPath(programAsset.sourceCsScript)));
}

Expand Down Expand Up @@ -242,6 +249,15 @@ public void Compile()
UdonSharpEditorCache.Instance.ClearSourceHash(module.programAsset);
}
}

foreach (UdonSharpProgramAsset programAsset in allPrograms)
{
if (programAsset == null || programAsset.sourceCsScript == null)
continue;

if (afterProgramAssetCompile != null)
afterProgramAssetCompile(programAsset);
}
}
finally
{
Expand Down

0 comments on commit 5bd9ca5

Please sign in to comment.