56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
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;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="_name"></param>
|
|
/// <param name="_prefabAssetName"></param>
|
|
/// <param name="_position"></param>
|
|
/// <param name="_equippableItemName">the name by which the system will search for the item</param>
|
|
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<EquippableItem>(SoPath);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Function to convert Prefab Asset model to data object
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public EquippableItemPrefabAssetData MapPrefabAssetModelToData()
|
|
{
|
|
return new EquippableItemPrefabAssetData(this);
|
|
}
|
|
}
|
|
|
|
|