type | 一种类型。 |
bool 如果该类型可以在文件中持久保存,则为 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。