You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-15 04:30:09 +00:00
# [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.
86 lines
2.3 KiB
C#
86 lines
2.3 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Coffee.UIExtensions
|
|
{
|
|
internal static class MeshHelper
|
|
{
|
|
private static CombineInstance[] s_CombineInstances;
|
|
private static int s_CurrentIndex;
|
|
static readonly List<Color32> s_Colors = new List<Color32>();
|
|
private static int s_RefCount;
|
|
|
|
public static void Register()
|
|
{
|
|
if (0 < s_RefCount++) return;
|
|
s_CombineInstances = new CombineInstance[2];
|
|
}
|
|
|
|
public static void Unregister()
|
|
{
|
|
s_RefCount--;
|
|
|
|
if (0 < s_RefCount || s_CombineInstances == null) return;
|
|
|
|
for (var i = 0; i < s_CombineInstances.Length; i++)
|
|
{
|
|
#if UNITY_EDITOR
|
|
if (!Application.isPlaying)
|
|
Object.DestroyImmediate(s_CombineInstances[i].mesh);
|
|
else
|
|
#endif
|
|
{
|
|
Object.Destroy(s_CombineInstances[i].mesh);
|
|
}
|
|
}
|
|
|
|
s_CombineInstances = null;
|
|
}
|
|
|
|
public static Mesh GetTemporaryMesh()
|
|
{
|
|
return s_CombineInstances[s_CurrentIndex++].mesh;
|
|
}
|
|
|
|
public static void Clear()
|
|
{
|
|
s_CurrentIndex = 0;
|
|
for (var i = 0; i < s_CombineInstances.Length; i++)
|
|
{
|
|
if (!s_CombineInstances[i].mesh)
|
|
{
|
|
var mesh = new Mesh();
|
|
mesh.MarkDynamic();
|
|
s_CombineInstances[i].mesh = mesh;
|
|
}
|
|
else
|
|
{
|
|
s_CombineInstances[i].mesh.Clear(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void CombineMesh(Mesh result, Matrix4x4 transform)
|
|
{
|
|
if (!result || s_CurrentIndex == 0) return;
|
|
|
|
for (var i = 0; i < 2; i++)
|
|
s_CombineInstances[i].transform = transform;
|
|
|
|
result.CombineMeshes(s_CombineInstances, false, true);
|
|
result.RecalculateBounds();
|
|
}
|
|
|
|
public static void ModifyColorSpaceToLinear(this Mesh self)
|
|
{
|
|
self.GetColors(s_Colors);
|
|
|
|
for (var i = 0; i < s_Colors.Count; i++)
|
|
s_Colors[i] = ((Color) s_Colors[i]).gamma;
|
|
|
|
self.SetColors(s_Colors);
|
|
s_Colors.Clear();
|
|
}
|
|
}
|
|
}
|