IsScriptableObject() private static method

private static IsScriptableObject ( Mono.Cecil.TypeDefinition temp ) : bool
temp Mono.Cecil.TypeDefinition
return bool
Exemplo n.º 1
0
        public static bool ShouldImplementIDeserializable(TypeReference typeDeclaration)
        {
            if (typeDeclaration.FullName == "UnityEngine.ExposedReference`1")
            {
                return(true);
            }

            if (IsNonSerialized(typeDeclaration))
            {
                return(false);
            }

            var genericInstance = typeDeclaration as GenericInstanceType;

            if (genericInstance != null)
            {
                if (genericInstance.ElementType.FullName == "UnityEngine.ExposedReference`1")
                {
                    return(true);
                }

                return(false);
            }

            try
            {
                return(UnityEngineTypePredicates.IsMonoBehaviour(typeDeclaration) ||
                       UnityEngineTypePredicates.IsScriptableObject(typeDeclaration) ||
                       (typeDeclaration.CheckedResolve().IsSerializable&& !typeDeclaration.CheckedResolve().IsAbstract&& !typeDeclaration.CheckedResolve().CustomAttributes.Any(a => a.AttributeType.FullName.Contains("System.Runtime.CompilerServices.CompilerGenerated"))) ||
                       UnityEngineTypePredicates.ShouldHaveHadSerializableAttribute(typeDeclaration));
            }
            catch (Exception)
            {
                return(false);
            }
        }
 public static bool IsScriptableObject(TypeReference type)
 {
     return(UnityEngineTypePredicates.IsScriptableObject(type.CheckedResolve()));
 }