Skip to content

Commit

Permalink
fix: sample version
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Feb 21, 2020
1 parent 6a2de8e commit ed18032
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Packages/UIParticle/Scripts/Editor/UIParticleMenu.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#if IGNORE_ACCESS_CHECKS // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
#if !UNITY_2019_1_OR_NEWER
using System.IO;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Expand All @@ -12,13 +14,27 @@ public class UIParticleMenu
[MenuItem("Assets/Samples/Import UIParticle Sample")]
static void ImportSample()
{
const string src = "Packages/com.coffee.ui-particle/Samples~/Demo";
const string dst = "Assets/Samples/UI Particle/3.0.0/Demo";
const string sampleGuid = "dc0fe9e7fe61947fab1522ab29e2fc88";
const string jsonGuid = "823dc693d087a4b559c7e1547274cc7d";
const string SAMPLE_NAME = "Demo";

if (FileUtil.PathExists(dst))
FileUtil.DeleteFileOrDirectory(dst);
string jsonPath = AssetDatabase.GUIDToAssetPath(jsonGuid);
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~/" + SAMPLE_NAME;
string dst = string.Format("Assets/Samples/{0}/{1}/{2}",displayName, version, SAMPLE_NAME);

// Remove old samples
string samplePath = AssetDatabase.GUIDToAssetPath(sampleGuid);
if (samplePath.StartsWith("Assets/") && FileUtil.PathExists(samplePath))
{
FileUtil.DeleteFileOrDirectory(samplePath);
FileUtil.DeleteFileOrDirectory(samplePath + ".meta");
}

FileUtil.CopyDirectoryRecursive(src, dst);
FileUtil.CopyFileOrDirectory(src + ".meta", dst + ".meta");
AssetDatabase.ImportAsset(dst, ImportAssetOptions.ImportRecursive);
}
}
Expand Down

0 comments on commit ed18032

Please sign in to comment.