diff --git a/Assets/Common/Interfaces/ModelList.cs b/Assets/Common/Interfaces/ModelList.cs index 3a6b759..5f191a8 100644 --- a/Assets/Common/Interfaces/ModelList.cs +++ b/Assets/Common/Interfaces/ModelList.cs @@ -23,9 +23,9 @@ public class ModelList : ScriptableObject /// /// ModelIndex of the model /// Model associated with this index, null if no model was found - public NNModel GetModelByIndex(ModelIndex modelIndex) + public NNModel GetCurrentModel() { - return models.Find((m) => m.index == modelIndex).model; + return models[currentModelIndex].model; } /// diff --git a/Assets/Common/Scripts/CommonScripts.asmdef b/Assets/Common/Scripts/CommonScripts.asmdef index 8cd1fb2..8b1a1ba 100644 --- a/Assets/Common/Scripts/CommonScripts.asmdef +++ b/Assets/Common/Scripts/CommonScripts.asmdef @@ -6,8 +6,7 @@ "GUID:63c63e721f65ebb7d871cb9ef49f4752", "GUID:1631ed2680c61245b8211d943c1639a8", "GUID:5c2b5ba89f9e74e418232e154bc5cc7a", - "GUID:7f2d0ee6dd21e1d4eb25b71b7a749d25", - "GUID:d0b6b39a21908f94fbbd9f2c196a9725" + "GUID:7f2d0ee6dd21e1d4eb25b71b7a749d25" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/Common/Tests/ModelListTest.cs b/Assets/Common/Tests/ModelListTest.cs index d28480d..2e975a9 100644 --- a/Assets/Common/Tests/ModelListTest.cs +++ b/Assets/Common/Tests/ModelListTest.cs @@ -37,27 +37,10 @@ public class ModelListTest } /// - /// Check if getModelByIndex returns the NMModel or return null if there is no model + /// Check if all courses can be correctly gotten and set as current via SetCurrentCourse /// [Test] - public void TestGetModelByIndex() - { - foreach (var field in typeof(ModelIndex).GetFields()) - { - if (field.IsLiteral) - { - ModelIndex value = (ModelIndex)field.GetValue(null); - string name = field.Name; - Assert.IsTrue(modelList.GetModelByIndex(value) is NNModel || modelList.GetModelByIndex(value) is null); - } - } - } - - /// - /// Check if all courses can be correctly set as current via SetCurrentCourse - /// - [Test] - public void TestSetCurrentModel() + public void TestGetSetCurrentModel() { foreach (var field in typeof(ModelIndex).GetFields()) { @@ -71,6 +54,7 @@ public class ModelListTest ModelTuple m = modelList.models[modelList.currentModelIndex]; Assert.AreEqual(m.index, value); + Assert.IsTrue(m.model is NNModel || m.model is null); } } } diff --git a/Assets/MediaPipeUnity/Scripts/SignPredictor.cs b/Assets/MediaPipeUnity/Scripts/SignPredictor.cs index fb02a82..2ec4263 100644 --- a/Assets/MediaPipeUnity/Scripts/SignPredictor.cs +++ b/Assets/MediaPipeUnity/Scripts/SignPredictor.cs @@ -210,7 +210,7 @@ namespace Mediapipe.Unity.Tutorial // check if model exists at path //var model = ModelLoader.Load(Resources.Load("Models/Fingerspelling/model_A-L")); - worker = modelList.models[modelList.currentModelIndex].model.CreateWorker(); + worker = modelList.GetCurrentModel().CreateWorker(); StartCoroutine(SignRecognitionCoroutine()); StartCoroutine(MediapipeCoroutine()); @@ -223,7 +223,7 @@ namespace Mediapipe.Unity.Tutorial worker?.Dispose(); // Add a new worker for the new model - worker = modelList.models[modelList.currentModelIndex].model.CreateWorker(); + worker = modelList.GetCurrentModel().CreateWorker(); } ///