/// <summary> /// Dispatches a <see cref="ValidationLog"/> instance via <see cref="LogCreated"/>. /// </summary> /// <param name="obj"></param> /// <param name="type"></param> /// <param name="message"></param> protected void DispatchLogEvent(Object obj, LogType type, string message) { LogCreated?.Invoke(new ValidationLog { logType = type, validatorName = TypeName, message = message, objectPath = ObjectTools.GetObjectPath(obj) }); }
/// <summary> /// Dispatches a <see cref="ValidationLog"/> instance via <see cref="LogCreated"/>. /// </summary> /// <param name="obj"></param> /// <param name="type"></param> /// <param name="message"></param> /// <param name="scenePath"></param> /// <param name="source"></param> protected ValidationLog CreateVLog(Object obj, LogType type, string message, string scenePath, LogSource source) { return(new ValidationLog { logType = type, source = source, validatorName = TypeName, message = message, objectPath = ObjectTools.GetObjectPath(obj), scenePath = scenePath }); }
protected void DispatchVLogEvent(Object obj, LogType type, string message, string scenePath = "", LogSource source = LogSource.Scene) { LogCreated?.Invoke(new ValidationLog { logType = type, source = source, validatorName = TypeName, message = message, objectPath = ObjectTools.GetObjectPath(obj), scenePath = scenePath }); }
/// <summary> /// Dispatches a <see cref="ValidationLog"/> instance via <see cref="LogCreated"/>. /// </summary> /// <param name="obj"></param> /// <param name="type"></param> /// <param name="message"></param> /// <param name="scenePath"></param> /// <param name="objectPath"></param> protected void DispatchLogEvent( Object obj, LogType type, string message, string scenePath, string objectPath) { LogCreated?.Invoke(new ValidationLog { logType = type, source = LogSource.Project, validatorName = TypeName, message = message, objectPath = string.IsNullOrEmpty(objectPath) ? ObjectTools.GetObjectPath(obj) : objectPath, scenePath = scenePath }); }
public override bool Validate(Object obj) { var isValidated = true; var fields = GetFieldInfosApplyTo(obj); foreach (var field in fields) { var value = field.GetValue(obj); if (value == null) { DispatchLogEvent( obj, LogType.Error, string.Format(NullWarningFormat, field, obj.name)); isValidated = false; continue; } var unityObject = value as Object; if (unityObject == null) { DispatchLogEvent( obj, LogType.Warning, string.Format(InvalidTypeWarningFormat, field, obj.name)); continue; } if (!ObjectTools.IsProjectReference(unityObject)) { DispatchLogEvent( obj, LogType.Error, string.Format( NotProjectReferenceWarningFormat, field, obj.name)); isValidated = false; } } return(isValidated); }
public override bool Validate(Object obj) { var isValidated = true; var fields = GetFieldInfosApplyTo(obj); foreach (var field in fields) { var objValue = field.GetValue(obj); // If the field's type is a UnityEngine.Object derived type, cast it as such and check to see // if it is null. If not, continue. if (field.FieldType.IsSubclassOf(typeof(Object))) { var unityObjValue = objValue as Object; if (!ObjectTools.IsNullReference(unityObjValue)) { continue; } } // Otherwise if it is not a UnityEngine.Object type, simple check for null and continue // if it has a value. else if (objValue != null) { continue; } DispatchLogEvent( obj, LogType.Error, string.Format(NullWarningFormat, obj.name, field.Name)); isValidated = false; } return(isValidated); }