Skip to content

Commit

Permalink
Avoid unnecessary string processing
Browse files Browse the repository at this point in the history
  • Loading branch information
c3-hoge-fuga-piyo committed May 13, 2021
1 parent f66d6b6 commit d4b5dbf
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions VContainer/Assets/VContainer/Editor/ScriptTemplateModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@ public static void OnWillCreateAsset(string metaPath)
return;
}

if (!scriptPath.EndsWith("LifetimeScope.cs"))
{
return;
}

var content = MonoInstallerTemplate.Replace("#SCRIPTNAME#", basename);

if (scriptPath.StartsWith("Assets/"))
{
scriptPath = scriptPath.Substring("Assets/".Length);
}

var fullPath = Path.Combine(Application.dataPath, scriptPath);
if (scriptPath.EndsWith("LifetimeScope.cs"))
{
var content = MonoInstallerTemplate.Replace("#SCRIPTNAME#", basename);
File.WriteAllText(fullPath, content);
AssetDatabase.Refresh();
}
File.WriteAllText(fullPath, content);
AssetDatabase.Refresh();
}
}
}

0 comments on commit d4b5dbf

Please sign in to comment.