Compare commits

..

6 Commits

Author SHA1 Message Date
mob-sakai
0441238cc5 docs: update readme 2026-06-24 15:10:37 +09:00
mob-sakai
639bc9c342 fix: rename UIParticleProjectSettings.enableLinearToGamma to autoColorCorrection 2026-06-24 15:10:37 +09:00
mob-sakai
b3d42a2478 fix: UI/Additive shader does not support RectMask2D softness. 2026-06-24 15:10:37 +09:00
mob-sakai
418b257ae2 fix: there is a compilation error in Unity 2019.1 or earlier
close #407
2026-06-24 15:10:36 +09:00
mob-sakai
664c7963ea chore: update internal 2026-06-24 15:10:36 +09:00
mob-sakai
7363f7497c feat: preview the ParticleSystem playback when selecting a UIParticle in the Editor 2026-06-24 15:10:36 +09:00
8 changed files with 35 additions and 86 deletions

View File

@@ -49,6 +49,7 @@ namespace Coffee.UIExtensions
private static readonly GUIContent s_ContentRandom = new GUIContent("Random");
private static readonly GUIContent s_ContentScale = new GUIContent("Scale");
private static readonly GUIContent s_ContentPrimary = new GUIContent("Primary");
private static readonly GUIContent s_Remove = new GUIContent("Remove");
private static readonly Regex s_RegexBuiltInGuid = new Regex(@"^0{16}.0{15}$", RegexOptions.Compiled);
private static readonly List<Material> s_TempMaterials = new List<Material>();
@@ -82,18 +83,6 @@ namespace Coffee.UIExtensions
"_ColorMask"
};
/// <summary>
/// ドメインリロード無効化対応:静的キャッシュをクリア
/// </summary>
[InitializeOnLoadMethod]
private static void OnDomainReload()
{
s_Shaders.Clear();
#if UNITY_2018 || UNITY_2019
s_Streams.Clear();
#endif
}
//################################
// Public/Protected Members.
//################################

View File

@@ -195,13 +195,6 @@ namespace Coffee.UIParticleInternal
private static T s_Instance;
#if UNITY_EDITOR
#if UNITY_2019_3_OR_NEWER
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnDomainReload()
{
s_Instance = null;
}
#endif
private string _jsonText;
public static bool hasInstance => s_Instance != null;

View File

@@ -14,7 +14,7 @@ namespace Coffee.UIParticleInternal
UIExtraCallbacks.onLateAfterCanvasRebuild += ClearAllCache;
}
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
#if UNITY_EDITOR && UNITY_2019_2_OR_NEWER
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void Clear()
{

View File

@@ -15,7 +15,7 @@ namespace Coffee.UIParticleInternal
public static Func<string, Shader> onShaderFind = Shader.Find;
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
#if UNITY_EDITOR && UNITY_2019_2_OR_NEWER
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
public static void Clear()
{

View File

@@ -82,22 +82,14 @@ namespace Coffee.UIParticleInternal
message: "InitializeAfterCanvasRebuild");
}
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
#elif UNITY_EDITOR
#if UNITY_EDITOR
[InitializeOnLoadMethod]
#else
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
#endif
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void InitializeOnLoad()
{
Canvas.willRenderCanvases -= OnAfterCanvasRebuild;
s_IsInitializedAfterCanvasRebuild = false;
s_AfterCanvasRebuildAction.Clear();
s_LateAfterCanvasRebuildAction.Clear();
s_BeforeCanvasRebuildAction.Clear();
s_OnScreenSizeChangedAction.Clear();
s_LastScreenSize = default;
}
/// <summary>

View File

