| 637 | } |
| 638 | |
| 639 | void GuiInspectorTypeMaterialAssetPtr::setPreviewImage(StringTableEntry assetId) |
| 640 | { |
| 641 | //if what we're working with isn't even a valid asset, don't present like we found a good one |
| 642 | if (!AssetDatabase.isDeclaredAsset(assetId)) |
| 643 | { |
| 644 | mPreviewImage->_setBitmap(StringTable->EmptyString()); |
| 645 | return; |
| 646 | } |
| 647 | |
| 648 | String matPreviewAssetId = String(assetId) + "_PreviewImage"; |
| 649 | matPreviewAssetId.replace(":", "_"); |
| 650 | matPreviewAssetId = "ToolsModule:" + matPreviewAssetId; |
| 651 | if (AssetDatabase.isDeclaredAsset(matPreviewAssetId.c_str())) |
| 652 | { |
| 653 | mPreviewImage->setBitmap(StringTable->insert(matPreviewAssetId.c_str())); |
| 654 | } |
| 655 | else |
| 656 | { |
| 657 | if (AssetDatabase.isDeclaredAsset(assetId)) |
| 658 | { |
| 659 | MaterialAsset* matAsset = AssetDatabase.acquireAsset<MaterialAsset>(assetId); |
| 660 | if (matAsset && matAsset->getMaterialDefinition()) |
| 661 | { |
| 662 | mPreviewImage->_setBitmap(matAsset->getMaterialDefinition()->mDiffuseMapAssetId[0]); |
| 663 | } |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | if (mPreviewImage->getBitmapAsset().isNull()) |
| 668 | mPreviewImage->_setBitmap(StringTable->insert("ToolsModule:genericAssetIcon_image")); |
| 669 | } |
| 670 | |
| 671 | IMPLEMENT_CONOBJECT(GuiInspectorTypeMaterialAssetId); |
| 672 |
nothing calls this directly
no test coverage detected