- Validator: Added option to enable/disable certain validators - Project Settings: Fixed issue, where changes weren't always saved - Unity: Removed deprecated warnings in Unity 6.4
28 lines
No EOL
1.2 KiB
C#
28 lines
No EOL
1.2 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Module.ProjectValidator.Editor
|
|
{
|
|
internal sealed class GameObjectValidatorTransform : IGameObjectValidator
|
|
{
|
|
public void Validate(GameObject gameObject, List<ValidatorResult> results)
|
|
{
|
|
var transform = gameObject.transform;
|
|
var lp = transform.localPosition;
|
|
var lr = transform.localRotation;
|
|
var ls = transform.localScale;
|
|
|
|
if (IsInvalid(lp.x) || IsInvalid(lp.y) || IsInvalid(lp.z))
|
|
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, $"Local position '{lp}' is invalid"));
|
|
if (IsInvalid(lr.x) || IsInvalid(lr.y) || IsInvalid(lr.z) || IsInvalid(lr.w))
|
|
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, $"Local rotation '{lr}' is invalid"));
|
|
if (IsInvalid(ls.x) || IsInvalid(ls.y) || IsInvalid(ls.z))
|
|
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, $"Local scale '{ls}' is invalid"));
|
|
}
|
|
|
|
private static bool IsInvalid(float value)
|
|
{
|
|
return float.IsNaN(value) || float.IsInfinity(value);
|
|
}
|
|
}
|
|
} |