PropertyDatabase.IsPersistableType
Declaration
public static bool IsPersistableType(Type type);Параметры
| Параметр | Описание |
|---|---|
| тип | Тип. |
Возвращаемое значение
логическое True, если тип может быть сохранен в файле, false в противном случае.
Описание
Возвращает логическое значение, указывающее, может ли тип быть сохранен в резервном файле.
Только некоторые типы могут быть сохранены в резервном файле, чтобы выжить после перезагрузки домена и выхода из Unity. Однако любой тип может быть сохранен без резервирования в PropertyDatabase. Вы всегда можете разложить свои пользовательские объекты на меньшие свойства, которые могут быть сохранены, если вам абсолютно нужна постоянство.
// Any object can be stored in the property database, but only // some of them will be persisted in the database file. All others // will disappear after the current Unity session. If you absolutely need your // data to be persisted, you can decompose your it into smaller properties that can // be serialized. var customTypeValue = new MyCustomType(42, "myValue"); if (PropertyDatabase.IsPersistableType(typeof(MyCustomType))) { stored = propertyDatabase.Store("path/to/my/asset", "m_customTypeValue", customTypeValue); if (!stored) Debug.LogWarning("Property m_customTypeValue did not store."); } else { stored = propertyDatabase.Store("path/to/my/asset", "m_customTypeValue.value", customTypeValue.value); if (!stored) Debug.LogWarning("Property m_customTypeValue.value did not store."); stored = propertyDatabase.Store("path/to/my/asset", "m_customTypeValue.name", customTypeValue.name); if (!stored) Debug.LogWarning("Property m_customTypeValue.name did not store."); }
Дополнительные ресурсы: ,PropertyDatabaseType,.