You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-14 20:20:06 +00:00
3.0.0-preview.18
# [3.0.0-preview.18](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.17...v3.0.0-preview.18) (2020-08-19) ### Bug Fixes * AsmdefEx is no longer required ([50e749c](50e749c183)) * fix camera for baking mesh ([6395a4f](6395a4fa74)) * support .Net Framework 3.5 (again) ([23fcb06](23fcb06bf9)) ### Features * 3.0.0 updater ([f99292b](f99292b9a1)) * add menu to create UIParticle ([14f1c78](14f1c782ff)) * Combine baked meshes to improve performance ([633d058](633d058756)) * improve performance ([77c056a](77c056ad5f)) * optimization for vertices transforms and adding node for trails ([e070e8d](e070e8d5ee)), closes [#75](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/75) * option to ignoring canvas scaling ([fe85fed](fe85fed3c0)) * support 3d scaling ([42a84bc](42a84bc5e1)) * support custom simulation space ([a83e647](a83e64761c)), closes [#78](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/78) * support for particle systems including trail only ([f389d39](f389d39953)), closes [#61](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/61) ### BREAKING CHANGES * The bake-task has changed significantly. It may look different from previous versions.
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
#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 UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -27,12 +27,12 @@ namespace Coffee.UIExtensions
|
||||
|
||||
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))
|
||||
@@ -43,11 +43,19 @@ namespace Coffee.UIExtensions
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -56,7 +64,45 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
ImportSample("com.coffee.ui-particle", "Demo");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
[MenuItem("GameObject/UI/Particle System", false, 2019)]
|
||||
public static void AddParticle(MenuCommand menuCommand)
|
||||
{
|
||||
// Create UI element.
|
||||
EditorApplication.ExecuteMenuItem("GameObject/UI/Image");
|
||||
var ui = Selection.activeGameObject;
|
||||
|
||||
// Create ParticleSystem.
|
||||
EditorApplication.ExecuteMenuItem("GameObject/Effects/Particle System");
|
||||
var ps = Selection.activeGameObject;
|
||||
var transform = ps.transform;
|
||||
var localRotation = transform.localRotation;
|
||||
|
||||
transform.SetParent(ui.transform.parent, true);
|
||||
var pos = transform.localPosition;
|
||||
pos.z = 0;
|
||||
ps.transform.localPosition = pos;
|
||||
ps.transform.localRotation = localRotation;
|
||||
|
||||
// Destroy UI elemant
|
||||
Object.DestroyImmediate(ui);
|
||||
|
||||
// Assign default material.
|
||||
var renderer = ps.GetComponent<ParticleSystemRenderer>();
|
||||
var defaultMat = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Particle.mat");
|
||||
renderer.material = defaultMat ? defaultMat : renderer.material;
|
||||
|
||||
// Set to hierarchy mode
|
||||
var particleSystem = ps.GetComponent<ParticleSystem>();
|
||||
var main = particleSystem.main;
|
||||
main.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||
|
||||
// Add UIParticle.
|
||||
var uiParticle = ps.AddComponent<UIParticle>();
|
||||
uiParticle.ignoreCanvasScaler = true;
|
||||
uiParticle.scale = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
|
||||
|
||||
Reference in New Issue
Block a user