From eaae94ce0081743594e6325992b1154bd1022b48 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Sun, 26 Nov 2023 17:15:26 +0900 Subject: [PATCH] fix: fix warning --- Scripts/Editor/UIParticleEditor.cs | 21 ++++++++++++++++----- Scripts/UIParticleRenderer.cs | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Scripts/Editor/UIParticleEditor.cs b/Scripts/Editor/UIParticleEditor.cs index 1695bb1..3ba75f0 100644 --- a/Scripts/Editor/UIParticleEditor.cs +++ b/Scripts/Editor/UIParticleEditor.cs @@ -43,7 +43,7 @@ namespace Coffee.UIExtensions { if (visible) { - WindowFunction(null, null); + WindowFunction(); } } } @@ -75,8 +75,9 @@ namespace Coffee.UIExtensions private bool _showMax; private static readonly HashSet s_Shaders = new HashSet(); +#if UNITY_2018 || UNITY_2019 private static readonly List s_Streams = new List(); - +#endif private static readonly List s_MaskablePropertyNames = new List { "_Stencil", @@ -128,6 +129,7 @@ namespace Coffee.UIExtensions .Concat(Selection.gameObjects.Select(x => x.GetComponent()) .Where(x => x && x.canvas)) .Distinct() + .OfType() .ToArray(); return 0 < uiParticles.Length ? new SerializedObject(uiParticles) : null; } @@ -332,6 +334,8 @@ namespace Coffee.UIExtensions DestroyUIParticle(current); } +#if UNITY_2018 || UNITY_2019 + // (2018, 2019) Check to use 'TEXCOORD*.zw' components as custom vertex stream. var allPsRenderers = targets.OfType() .SelectMany(x => x.particles) .Where(x => x) @@ -357,6 +361,7 @@ namespace Coffee.UIExtensions s_Streams.Clear(); } } +#endif } private bool IsBuiltInObject(Object obj) @@ -365,6 +370,7 @@ namespace Coffee.UIExtensions && Regex.IsMatch(guid, "^0{16}.0{15}$", RegexOptions.Compiled); } +#if UNITY_2018 || UNITY_2019 private static int GetUsedComponentCount(ParticleSystemVertexStream s) { switch (s) @@ -423,6 +429,7 @@ namespace Coffee.UIExtensions return 3; } +#endif private static bool DrawMeshSharing(SerializedProperty spMeshSharing, SerializedProperty spGroupId, SerializedProperty spGroupMaxId, bool showMax) @@ -482,12 +489,16 @@ namespace Coffee.UIExtensions }; } - private static void WindowFunction(Object target, SceneView sceneView) +#if UNITY_2021_2_OR_NEWER + private static void WindowFunction() +#else + private static void WindowFunction(Object _, SceneView __) +#endif { try { if (s_SerializedObject == null || !s_SerializedObject.targetObject) return; - var uiParticles = s_SerializedObject.targetObjects.OfType(); + var uiParticles = s_SerializedObject.targetObjects.OfType().ToArray(); if (uiParticles.Any(x => !x || !x.canvas)) return; s_SerializedObject.Update(); @@ -523,7 +534,7 @@ namespace Coffee.UIExtensions if (stage != null && stage.scene.isLoaded) { #if UNITY_2020_1_OR_NEWER - string prefabAssetPath = stage.assetPath; + var prefabAssetPath = stage.assetPath; #else var prefabAssetPath = stage.prefabAssetPath; #endif diff --git a/Scripts/UIParticleRenderer.cs b/Scripts/UIParticleRenderer.cs index 5df30f7..0f213d4 100644 --- a/Scripts/UIParticleRenderer.cs +++ b/Scripts/UIParticleRenderer.cs @@ -1,4 +1,10 @@ -using System; +#if UNITY_2022_3_0 || UNITY_2022_3_1 || UNITY_2022_3_2 || UNITY_2022_3_3 || UNITY_2022_3_4 || UNITY_2022_3_5 || UNITY_2022_3_6 || UNITY_2022_3_7 || UNITY_2022_3_8 || UNITY_2022_3_9 || UNITY_2022_3_10 +#elif UNITY_2023_1_0 || UNITY_2023_1_1 || UNITY_2023_1_2 || UNITY_2023_1_3 || UNITY_2023_1_4 || UNITY_2023_1_5 || UNITY_2023_1_6 || UNITY_2023_1_7 || UNITY_2023_1_8 || UNITY_2023_1_9 +#elif UNITY_2023_1_10 || UNITY_2023_1_11 || UNITY_2023_1_12 || UNITY_2023_1_13 || UNITY_2023_1_14 || UNITY_2023_1_15 || UNITY_2023_1_16 +#elif UNITY_2022_3_OR_NEWER +#define PS_BAKE_API_V2 +#endif +using System; using System.Collections.Generic; using Coffee.UIParticleExtensions; using UnityEditor; @@ -333,11 +339,19 @@ namespace Coffee.UIExtensions Profiler.BeginSample("[UIParticleRenderer] Bake Mesh"); if (_isTrail && _parent.canSimulate && 0 < s_CombineInstances[0].mesh.vertexCount) { +#if PS_BAKE_API_V2 + _renderer.BakeTrailsMesh(s_CombineInstances[0].mesh, bakeCamera, ParticleSystemBakeMeshOptions.BakeRotationAndScale); +#else _renderer.BakeTrailsMesh(s_CombineInstances[0].mesh, bakeCamera, true); +#endif } else if (_renderer.CanBakeMesh()) { +#if PS_BAKE_API_V2 + _renderer.BakeMesh(s_CombineInstances[0].mesh, bakeCamera, ParticleSystemBakeMeshOptions.BakeRotationAndScale); +#else _renderer.BakeMesh(s_CombineInstances[0].mesh, bakeCamera, true); +#endif } else {