using NatML;
using System;
using System.Collections.Generic;
using UnityEngine;
///
/// This scriptable will hold tupples of Courseindices and models
///
[CreateAssetMenu(menuName = "Create new Scriptable/ModelList")]
public class ModelList : ScriptableObject
{
///
/// Small class to link a model to a courseIndex irrespective of its position in a list
///
[Serializable]
public class ModelTuple
{
///
/// ModelIndex to which the model corresponds
///
public ModelIndex index;
///
/// The model itself
///
public MLModelData modelWINDOWS;
///
/// The model itself
///
public MLModelData modelMAC;
}
///
/// A list of all the models
///
public List models = new List();
///
/// Index of the currently active model
///
public int currentModelIndex = 0;
///
/// Get a model by modelindex
///
/// ModelIndex of the model
/// Model associated with this index, null if no model was found
public MLModelData GetCurrentModel()
{
// Select Model based on OS
#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN)
return models.Find(x => x.modelWINDOWS == models[currentModelIndex].modelWINDOWS)?.modelWINDOWS;
#elif (UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX)
return models.Find(x => x.modelMAC == models[currentModelIndex].modelMAC)?.modelMAC;
#endif
return null;
}
///
/// Function to check if the modelIndex has been set
///
///
public bool HasValidModel()
{
return models[currentModelIndex].index != (int)ModelIndex.NONE;
}
///
/// Function to find a model-index in the list based on its index
///
///
public void SetCurrentModel(ModelIndex index)
{
currentModelIndex = models.FindIndex((m) => m.index == index);
}
}