32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using System.Linq;
|
|
using Sirenix.OdinInspector.Editor.Validation;
|
|
using UnityEngine;
|
|
using VOID.Editor.AttributeValidator;
|
|
using VOID.Generic;
|
|
using VOID.Generic.Triggers;
|
|
|
|
[assembly: RegisterValidator(typeof(HideCeilingTriggerValidator))]
|
|
|
|
namespace VOID.Editor.AttributeValidator
|
|
{
|
|
public class HideCeilingTriggerValidator : ValueValidator<HideCeilingTrigger>
|
|
{
|
|
protected override void Validate(ValidationResult result)
|
|
{
|
|
if (Value == null) return;
|
|
|
|
ValidateHideableLayer(result);
|
|
}
|
|
|
|
private void ValidateHideableLayer(ValidationResult result)
|
|
{
|
|
var isWrongLayer = Value.gameObjectsToHide.SelectMany(go => go.GetComponentsInChildren<Transform>())
|
|
.Select(transform => transform.gameObject.layer)
|
|
.Any(layer => layer != LayerManager.StaticHideableIndex);
|
|
|
|
if (!isWrongLayer) return;
|
|
|
|
result.AddError($"All hideable objects targeted by this components needs layer <u>{nameof(LayerManager.StaticHideable)}</u>");
|
|
}
|
|
}
|
|
} |