Skip to content

Commit

Permalink
fix: support .Net Framework 3.5 (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Aug 19, 2020
1 parent f99292b commit 23fcb06
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Packages/UIParticle/Scripts/Editor/UIParticleMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class UIParticleMenu
#if !UNITY_2019_1_OR_NEWER
static string GetPreviousSamplePath(string displayName, string sampleName)
{
string sampleRoot = $"Assets/Samples/{displayName}";
string sampleRoot = string.Format("Assets/Samples/{0}", displayName);
var sampleRootInfo = new DirectoryInfo(sampleRoot);
if (!sampleRootInfo.Exists) return null;

Expand All @@ -27,12 +27,12 @@ static string GetPreviousSamplePath(string displayName, string sampleName)

static void ImportSample(string packageName, string sampleName)
{
string jsonPath = $"Packages/{packageName}/package.json";
string jsonPath = string.Format("Packages/{0}/package.json", packageName);
string json = File.ReadAllText(jsonPath);
string version = Regex.Match(json, "\"version\"\\s*:\\s*\"([^\"]+)\"").Groups[1].Value;
string displayName = Regex.Match(json, "\"displayName\"\\s*:\\s*\"([^\"]+)\"").Groups[1].Value;
string src = $"{Path.GetDirectoryName(jsonPath)}/Samples~/{sampleName}";
string dst = $"Assets/Samples/{displayName}/{version}/{sampleName}";
string src = string.Format("{0}/Samples~/{1}", Path.GetDirectoryName(jsonPath), sampleName);
string dst = string.Format("Assets/Samples/{0}/{1}/{2}", displayName, version, sampleName);
string previous = GetPreviousSamplePath(displayName, sampleName);

if (!string.IsNullOrEmpty(previous))
Expand All @@ -43,11 +43,19 @@ static void ImportSample(string packageName, string sampleName)
if (!EditorUtility.DisplayDialog("Sample Importer", msg, "OK", "Cancel"))
return;

FileUtil.DeleteFileOrDirectory(previous);
FileUtil.DeleteFileOrDirectory(previous + ".meta");
FileUtil.DeleteFileOrDirectory(previous);

string versionDir = Path.GetDirectoryName(previous);
if (Directory.GetFiles(versionDir, "*.meta", SearchOption.TopDirectoryOnly).Length == 0)
{
FileUtil.DeleteFileOrDirectory(versionDir + ".meta");
FileUtil.DeleteFileOrDirectory(versionDir);
}
}

FileUtil.CopyDirectoryRecursive(src, dst);
Directory.CreateDirectory(Path.GetDirectoryName(dst));
FileUtil.CopyFileOrDirectory(src, dst);
AssetDatabase.ImportAsset(dst, ImportAssetOptions.ImportRecursive);
}

Expand Down

0 comments on commit 23fcb06

Please sign in to comment.