| 36 | } |
| 37 | |
| 38 | bool BinaryAsset::Init(const FlaxStorageReference& storage, AssetHeader& header) |
| 39 | { |
| 40 | // We allow to init asset only once like that |
| 41 | ASSERT(Storage == nullptr && _header.ID.IsValid() == false); |
| 42 | |
| 43 | // Block initialization with a different storage |
| 44 | bool isChanged = _storageRef != storage; |
| 45 | if (Storage != nullptr && isChanged) |
| 46 | { |
| 47 | LOG(Error, "Asset \'{0}\' has been already initialized.", GetPath()); |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | // Get data |
| 52 | _storageRef = storage; |
| 53 | Storage = storage.Get(); |
| 54 | _header = header; |
| 55 | |
| 56 | #if USE_EDITOR |
| 57 | // Link for storage reload event |
| 58 | if (Storage && isChanged) |
| 59 | Storage->OnReloaded.Bind<BinaryAsset, &BinaryAsset::OnStorageReloaded>(this); |
| 60 | #endif |
| 61 | |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | bool BinaryAsset::Init(AssetInitData& initData) |
| 66 | { |