From 8cd1b9e46b92fe803c57037c15c628493b404005 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 2 Mar 2020 10:25:41 +0000 Subject: [PATCH] 3.0.0-preview.7 # [3.0.0-preview.7](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.6...v3.0.0-preview.7) (2020-03-02) ### Bug Fixes * add package keywords ([49d8f3f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/49d8f3fe4c76cf6bd2cd5b6134ee23134532da8e)) * fix sample path ([57ee210](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/57ee21005e114fdf186b5db55ca2b77b7b7c441a)) --- CHANGELOG.md | 8 +++++ Scripts/Editor/UIParticleMenu.cs | 52 +++++++++++++++++++++----------- package.json | 6 +++- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 880194d..9acb6ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# [3.0.0-preview.7](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.6...v3.0.0-preview.7) (2020-03-02) + + +### Bug Fixes + +* add package keywords ([49d8f3f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/49d8f3fe4c76cf6bd2cd5b6134ee23134532da8e)) +* fix sample path ([57ee210](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/57ee21005e114fdf186b5db55ca2b77b7b7c441a)) + # [3.0.0-preview.6](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.5...v3.0.0-preview.6) (2020-02-21) diff --git a/Scripts/Editor/UIParticleMenu.cs b/Scripts/Editor/UIParticleMenu.cs index 286614c..93d2880 100644 --- a/Scripts/Editor/UIParticleMenu.cs +++ b/Scripts/Editor/UIParticleMenu.cs @@ -2,41 +2,59 @@ #if !UNITY_2019_1_OR_NEWER using System.IO; using System.Text.RegularExpressions; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; using UnityEditor; namespace Coffee.UIExtensions { public class UIParticleMenu { - [MenuItem("Assets/Samples/Import UIParticle Sample")] - static void ImportSample() + static string GetPreviousSamplePath(string displayName, string sampleName) { - const string sampleGuid = "dc0fe9e7fe61947fab1522ab29e2fc88"; - const string jsonGuid = "823dc693d087a4b559c7e1547274cc7d"; - const string SAMPLE_NAME = "Demo"; + string sampleRoot = $"Assets/Samples/{displayName}"; + var sampleRootInfo = new DirectoryInfo(sampleRoot); + if (!sampleRootInfo.Exists) return null; - string jsonPath = AssetDatabase.GUIDToAssetPath(jsonGuid); + foreach (var versionDir in sampleRootInfo.GetDirectories()) + { + var samplePath = Path.Combine(versionDir.ToString(), sampleName); + if (Directory.Exists(samplePath)) + return samplePath; + } + return null; + } + + + static void ImportSample(string packageName, string sampleName) + { + string jsonPath = $"Packages/{packageName}/package.json"; 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); + string src = $"{Path.GetDirectoryName(jsonPath)}/Samples~/{sampleName}"; + string dst = $"Assets/Samples/{displayName}/{version}/{sampleName}"; + string previous = GetPreviousSamplePath(displayName, sampleName); - // Remove old samples - string samplePath = AssetDatabase.GUIDToAssetPath(sampleGuid); - if (samplePath.StartsWith("Assets/") && FileUtil.PathExists(samplePath)) + if (!string.IsNullOrEmpty(previous)) { - FileUtil.DeleteFileOrDirectory(samplePath); - FileUtil.DeleteFileOrDirectory(samplePath + ".meta"); + string msg = "A different version of the sample is already imported at\n\n" + + previous + + "\n\nIt will be deleted when you update. Are you sure you want to continue?"; + if (!EditorUtility.DisplayDialog("Sample Importer", msg, "OK", "Cancel")) + return; + + FileUtil.DeleteFileOrDirectory(previous); + FileUtil.DeleteFileOrDirectory(previous + ".meta"); } FileUtil.CopyDirectoryRecursive(src, dst); - FileUtil.CopyFileOrDirectory(src + ".meta", dst + ".meta"); AssetDatabase.ImportAsset(dst, ImportAssetOptions.ImportRecursive); } + + [MenuItem("Assets/Samples/Import UIParticle Sample")] + static void ImportSample() + { + ImportSample("com.coffee.ui-particle", "Demo"); + } } } #endif diff --git a/package.json b/package.json index ed8e0d2..56b58eb 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.coffee.ui-particle", "displayName": "UI Particle", "description": "This plugin provide a component to render particle effect for uGUI.\nThe particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.", - "version": "3.0.0-preview.6", + "version": "3.0.0-preview.7", "unity": "2018.2", "license": "MIT", "repository": { @@ -11,6 +11,10 @@ }, "author": "mob-sakai (https://github.com/mob-sakai)", "dependencies": {}, + "keywords": [ + "ui", + "particle" + ], "samples": [ { "displayName": "Demo",