Created
April 4, 2018 17:44
-
-
Save rakkarage/aa5c98b742f3cda22dc7dd76fcb471dc to your computer and use it in GitHub Desktop.
modify unity generated project files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using System.Text.RegularExpressions; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
class Fix : AssetPostprocessor | |
{ | |
private static void OnGeneratedCSProjectFiles() | |
{ | |
Debug.Log("Fix.OnGeneratedCSProjectFiles"); | |
var dir = Directory.GetCurrentDirectory(); | |
var files = Directory.GetFiles(dir, "*.csproj"); | |
foreach (var file in files) | |
FixProject(file); | |
} | |
static bool FixProject(string file) | |
{ | |
var text = File.ReadAllText(file); | |
var find = "<Reference Include=\"System\" />"; | |
var replace = "<Reference Include=\"System\" /> <Reference Include=\"System.Net.Http\" />"; | |
if (text.IndexOf(find) != -1) | |
{ | |
text = Regex.Replace(text, find, replace); | |
File.WriteAllText(file, text); | |
return true; | |
} | |
else | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment