| 599 | } |
| 600 | |
| 601 | void GuiInspectorTypeMaterialAssetPtr::updatePreviewImage() |
| 602 | { |
| 603 | const char* previewImage; |
| 604 | if (mInspector->getInspectObject() != nullptr) |
| 605 | previewImage = mInspector->getInspectObject()->getDataField(mCaption, NULL); |
| 606 | else |
| 607 | previewImage = Con::getVariable(mVariableName); |
| 608 | |
| 609 | //if what we're working with isn't even a valid asset, don't present like we found a good one |
| 610 | if (!AssetDatabase.isDeclaredAsset(previewImage)) |
| 611 | { |
| 612 | mPreviewImage->_setBitmap(StringTable->EmptyString()); |
| 613 | return; |
| 614 | } |
| 615 | |
| 616 | String matPreviewAssetId = String(previewImage) + "_PreviewImage"; |
| 617 | matPreviewAssetId.replace(":", "_"); |
| 618 | matPreviewAssetId = "ToolsModule:" + matPreviewAssetId; |
| 619 | if (AssetDatabase.isDeclaredAsset(matPreviewAssetId.c_str())) |
| 620 | { |
| 621 | mPreviewImage->setBitmap(StringTable->insert(matPreviewAssetId.c_str())); |
| 622 | } |
| 623 | else |
| 624 | { |
| 625 | if (AssetDatabase.isDeclaredAsset(previewImage)) |
| 626 | { |
| 627 | MaterialAsset* matAsset = AssetDatabase.acquireAsset<MaterialAsset>(previewImage); |
| 628 | if (matAsset && matAsset->getMaterialDefinition()) |
| 629 | { |
| 630 | mPreviewImage->_setBitmap(matAsset->getMaterialDefinition()->mDiffuseMapAssetId[0]); |
| 631 | } |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | if (mPreviewImage->getBitmapAsset().isNull()) |
| 636 | mPreviewImage->_setBitmap(StringTable->insert("ToolsModule:genericAssetIcon_image")); |
| 637 | } |
| 638 | |
| 639 | void GuiInspectorTypeMaterialAssetPtr::setPreviewImage(StringTableEntry assetId) |
| 640 | { |
nothing calls this directly
no test coverage detected