init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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>");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user