Skip to content

Instantly share code, notes, and snippets.

@Fogsight
Forked from jbevain/ReferenceRemovalProjectHook.cs
Last active January 29, 2021 12:53
Show Gist options
  • Select an option

  • Save Fogsight/d8dd87315ff12245614334dfdcff5b28 to your computer and use it in GitHub Desktop.

Select an option

Save Fogsight/d8dd87315ff12245614334dfdcff5b28 to your computer and use it in GitHub Desktop.
Project Generation Hook to remove references to Boo.Lang (Updated for Unity 2019.4)
using SyntaxTree.VisualStudio.Unity.Bridge;
using UnityEditor;
[InitializeOnLoad]
public class ReferenceRemovalProjectHook {
static ReferenceRemovalProjectHook() => ProjectFilesGenerator.ProjectFileGeneration += (string name, string content) => GetAmmendedProjectFile(content);
private static string GetAmmendedProjectFile(string content) {
string start = "\r\n <Reference Include=\"Boo.Lang\">";
string end = "</Reference>";
int startIndex = content.IndexOf(start);
string temp = content.Substring(startIndex); //Get tail
temp = temp.Substring(0, temp.IndexOf(end) + end.Length); // Get replacement string
return content.Replace(temp, "");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment