using UnityEditor;
using UnityEngine;
[System.Serializable]
public class EquippableItemPrefabAsset : PrefabAssetModel
{
[SerializeField]
public EquippableItem EquippableItem = null;
public EquippableItemPrefabAsset() { }
public EquippableItemPrefabAsset(string _name, string _prefabAssetName, Vector3 _position, EquippableItem _equippableItem = null)
: base(_name, _prefabAssetName, _position)
{
EquippableItem = _equippableItem;
}
///
///
///
///
///
///
/// the name by which the system will search for the item
public EquippableItemPrefabAsset(string _name, string _prefabAssetName, Vector3 _position, string _equippableItemName)
: base(_name, _prefabAssetName, _position)
{
// TODO during build product process, objects are not found - refactor this
string[] assetNames = AssetDatabase.FindAssets("t:EquippableItem", new[] { "Assets/Items/" });
foreach (string SOName in assetNames)
{
var SoPath = AssetDatabase.GUIDToAssetPath(SOName);
if(SoPath.Contains(_equippableItemName + ".asset"))
{
// 3.2 set EquippableItem object
EquippableItem = AssetDatabase.LoadAssetAtPath(SoPath);
break;
}
}
}
///
/// Function to convert Prefab Asset model to data object
///
///
public EquippableItemPrefabAssetData MapPrefabAssetModelToData()
{
return new EquippableItemPrefabAssetData(this);
}
}