3.0.0-preview.36
# [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) ### Bug Fixes * do not bake particle system to mesh when the alpha is zero ([1775713](pull/120/head1775713c2d
)), closes [#102](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/102) * in Unity 2018.x, sample import failed on Windows ([f5861b0](f5861b0add
))
parent
94ae9d2016
commit
4b4d70bdd1
|
@ -1,3 +1,11 @@
|
|||
# [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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* do not bake particle system to mesh when the alpha is zero ([1775713](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/1775713c2dbeef09ad3eb1f49b53cf44bf61d535)), closes [#102](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/102)
|
||||
* in Unity 2018.x, sample import failed on Windows ([f5861b0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f5861b0add1477987d6b9a3db26979fde50930ad))
|
||||
|
||||
# [3.0.0-preview.35](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.34...v3.0.0-preview.35) (2020-09-27)
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
namespace Coffee.UIParticleExtensions
|
||||
{
|
||||
internal class BakingCamera : MonoBehaviour
|
||||
{
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
namespace Coffee.UIParticleExtensions
|
||||
{
|
||||
internal class CombineInstanceEx
|
||||
{
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
#if !UNITY_2019_1_OR_NEWER
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
|
||||
static class ImportSampleMenu_UIParticle
|
||||
{
|
||||
private const string k_DisplayName = "UI Particle";
|
||||
private const string k_JsonGuid = "823dc693d087a4b559c7e1547274cc7d";
|
||||
|
||||
[MenuItem("Assets/Samples/" + k_DisplayName + "/Import Demo")]
|
||||
private static void ImportDemo()
|
||||
{
|
||||
ImportSample(k_JsonGuid, "Demo");
|
||||
}
|
||||
|
||||
private static void ImportSample(string jsonGuid, string sampleName)
|
||||
{
|
||||
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"
|
||||
+ 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))
|
||||
FileUtil.DeleteFileOrDirectory(dst);
|
||||
|
||||
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
|
|
@ -1,113 +0,0 @@
|
|||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
public class UIParticleMenu
|
||||
{
|
||||
#if !UNITY_2019_1_OR_NEWER
|
||||
static string GetPreviousSamplePath(string displayName, string sampleName)
|
||||
{
|
||||
string sampleRoot = string.Format("Assets/Samples/{0}", displayName);
|
||||
var sampleRootInfo = new DirectoryInfo(sampleRoot);
|
||||
if (!sampleRootInfo.Exists) return null;
|
||||
|
||||
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 = 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 = 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))
|
||||
{
|
||||
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 + ".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);
|
||||
}
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(dst));
|
||||
FileUtil.CopyFileOrDirectory(src, dst);
|
||||
AssetDatabase.ImportAsset(dst, ImportAssetOptions.ImportRecursive);
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Samples/Import UIParticle Demo")]
|
||||
static void ImportSample()
|
||||
{
|
||||
ImportSample("com.coffee.ui-particle", "Demo");
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Samples/Import UIParticle Demo (Cartoon FX & War FX Demo)")]
|
||||
static void ImportSample_CFX()
|
||||
{
|
||||
ImportSample("com.coffee.ui-particle", "Cartoon FX & War FX Demo");
|
||||
}
|
||||
#endif
|
||||
|
||||
[MenuItem("GameObject/UI/Particle System (Empty)", false, 2018)]
|
||||
public 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)]
|
||||
public 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
namespace Coffee.UIParticleExtensions
|
||||
{
|
||||
internal static class MeshHelper
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Coffee.UIParticleExtensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Serialization;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Coffee.UIParticleExtensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
|
@ -196,6 +197,10 @@ namespace Coffee.UIExtensions
|
|||
Profiler.EndSample();
|
||||
}
|
||||
|
||||
// #102: Do not bake particle system to mesh when the alpha is zero.
|
||||
if (Mathf.Approximately( particle.canvasRenderer.GetInheritedAlpha(), 0))
|
||||
continue;
|
||||
|
||||
// Bake main particles.
|
||||
var r = currentPs.GetComponent<ParticleSystemRenderer>();
|
||||
if (CanBakeMesh(r))
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
namespace Coffee.UIParticleExtensions
|
||||
{
|
||||
internal static class SpriteExtensions
|
||||
{
|
||||
|
|
|
@ -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.35",
|
||||
"version": "3.0.0-preview.36",
|
||||
"unity": "2018.2",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
|
Loading…
Reference in New Issue