mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 00:05:40 +00:00
Added utility methods to AssetBase:
getAssetDependencyFieldCount clearAssetDependencyFields addAssetDependencyField saveAsset Updated the saveAsset function for terrain block to utilize utility methods to ensure the terrain asset's material dependencies, so they will load properly.
This commit is contained in:
parent
906c7095f1
commit
d8cc73f5a1
6 changed files with 120 additions and 100 deletions
Binary file not shown.
|
|
@ -83,45 +83,4 @@ function GuiInspectorTypeTerrainAssetPtr::onClick( %this, %fieldName )
|
|||
function GuiInspectorTypeTerrainAssetPtr::onControlDropped( %this, %payload, %position )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//AssetDatabase.acquireAsset("pbr:NewTerrain");
|
||||
function TerrainAsset::saveAsset(%this)
|
||||
{
|
||||
%matDepIdx = 0;
|
||||
while(%this.getFieldValue("terrainMaterialAsset", %matDepIdx) !$= "")
|
||||
{
|
||||
%this.setFieldValue("terrainMaterialAsset", "", %matDepIdx);
|
||||
}
|
||||
|
||||
%filePath = AssetDatabase.getAssetFilePath(%this.getAssetId());
|
||||
|
||||
%mats = ETerrainEditor.getMaterials();
|
||||
|
||||
%assetQuery = new AssetQuery();
|
||||
AssetDatabase.findAssetType(%assetQuery, "TerrainMaterialAsset");
|
||||
|
||||
%count = %assetQuery.getCount();
|
||||
|
||||
%matDepIdx = 0;
|
||||
for( %i = 0; %i < getRecordCount( %mats ); %i++ )
|
||||
{
|
||||
%matInternalName = getRecord( %mats, %i );
|
||||
|
||||
for(%m=0; %m < %count; %m++)
|
||||
{
|
||||
%assetId = %assetQuery.getAsset(%m);
|
||||
|
||||
%terrMatAssetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
|
||||
if(%terrMatAssetDef.materialDefinitionName $= %matInternalName)
|
||||
{
|
||||
%this.setFieldValue("terrainMaterialAsset", "@Asset=" @ %assetId, %matDepIdx);
|
||||
%matDepIdx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
%assetQuery.delete();
|
||||
|
||||
TAMLWrite(%this, %filePath);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue