feat: explicit null checks

This commit is contained in:
mob-sakai
2026-03-24 17:32:31 +09:00
parent 04c1ca72cd
commit 319ab5fe06
15 changed files with 98 additions and 80 deletions

View File

@@ -76,7 +76,7 @@ namespace Coffee.UIExtensions
for (var j = 0; j < mats.Count; j++)
{
var mat = mats[j];
if (!mat || !mat.shader) continue;
if (mat == null || mat.shader == null) continue;
for (var i = 0; i < ShaderUtil.GetPropertyCount(mat.shader); i++)
{

View File

@@ -110,7 +110,7 @@ namespace Coffee.UIExtensions
{
var ps = sp.GetArrayElementAtIndex(index).objectReferenceValue as ParticleSystem;
var materialCount = 0;
if (ps && ps.TryGetComponent<ParticleSystemRenderer>(out var psr))
if (ps != null && ps.TryGetComponent<ParticleSystemRenderer>(out var psr))
{
materialCount = psr.sharedMaterials.Length;
}
@@ -124,7 +124,7 @@ namespace Coffee.UIExtensions
var p = sp.GetArrayElementAtIndex(index);
EditorGUI.ObjectField(rect, p, GUIContent.none);
var ps = p.objectReferenceValue as ParticleSystem;
if (!ps || !ps.TryGetComponent<ParticleSystemRenderer>(out var psr)) return;
if (ps == null || !ps.TryGetComponent<ParticleSystemRenderer>(out var psr)) return;
rect.x += 15;
rect.width -= 15;
@@ -191,7 +191,7 @@ namespace Coffee.UIExtensions
public override void OnInspectorGUI()
{
var current = target as UIParticle;
if (!current) return;
if (current == null) return;
Profiler.BeginSample("(UIP:E) OnInspectorGUI");
serializedObject.Update();
@@ -267,7 +267,7 @@ namespace Coffee.UIExtensions
Profiler.BeginSample("(UIP:E) Non-UI built-in shader is not supported.");
foreach (var mat in s_TempMaterials)
{
if (!mat || !mat.shader) continue;
if (mat == null || mat.shader == null) continue;
var shader = mat.shader;
if (IsBuiltInObject(shader) && !shader.name.StartsWith("UI/"))
{
@@ -286,7 +286,7 @@ namespace Coffee.UIExtensions
{
foreach (var mat in s_TempMaterials)
{
if (!mat || !mat.shader) continue;
if (mat == null || mat.shader == null) continue;
var shader = mat.shader;
if (!s_Shaders.Add(shader)) continue;