Skip to content

Commit

Permalink
More install fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyvelour committed Jan 8, 2019
1 parent 4411e3f commit 4f38db4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
3 changes: 0 additions & 3 deletions Editor/Utils/ReflectionHelpers.cs
Expand Up @@ -49,9 +49,6 @@ static ReflectionHelpers()
}
else if (assembly.FullName.StartsWith("UnityEditor"))
{
// HACK
if (type.Name == "CSharpNamespaceParser") continue;

_editorTypeMap[type.Name] = type;
}
}
Expand Down
30 changes: 16 additions & 14 deletions Install/FluvioFXInstall.cs
Expand Up @@ -99,13 +99,13 @@ private static void Install(bool force = false)
var integrationFileExists = File.Exists($"{vfxPath}/Editor/FluvioFXIntegration.cs");

// VFXCodeGenerator.cs can't be found
var vfxCodeGenDir = $"{vfxPath}/Editor/Compiler";
var vfxCodeGenFileName = "VFXCodeGenerator.cs";
var vfxCodeGenPath = $"{vfxCodeGenDir}/{vfxCodeGenFileName}";
var vfxCodeGenPath = $"{vfxPath}/Editor/Compiler/VFXCodeGenerator.cs";
string vfxCodeGenFile;
try
{
vfxCodeGenFile = File.ReadAllText(vfxCodeGenPath);
vfxCodeGenFile = File
.ReadAllText(vfxCodeGenPath)
.Replace("\r\n", "\n");
}
catch
{
Expand Down Expand Up @@ -136,19 +136,20 @@ private static void Install(bool force = false)
{
// Modify VFXCodeGenerator.cs
vfxCodeGenFile = vfxCodeGenFile
.Replace(codeGenEventCallReplace, codeGenEventCall)
.Replace(codeGenEventReplace, codeGenEvent)
.Replace(codeGenEventCall, codeGenEventCallReplace)
.Replace(codeGenEvent, codeGenEventReplace);
.Replace(codeGenEventCallReplace.Replace("\r\n", "\n"), codeGenEventCall.Replace("\r\n", "\n"))
.Replace(codeGenEventReplace.Replace("\r\n", "\n"), codeGenEvent.Replace("\r\n", "\n"))
.Replace(codeGenEventCall.Replace("\r\n", "\n"), codeGenEventCallReplace.Replace("\r\n", "\n"))
.Replace(codeGenEvent.Replace("\r\n", "\n"), codeGenEventReplace.Replace("\r\n", "\n"));

try
{
SaveFile(vfxCodeGenDir, vfxCodeGenFileName, vfxCodeGenFile);
// Save VFXCodeGenerator.cs
SaveReadOnlyFile(vfxCodeGenPath, vfxCodeGenFile);

// Add integration file
// Add FluvioFXIntegration.cs
var integrationFilePath = $"{vfxPath}/Editor/FluvioFXIntegration.cs";
File.WriteAllText(integrationFilePath, integrationFile);
File.WriteAllText($"{integrationFilePath}.meta", integrationFileMeta);
SaveReadOnlyFile(integrationFilePath, integrationFile);
SaveReadOnlyFile($"{integrationFilePath}.meta", integrationFileMeta);

Debug.Log("FluvioFX install successful!");

Expand Down Expand Up @@ -207,12 +208,13 @@ private static void SetDefine(bool add)
}
}

private static void SaveFile(string directoryName, string filename, string text)
private static void SaveReadOnlyFile(string path, string text)
{
var path = Path.Combine(directoryName, filename);
path = path.Replace("\\", "/");

File.SetAttributes(path, FileAttributes.Normal);
File.WriteAllText(path, text);
File.SetAttributes(path, FileAttributes.ReadOnly);
}
}
}
3 changes: 0 additions & 3 deletions Install/ReflectionHelpers.cs
Expand Up @@ -49,9 +49,6 @@ static ReflectionHelpers()
}
else if (assembly.FullName.StartsWith("UnityEditor"))
{
// HACK
if (type.Name == "CSharpNamespaceParser") continue;

_editorTypeMap[type.Name] = type;
}
}
Expand Down

0 comments on commit 4f38db4

Please sign in to comment.