@@ -24,6 +24,7 @@ namespace Coffee.UIExtensions
{
_gameObjects = targets.OfType<ParticleSystemPreviewer>().Select(x => x.gameObject).ToArray();
ParticleSystemPreviewSystem.Register(_gameObjects);
}
public override void OnInspectorGUI()
@@ -46,19 +47,6 @@ namespace Coffee.UIExtensions
[SerializeField]
private List<GameObject> m_PreviewObjects = new List<GameObject>();
#if UNITY_2019_3_OR_NEWER
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
#else
[InitializeOnLoadMethod]
#endif
public static void Initialize()
{
instance.OnSelectionChanged();
Selection.selectionChanged -= instance.OnSelectionChanged;
Selection.selectionChanged += instance.OnSelectionChanged;
}
/// <summary>
/// Adds a temporary ParticleSystem to the specified GameObject for preview purposes.
/// </summary>
@@ -78,18 +66,25 @@ namespace Coffee.UIExtensions
if (!target) return;
if (EditorApplication.isPlaying) return;
if (instance.m_PreviewObjects.Contains(target)) return;
if (target.TryGetComponent<ParticleSystem>(out var ps))
{
if (ps.hideFlags == k_TemporaryHideFlags)
{
RegisterParticleSystem(ps);
}
return;
}
if (target.TryGetComponent<ParticleSystem>(out var _)) return;
// Create temporary ParticleSystem for preview.
RegisterParticleSystem(target.AddComponent<ParticleSystem>());
var ps = target.AddComponent<ParticleSystem>();
ps.hideFlags = k_TemporaryHideFlags;
var emission = ps.emission;
emission.enabled = false;
var shape = ps.shape;
shape.enabled = false;
if (target.TryGetComponent<ParticleSystemRenderer>(out var psr))
{
psr.enabled = false;
psr.hideFlags = k_TemporaryHideFlags;
}
instance.m_PreviewObjects.Add(target);
EditorUtility.SetDirty(target);
}
/// <summary>
@@ -110,26 +105,6 @@ namespace Coffee.UIExtensions
}
}
private static void RegisterParticleSystem(ParticleSystem ps)
{
if (!ps) return;
ps.hideFlags = k_TemporaryHideFlags;
var emission = ps.emission;
emission.enabled = false;
var shape = ps.shape;
shape.enabled = false;
if (ps.TryGetComponent<ParticleSystemRenderer>(out var psr))
{
psr.enabled = false;
psr.hideFlags = k_TemporaryHideFlags;
}
instance.m_PreviewObjects.Add(ps.gameObject);
EditorUtility.SetDirty(ps.gameObject);
}
/// <summary>
/// Removes the temporary ParticleSystem associated with the specified GameObject.
/// </summary>
@@ -170,6 +145,17 @@ namespace Coffee.UIExtensions
&& ps.hideFlags != k_TemporaryHideFlags;
}
private void OnEnable()
{
Selection.selectionChanged -= OnSelectionChanged;
Selection.selectionChanged += OnSelectionChanged;
}
private void OnDisable()
{
Selection.selectionChanged -= OnSelectionChanged;
}
private void OnSelectionChanged()
{
var selectedGameObjects = Selection.gameObjects;

View File

@@ -546,7 +546,7 @@ namespace Coffee.UIExtensions
var ps = particles[i];
if (!ps
#if UNITY_EDITOR
|| (ps.hideFlags & HideFlags.DontSave) != 0 // Dummy ParticleSystems for preview.
|| ps.hideFlags == HideFlags.HideAndDontSave // Dummy ParticleSystems for preview.
|| ps.gameObject.CompareTag("EditorOnly") // Ignore "EditorOnly" tagged ParticleSystems.
#endif
|| ps.GetComponentInParent<UIParticle>(true) != this) // Ignore ParticleSystems that are not under this UIParticle.

View File

@@ -39,17 +39,6 @@ namespace Coffee.UIExtensions
}
#if UNITY_EDITOR
#if UNITY_2019_3_OR_NEWER
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnDomainReload()
{
s_ActiveParticles.Clear();
s_ActiveAttractors.Clear();
s_UpdatedGroupIds.Clear();
s_FrameCount = 0;
}
#endif
[InitializeOnLoadMethod]
private static void InitializeOnLoad()
{