mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-30 15:33:44 +00:00
Reworking item spawn, adding item conversion.
This commit is contained in:
45
Assets/Scripts/Products/DefectMeshSelector.cs
Normal file
45
Assets/Scripts/Products/DefectMeshSelector.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DefectMeshSelector: MonoBehaviour, IDefectVisualizer
|
||||
{
|
||||
public GameObject NormalPrefab;
|
||||
|
||||
[Serializable]
|
||||
public struct PrefabVariant
|
||||
{
|
||||
public DefectType DefectType;
|
||||
public GameObject Prefab;
|
||||
}
|
||||
|
||||
public List<PrefabVariant> DefectivePrefabVariants;
|
||||
|
||||
public void VisualizeDefect(DefectType defectType)
|
||||
{
|
||||
if (defectType == DefectType.None)
|
||||
{
|
||||
NormalPrefab.SetActive(true);
|
||||
|
||||
foreach (var variant in DefectivePrefabVariants)
|
||||
{
|
||||
variant.Prefab.SetActive(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NormalPrefab.SetActive(false);
|
||||
|
||||
foreach (var variant in DefectivePrefabVariants)
|
||||
{
|
||||
variant.Prefab.SetActive(false);
|
||||
|
||||
if (defectType.HasFlag(variant.DefectType))
|
||||
{
|
||||
variant.Prefab.SetActive(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user