示例#1
0
        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)
                {
                    DispatchVLogEvent(obj, VLogType.Error, string.Format("Field [{0}] on Object [{1}] is null when it should be a" +
                                                                         " reference to a scene object", field, obj.name));
                    isValidated = false;
                    continue;
                }

                if (!field.FieldType.IsSubclassOf(typeof(Object)) && field.FieldType != typeof(Object))
                {
                    DispatchVLogEvent(obj, VLogType.Warning, string.Format("Field [{0}] on Object [{1}] should not have a VIsSceneReference " +
                                                                           "attribute as it does not derive from UnityEngine.Object", field, obj.name));
                    continue;
                }

                var unityObject = value as Object;
                if (ObjectUtility.IsProjectReference(unityObject))
                {
                    DispatchVLogEvent(obj, VLogType.Error, string.Format("Field [{0}] on Object [{1}] does not refer to a scene asset " +
                                                                         "when it should", field, obj.name));
                    isValidated = false;
                }
            }

            return(isValidated);
        }