49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
[System.Serializable]
|
|
public class EquippableItemPrefarbAsset
|
|
{
|
|
[SerializeField]
|
|
public string name;
|
|
[SerializeField]
|
|
public string prefarbAssetName;
|
|
[SerializeField]
|
|
public Vector3 position;
|
|
[SerializeField]
|
|
public EquippableItem equippableItem = null;
|
|
|
|
public EquippableItemPrefarbAsset() { }
|
|
|
|
public EquippableItemPrefarbAsset(string _name, string _prefarbAssetName, Vector3 _position, EquippableItem _equippableItem)
|
|
{
|
|
name = _name;
|
|
prefarbAssetName = _prefarbAssetName;
|
|
position = _position;
|
|
equippableItem = _equippableItem;
|
|
}
|
|
|
|
public EquippableItemPrefarbAsset(string _name, string _prefarbAssetName, Vector3 _position, string _equippableItemName)
|
|
{
|
|
name = _name; // builded object local name (setuped e.g. by admin)
|
|
prefarbAssetName = _prefarbAssetName; // builded object name in Assets/
|
|
position = _position;
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|