I'm fairly sure that Meshes are Unity Objects so it should work.
Just to make sure, try using some other Object.
Just to make sure, try using some other Object.
[HutongGames.PlayMaker.Tooltip("Get or Set an attribute value.")]
[ActionCategory("Ultimate Inventory System")]
public class GetSetItemAttributeValueMesh : GetSetItemAttributeValueBase
{
[HutongGames.PlayMaker.Tooltip("The Value Which contains the value retrieved or contains the value to set.")]
[UIHint(UIHint.Variable)]
public FsmObject m_Value;
protected override void DoGetSetAttributeValue(Item item)
{
var attribute = item.GetAttribute<Attribute<Mesh>>(m_AttributeName.Value);
if (attribute == null) {
Fsm.Event(m_FailEvent);
return;
}
if (m_SetValue.Value) {
attribute.SetOverrideValue(m_Value.Value as Mesh);
} else {
m_Value.Value = attribute.GetValue();
}
Fsm.Event(m_SuccessEvent);
}
protected override void DoGetAttributeValue(ItemDefinition itemDefinition)
{
var attribute = itemDefinition.GetAttribute<Attribute<Mesh>>(m_AttributeName.Value);
if (attribute == null) {
Fsm.Event(m_FailEvent);
return;
}
m_Value.Value = attribute.GetValue();
Fsm.Event(m_SuccessEvent);
}
/// <summary>
/// Reset the public variables.
/// </summary>
public override void Reset()
{
base.Reset();
m_Value = null;
}
}
[HutongGames.PlayMaker.Tooltip("Get an item name from the item definition.")]
[ActionCategory("Ultimate Inventory System")]
public class GetItemName : GetSetItemAttributeValueBase
{
[HutongGames.PlayMaker.Tooltip("The Value Which contains the value retrieved or contains the value to set.")]
[UIHint(UIHint.Variable)]
public FsmString m_Value;
protected override void DoGetSetAttributeValue(Item item)
{
var name = item.name;
if (name == null)
{
Fsm.Event(m_FailEvent);
return;
}
Fsm.Event(m_SuccessEvent);
}
protected override void DoGetAttributeValue(ItemDefinition itemDefinition)
{
var name = itemDefinition.name;
if (name == null)
{
Fsm.Event(m_FailEvent);
return;
}
m_Value.Value = name;
Fsm.Event(m_SuccessEvent);
}
/// <summary>
/// Reset the public variables.
/// </summary>
public override void Reset()
{
base.Reset();
m_Value = null;
}
}
[HutongGames.PlayMaker.Tooltip("Get or Set an attribute value.")]
[ActionCategory("Ultimate Inventory System")]
public class GetSetItemAttributeValueItemDefinitionAmounts : GetSetItemAttributeValueBase
{
[HutongGames.PlayMaker.Tooltip("The Value Which contains the value retrieved or contains the value to set.")]
[UIHint(UIHint.Variable)]
[ArrayEditor(VariableType.Object)]
public FsmArray m_ItemDefinitionsValue;
[HutongGames.PlayMaker.Tooltip("The Value Which contains the value retrieved or contains the value to set.")]
[UIHint(UIHint.Variable)]
[ArrayEditor(VariableType.Int)]
public FsmArray m_AmountsValue;
protected override void DoGetSetAttributeValue(Item item)
{
var attribute = item.GetAttribute<Attribute<ItemDefinitionAmounts>>(m_AttributeName.Value);
if (attribute == null) {
Fsm.Event(m_FailEvent);
return;
}
if (m_SetValue.Value) {
if (m_ItemDefinitionsValue.Values.Length != m_AmountsValue.Values.Length) {
Fsm.Event(m_FailEvent);
return;
}
var array = new ItemDefinitionAmount[m_ItemDefinitionsValue.Values.Length];
for (int i = 0; i < array.Length; i++) {
array[i] = new ItemDefinitionAmount(m_ItemDefinitionsValue.Values[i] as ItemDefinition, (int)m_AmountsValue.Values[i]);
}
var itemDefinitionAmounts = new ItemDefinitionAmounts(array);
attribute.SetOverrideValue(itemDefinitionAmounts);
} else {
var itemDefinitionAmounts = attribute.GetValue();
m_ItemDefinitionsValue.Resize(itemDefinitionAmounts.Count);
m_AmountsValue.Resize(itemDefinitionAmounts.Count);
for (int i = 0; i < itemDefinitionAmounts.Count; i++) {
m_ItemDefinitionsValue.Set(i, itemDefinitionAmounts[i].ItemDefinition);
m_AmountsValue.Set(i, itemDefinitionAmounts[i].Amount);
}
}
Fsm.Event(m_SuccessEvent);
}
protected override void DoGetAttributeValue(ItemDefinition itemDefinition)
{
var attribute = itemDefinition.GetAttribute<Attribute<ItemDefinitionAmounts>>(m_AttributeName.Value);
if (attribute == null) {
Fsm.Event(m_FailEvent);
return;
}
var itemDefinitionAmounts = attribute.GetValue();
m_ItemDefinitionsValue.Resize(itemDefinitionAmounts.Count);
m_AmountsValue.Resize(itemDefinitionAmounts.Count);
for (int i = 0; i < itemDefinitionAmounts.Count; i++) {
m_ItemDefinitionsValue.Set(i, itemDefinitionAmounts[i].ItemDefinition);
m_AmountsValue.Set(i, itemDefinitionAmounts[i].Amount);
}
Fsm.Event(m_SuccessEvent);
}
/// <summary>
/// Reset the public variables.
/// </summary>
public override void Reset()
{
base.Reset();
m_ItemDefinitionsValue = null;
m_AmountsValue = null;
}
}
[HutongGames.PlayMaker.Tooltip("Get an attribute Array value.")]
[ActionCategory("Ultimate Inventory System")]
public class GetItemAttributeArrayValueItemDefinition : GetSetItemAttributeValueBase
{
[HutongGames.PlayMaker.Tooltip("The Value Which contains the value retrieved or contains the value to set.")]
[UIHint(UIHint.Variable)]
public FsmObject m_Value;
[HutongGames.PlayMaker.Tooltip("The Index to get")]
public FsmInt m_Index;
[HutongGames.PlayMaker.Tooltip("Get random item definition from array")]
public FsmBool m_Random;
protected override void DoGetSetAttributeValue(Item item)
{
int i = m_Index.Value;
bool random = m_Random.Value;
Attribute<ItemDefinition[]> attributes = item.GetAttribute<Attribute<ItemDefinition[]>>(m_AttributeName.Value);
if (attributes == null)
{
Fsm.Event(m_FailEvent);
return;
}
else
{
ItemDefinition[] attributesArray = attributes.GetValue();
if (random == true)
{
System.Random rnd = new System.Random();
int length = attributesArray.Length;
i = rnd.Next(0, length);
m_Index = i;
}
ItemDefinition attribute = (ItemDefinition)attributesArray.GetValue(i);
m_Value.Value = attribute;
}
Fsm.Event(m_SuccessEvent);
}
protected override void DoGetAttributeValue(ItemDefinition itemDefinition)
{
int i = m_Index.Value;
bool random = m_Random.Value;
var attributes = itemDefinition.GetAttribute<Attribute<ItemDefinition[]>>(m_AttributeName.Value);
if (attributes == null)
{
Fsm.Event(m_FailEvent);
return;
}
ItemDefinition[] attributesArray = attributes.GetValue();
if (random == true)
{
System.Random rnd = new System.Random();
int length = attributesArray.Length;
i = rnd.Next(0, length);
m_Index = i;
}
ItemDefinition attribute = (ItemDefinition)attributesArray.GetValue(i);
m_Value.Value = attribute;
Fsm.Event(m_SuccessEvent);
}
/// <summary>
/// Reset the public variables.
/// </summary>
public override void Reset()
{
base.Reset();
m_Value = null;
}
}
public void DoGetItemDefinition()
{
if (m_Inventory == null)
{
Debug.LogWarning("The Inventory does not exist on the gameobject", m_PrevGameObject);
Fsm.Event(m_FailEvent);
return;
}
var itemCollection = m_Inventory.GetItemCollection(m_ItemCollectionPurpose);
if (itemCollection != null)
{
// NEED HELP HERE: var itemInfo = itemCollection.GetItemInfo();
// get item definition from item collection or inventory or itemInfo
// set item definition to itemDefinition
}
else
{
Fsm.Event(m_FailEvent);
return;
}
if (itemDefinition != null)
{
ItemDefinition itemDef = itemDefinition;
m_Value.Value = itemDef;
Fsm.Event(m_SuccessEvent);
}
else
{
Fsm.Event(m_FailEvent);
}
}
var itemDefinition = itemInfo.Item?.ItemDefinition;