I have the following class:
[System.Serializable]
public abstract class BaseBehaviour<T> : MonoBehaviour
{
[SerializeField]
public List<BaseAction<T>> Actions;
protected int currentIndex = 0;
public bool OptOut = false;
public Intelligence.Intelligence Intelligence;
public T BaseAiContext;
public List<BaseConsideration> Considerations;
public Dictionary<string, object> CacheValues = new Dictionary<string, object>();
public abstract void UpdateBehaviour();
public bool IsDone()
{
if (currentIndex > Actions.Count || OptOut)
{
return true;
}
return false;
}
public abstract float GetScore();
}
Then i have an implementation of this class:
[System.Serializable]
public class AttackTargetBehaviour : BaseBehaviour<ExampleAI>
{
public override void UpdateBehaviour()
{
Actions[0].Execute(this);
}
public override float GetScore()
{
float currentScore = 1;
for (int i = 0; i < Actions.Count; i++)
{
float score = 0; // Actions[i].GetScore(this);
if (score <= 0.0f)
{
return 0;
}
else
{
currentScore *= score;
}
}
return currentScore;
}
}
However here the list doesn't show in the inspector window which ultimately means i can't add my scriptableobject actions.
Can anyone tell me how i can display such as list in the Unity inspector?
For reference my action looks like this:
[System.Serializable]
public abstract class BaseAction<TContext> : ScriptableObject, IAction
{
And the implementation of this class is:
[CreateAssetMenu(fileName = "Move to Target", menuName = "AnAppGames/AI/Example/Actions/MoveToTargetAction")]
public class MoveToTargetAction : BaseAction<ExampleAI>
{
public override void Execute(BaseBehaviour<ExampleAI> context)
{
throw new System.NotImplementedException();
}
protected override void OnUpdate(BaseBehaviour<ExampleAI> context)
{
throw new System.NotImplementedException();
}
protected override void OnStop(BaseBehaviour<ExampleAI> context)
{
throw new System.NotImplementedException();
}
}