IsSerializedByUnity() public static method

Returns true if the given type can be serialized by Unity. This function is conservative and may not return true if the type can be serialized by unity. However, it will *not* return true if the type cannot be serialized by unity.
public static IsSerializedByUnity ( InspectedProperty property ) : bool
property InspectedProperty
return bool
コード例 #1
0
 public bool IsInterested(InspectedProperty property)
 {
     return
         (property.CanWrite &&
          InspectedType.IsSerializedByFullInspector(property) &&
          InspectedType.IsSerializedByUnity(property) == false);
 }
コード例 #2
0
        /// <summary>
        /// Returns true if the given property should be displayed in the inspector. This method
        /// assumes that the property type is inspectable.
        /// </summary>
        private static bool ShouldDisplayProperty(InspectedProperty property)
        {
            var memberInfo = property.MemberInfo;

            // note: we do opt-out before opt-in so that we can still serialize
            //       a field but not display it in the inspector (as the serialize
            //       annotations automatically cause a field to be displayed)
            if (memberInfo.IsDefined(typeof(HideInInspector), /*inherit:*/ true) ||
                memberInfo.IsDefined(typeof(NotSerializedAttribute), /*inherit:*/ true) ||
                fiInstalledSerializerManager.SerializationOptOutAnnotations.Any(t => memberInfo.IsDefined(t, /*inherit*/ true)))
            {
                return(false);
            }

            if (memberInfo.IsDefined(typeof(ShowInInspectorAttribute), /*inherit:*/ true) ||
                (property.IsStatic == false && fiInstalledSerializerManager.SerializationOptInAnnotations.Any(t => memberInfo.IsDefined(t, /*inherit*/ true))))
            {
                return(true);
            }

            if (property.MemberInfo is PropertyInfo && fiSettings.InspectorRequireShowInInspector)
            {
                return(false);
            }

            return
                (InspectedType.IsSerializedByFullInspector(property) ||
                 InspectedType.IsSerializedByUnity(property));
        }
コード例 #3
0
        /// <summary>
        /// Returns true if the given property should be displayed in the
        /// inspector. This method assumes that the property type is inspectable.
        /// </summary>
        private static bool ShouldDisplayProperty(InspectedProperty property)
        {
            var memberInfo = property.MemberInfo;

            // If ShowInInspector is present, we will *always* display the
            // attribute.
            if (memberInfo.IsDefined(typeof(ShowInInspectorAttribute), /*inherit:*/ true))
            {
                return(true);
            }

            // note: we do opt-out serialization annotations before opt-in
            //       annotations so that we can still serialize a field but not
            //       display it in the inspector (as the serialize annotations
            //       automatically cause a field to be displayed)
            if (memberInfo.IsDefined(typeof(HideInInspector), /*inherit:*/ true) ||
                memberInfo.IsDefined(typeof(NotSerializedAttribute), /*inherit:*/ true) ||
                fiInstalledSerializerManager.SerializationOptOutAnnotations.Any(t => memberInfo.IsDefined(t, /*inherit*/ true)))
            {
                return(false);
            }

            // Show the property if any of the opt-in annotations are present.
            if (property.IsStatic == false &&
                fiInstalledSerializerManager.SerializationOptInAnnotations.Any(t => memberInfo.IsDefined(t, /*inherit*/ true)))
            {
                return(true);
            }

            if (property.MemberInfo is PropertyInfo && fiSettings.InspectorRequireShowInInspector)
            {
                return(false);
            }

            return
                // IsSerializedByFullInspector will return false for BaseObject
                // types, so we want to special case support for them being
                // inspected.
                (typeof(BaseObject).Resolve().IsAssignableFrom(property.StorageType.Resolve()) ||
                 InspectedType.IsSerializedByFullInspector(property) ||
                 InspectedType.IsSerializedByUnity(property));
        }