I wrote a custom action for my hot bar. But now I am having a weird and annoying issue where every time I re-open my unity. The inspector for my script clears out so I have to constantly go back to it and re-populate all the links. How do I fix this so they stay populated?
Here is my code for the custom action:
Here is my code for the custom action:
Code:
using Opsive.Shared.Game;
using Opsive.UltimateInventorySystem.Core.AttributeSystem;
using Opsive.UltimateInventorySystem.Core.DataStructures;
using Opsive.UltimateInventorySystem.ItemActions;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class UseTool : ItemAction
{
[SerializeField] protected string m_AttributeName = "ThrowablePrefab";
public Transform FirePoint;
public GameObject Body;
PlayerAnim PA;
protected override bool CanInvokeInternal(ItemInfo itemInfo, ItemUser itemUser)
{
if (itemInfo.Item.GetAttribute<Attribute<GameObject>>(m_AttributeName) == null)
{
return false;
}
return true;
}
protected override void InvokeActionInternal(ItemInfo itemInfo, ItemUser itemUser)
{
PA = Body.GetComponent<PlayerAnim>();
if (PA.Anim.GetInteger("State") == 0 || PA.Anim.GetInteger("State") == 2 || PA.Anim.GetInteger("State") == 5 || PA.Anim.GetInteger("State") == 6) {
var item = itemInfo.Item;
var MyPrefab = item.GetAttribute<Attribute<GameObject>>("ThrowablePrefab").GetValue();
var Value = item.GetAttribute<Attribute<int>>("Type").GetValue();
var clone = ObjectPool.Instantiate(MyPrefab, FirePoint.transform.position, FirePoint.transform.rotation);
// Debug.Log(Value);
PA.mode = Value;
}
}
}
Last edited by a moderator: