2023-06-16 09:25:07 -04:00
|
|
|
|
using System;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace TriInspector
|
2022-01-18 12:19:15 -05:00
|
|
|
|
{
|
|
|
|
|
public readonly struct TriValidationResult
|
|
|
|
|
{
|
|
|
|
|
public static TriValidationResult Valid => new TriValidationResult(true, null, TriMessageType.None);
|
|
|
|
|
|
2023-06-16 09:25:07 -04:00
|
|
|
|
public TriValidationResult(bool valid, string message, TriMessageType messageType,
|
|
|
|
|
Action fixAction = null, GUIContent fixActionContent = null)
|
2022-01-18 12:19:15 -05:00
|
|
|
|
{
|
|
|
|
|
IsValid = valid;
|
|
|
|
|
Message = message;
|
|
|
|
|
MessageType = messageType;
|
2023-06-16 09:25:07 -04:00
|
|
|
|
FixAction = fixAction;
|
|
|
|
|
FixActionContent = fixActionContent;
|
2022-01-18 12:19:15 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsValid { get; }
|
|
|
|
|
public string Message { get; }
|
|
|
|
|
public TriMessageType MessageType { get; }
|
2023-06-16 09:25:07 -04:00
|
|
|
|
public Action FixAction { get; }
|
|
|
|
|
public GUIContent FixActionContent { get; }
|
|
|
|
|
|
|
|
|
|
public TriValidationResult WithFix(Action action, string name = null)
|
|
|
|
|
{
|
2023-06-24 10:08:40 -04:00
|
|
|
|
return new TriValidationResult(IsValid, Message, MessageType, action, new GUIContent(name ?? "Fix"));
|
2023-06-16 09:25:07 -04:00
|
|
|
|
}
|
2022-01-18 12:19:15 -05:00
|
|
|
|
|
2023-04-05 13:14:35 -04:00
|
|
|
|
public static TriValidationResult Info(string error)
|
|
|
|
|
{
|
|
|
|
|
return new TriValidationResult(false, error, TriMessageType.Info);
|
|
|
|
|
}
|
2023-06-16 09:25:07 -04:00
|
|
|
|
|
2022-01-18 12:19:15 -05:00
|
|
|
|
public static TriValidationResult Error(string error)
|
|
|
|
|
{
|
|
|
|
|
return new TriValidationResult(false, error, TriMessageType.Error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static TriValidationResult Warning(string error)
|
|
|
|
|
{
|
|
|
|
|
return new TriValidationResult(false, error, TriMessageType.Warning);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum TriMessageType
|
|
|
|
|
{
|
|
|
|
|
None,
|
|
|
|
|
Info,
|
|
|
|
|
Warning,
|
|
|
|
|
Error,
|
|
|
|
|
}
|
|
|
|
|
}
|