3.0.0-preview.37
# [3.0.0-preview.37](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.36...v3.0.0-preview.37) (2020-10-01)
### Bug Fixes
* fix menus ([5fa12b5](5fa12b5338
))
pull/120/head
parent
4b4d70bdd1
commit
7bf1bae64a
|
@ -1,3 +1,10 @@
|
||||||
|
# [3.0.0-preview.37](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.36...v3.0.0-preview.37) (2020-10-01)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix menus ([5fa12b5](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5fa12b5338a90764a3bf384dcd3911f2ab4eba61))
|
||||||
|
|
||||||
# [3.0.0-preview.36](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.35...v3.0.0-preview.36) (2020-09-28)
|
# [3.0.0-preview.36](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.35...v3.0.0-preview.36) (2020-09-28)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,67 +4,76 @@ using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
static class ImportSampleMenu_UIParticle
|
namespace Coffee.UIExtensions
|
||||||
{
|
{
|
||||||
private const string k_DisplayName = "UI Particle";
|
internal static class ImportSampleMenu_UIParticle
|
||||||
private const string k_JsonGuid = "823dc693d087a4b559c7e1547274cc7d";
|
|
||||||
|
|
||||||
[MenuItem("Assets/Samples/" + k_DisplayName + "/Import Demo")]
|
|
||||||
private static void ImportDemo()
|
|
||||||
{
|
{
|
||||||
ImportSample(k_JsonGuid, "Demo");
|
private const string k_DisplayName = "UI Particle";
|
||||||
}
|
private const string k_JsonGuid = "823dc693d087a4b559c7e1547274cc7d";
|
||||||
|
|
||||||
private static void ImportSample(string jsonGuid, string sampleName)
|
[MenuItem("Assets/Samples/" + k_DisplayName + "/Demo")]
|
||||||
{
|
private static void ImportSample()
|
||||||
var jsonPath = AssetDatabase.GUIDToAssetPath(jsonGuid);
|
|
||||||
var packageRoot = Path.GetDirectoryName(jsonPath).Replace('\\', '/');
|
|
||||||
var json = File.ReadAllText(jsonPath);
|
|
||||||
var version = Regex.Match(json, "\"version\"\\s*:\\s*\"([^\"]+)\"").Groups[1].Value;
|
|
||||||
var src = string.Format("{0}/Samples~/{1}", packageRoot, sampleName);
|
|
||||||
var dst = string.Format("Assets/Samples/{0}/{1}/{2}", k_DisplayName, version, sampleName);
|
|
||||||
var previousPath = GetPreviousSamplePath(k_DisplayName, sampleName);
|
|
||||||
|
|
||||||
// Remove the previous sample directory.
|
|
||||||
if (!string.IsNullOrEmpty(previousPath))
|
|
||||||
{
|
{
|
||||||
var msg = "A different version of the sample is already imported at\n\n"
|
ImportSample(k_JsonGuid, "Demo");
|
||||||
+ previousPath
|
|
||||||
+ "\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(previousPath);
|
|
||||||
|
|
||||||
var metaFile = previousPath + ".meta";
|
|
||||||
if (File.Exists(metaFile))
|
|
||||||
FileUtil.DeleteFileOrDirectory(metaFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists(dst))
|
[MenuItem("Assets/Samples/" + k_DisplayName + "/Cartoon FX & War FX Demo")]
|
||||||
FileUtil.DeleteFileOrDirectory(dst);
|
private static void ImportSample_CFX()
|
||||||
|
{
|
||||||
|
ImportSample(k_JsonGuid, "Cartoon FX & War FX Demo");
|
||||||
|
}
|
||||||
|
|
||||||
var dstDir = Path.GetDirectoryName(dst);
|
private static void ImportSample(string jsonGuid, string sampleName)
|
||||||
if (!Directory.Exists(dstDir))
|
{
|
||||||
Directory.CreateDirectory(dstDir);
|
var jsonPath = AssetDatabase.GUIDToAssetPath(jsonGuid);
|
||||||
|
var packageRoot = Path.GetDirectoryName(jsonPath).Replace('\\', '/');
|
||||||
|
var json = File.ReadAllText(jsonPath);
|
||||||
|
var version = Regex.Match(json, "\"version\"\\s*:\\s*\"([^\"]+)\"").Groups[1].Value;
|
||||||
|
var src = string.Format("{0}/Samples~/{1}", packageRoot, sampleName);
|
||||||
|
var dst = string.Format("Assets/Samples/{0}/{1}/{2}", k_DisplayName, version, sampleName);
|
||||||
|
var previousPath = GetPreviousSamplePath(k_DisplayName, sampleName);
|
||||||
|
|
||||||
if (Directory.Exists(src))
|
// Remove the previous sample directory.
|
||||||
FileUtil.CopyFileOrDirectory(src, dst);
|
if (!string.IsNullOrEmpty(previousPath))
|
||||||
else
|
{
|
||||||
throw new DirectoryNotFoundException(src);
|
var msg = "A different version of the sample is already imported at\n\n"
|
||||||
|
+ previousPath
|
||||||
|
+ "\n\nIt will be deleted when you update. Are you sure you want to continue?";
|
||||||
|
if (!EditorUtility.DisplayDialog("Sample Importer", msg, "OK", "Cancel"))
|
||||||
|
return;
|
||||||
|
|
||||||
AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive);
|
FileUtil.DeleteFileOrDirectory(previousPath);
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetPreviousSamplePath(string displayName, string sampleName)
|
var metaFile = previousPath + ".meta";
|
||||||
{
|
if (File.Exists(metaFile))
|
||||||
var sampleRoot = string.Format("Assets/Samples/{0}", displayName);
|
FileUtil.DeleteFileOrDirectory(metaFile);
|
||||||
var sampleRootInfo = new DirectoryInfo(sampleRoot);
|
}
|
||||||
if (!sampleRootInfo.Exists) return null;
|
|
||||||
|
|
||||||
return sampleRootInfo.GetDirectories()
|
if (!Directory.Exists(dst))
|
||||||
.Select(versionDir => Path.Combine(versionDir.ToString(), sampleName))
|
FileUtil.DeleteFileOrDirectory(dst);
|
||||||
.FirstOrDefault(Directory.Exists);
|
|
||||||
|
var dstDir = Path.GetDirectoryName(dst);
|
||||||
|
if (!Directory.Exists(dstDir))
|
||||||
|
Directory.CreateDirectory(dstDir);
|
||||||
|
|
||||||
|
if (Directory.Exists(src))
|
||||||
|
FileUtil.CopyFileOrDirectory(src, dst);
|
||||||
|
else
|
||||||
|
throw new DirectoryNotFoundException(src);
|
||||||
|
|
||||||
|
AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetPreviousSamplePath(string displayName, string sampleName)
|
||||||
|
{
|
||||||
|
var sampleRoot = string.Format("Assets/Samples/{0}", displayName);
|
||||||
|
var sampleRootInfo = new DirectoryInfo(sampleRoot);
|
||||||
|
if (!sampleRootInfo.Exists) return null;
|
||||||
|
|
||||||
|
return sampleRootInfo.GetDirectories()
|
||||||
|
.Select(versionDir => Path.Combine(versionDir.ToString(), sampleName))
|
||||||
|
.FirstOrDefault(Directory.Exists);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace Coffee.UIExtensions
|
||||||
|
{
|
||||||
|
internal class UIParticleMenu
|
||||||
|
{
|
||||||
|
[MenuItem("GameObject/UI/Particle System (Empty)", false, 2018)]
|
||||||
|
private static void AddParticleEmpty(MenuCommand menuCommand)
|
||||||
|
{
|
||||||
|
// Create empty UI element.
|
||||||
|
EditorApplication.ExecuteMenuItem("GameObject/UI/Image");
|
||||||
|
var ui = Selection.activeGameObject;
|
||||||
|
Object.DestroyImmediate(ui.GetComponent<Image>());
|
||||||
|
|
||||||
|
// Add UIParticle.
|
||||||
|
var uiParticle = ui.AddComponent<UIParticle>();
|
||||||
|
uiParticle.name = "UIParticle";
|
||||||
|
uiParticle.scale = 10;
|
||||||
|
uiParticle.rectTransform.sizeDelta = Vector2.zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/UI/Particle System", false, 2019)]
|
||||||
|
private static void AddParticle(MenuCommand menuCommand)
|
||||||
|
{
|
||||||
|
// Create empty UIEffect.
|
||||||
|
AddParticleEmpty(menuCommand);
|
||||||
|
var uiParticle = Selection.activeGameObject.GetComponent<UIParticle>();
|
||||||
|
|
||||||
|
// Create ParticleSystem.
|
||||||
|
EditorApplication.ExecuteMenuItem("GameObject/Effects/Particle System");
|
||||||
|
var ps = Selection.activeGameObject;
|
||||||
|
ps.transform.SetParent(uiParticle.transform, false);
|
||||||
|
ps.transform.localPosition = Vector3.zero;
|
||||||
|
|
||||||
|
// Assign default material.
|
||||||
|
var renderer = ps.GetComponent<ParticleSystemRenderer>();
|
||||||
|
var defaultMat = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Particle.mat");
|
||||||
|
renderer.material = defaultMat ? defaultMat : renderer.material;
|
||||||
|
|
||||||
|
// Refresh particles.
|
||||||
|
uiParticle.RefreshParticles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0ad158a8abf7646d6b540eed4a91a2dc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -6,7 +6,7 @@ using UnityEngine.Profiling;
|
||||||
|
|
||||||
namespace Coffee.UIExtensions
|
namespace Coffee.UIExtensions
|
||||||
{
|
{
|
||||||
public static class UIParticleUpdater
|
internal static class UIParticleUpdater
|
||||||
{
|
{
|
||||||
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>();
|
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>();
|
||||||
static MaterialPropertyBlock s_Mpb;
|
static MaterialPropertyBlock s_Mpb;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "com.coffee.ui-particle",
|
"name": "com.coffee.ui-particle",
|
||||||
"displayName": "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.",
|
"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.36",
|
"version": "3.0.0-preview.37",
|
||||||
"unity": "2018.2",
|
"unity": "2018.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
Loading…
Reference in New Issue