Hot Fix - confused casting Items types
This commit is contained in:
parent
cc9c34930f
commit
25fedfae64
@ -38,9 +38,22 @@ public class EquippableItemPrefabAssetData : PrefabAssetModelData
|
|||||||
new Vector3(Position[0], Position[1], Position[2])
|
new Vector3(Position[0], Position[1], Position[2])
|
||||||
);
|
);
|
||||||
|
|
||||||
equippableItemPrefabAsset.EquippableItem = new EquippableItem(
|
// if we forcefully cast on EquippableItem by creating new clss variable - we lost data about Type
|
||||||
EquippableItemData.MapDataToObject(equippableItemPrefabAsset.PrefabAssetName)
|
// because constructo think we pass Item not EquippableItem (because MapDataToObject return Item type)
|
||||||
);
|
var item = EquippableItemData.MapDataToObject(equippableItemPrefabAsset.PrefabAssetName) as EquippableItem;
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
// successfully cast - it was oryginally EquippableItem
|
||||||
|
equippableItemPrefabAsset.EquippableItem = item;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// cast failed - it never were EquippableItem it plain Item
|
||||||
|
equippableItemPrefabAsset.EquippableItem = new EquippableItem(
|
||||||
|
EquippableItemData.MapDataToObject(equippableItemPrefabAsset.PrefabAssetName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return equippableItemPrefabAsset;
|
return equippableItemPrefabAsset;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user