@PanthenEye Thanks! Yah I could, but would that require me to manually set a pulldown for each Lesson?
Here’s how I’m using it: I’ve defined a Chapter as a List of Lessons… and then I want to go through the Lessons and automatically render each as either a Puzzle or a Story.
Is there a way to do that automatically with the eNum approach you mentioned? Thanks!
using UnityEngine;
using Unity.VisualScripting;
using System.Collections;
using System.Collections.Generic;
[CreateAssetMenu(fileName = "New Chapter", menuName = "Chapter", order = 11)]
public class Chapter : ScriptableObject
{
[SerializeField]
public string chapterName;
[SerializeField]
public List<Lesson> thisChapter;
}
You could have an OnValidate method in Chapter SO that loops over thisChapter items and sets the LessonType enum property based on Lesson type automatically whenever you update the list by hand.
using UnityEngine;
using System.Collections.Generic;
[CreateAssetMenu(fileName = "New Chapter", menuName = "Chapter", order = 11)]
public class Chapter : ScriptableObject
{
[SerializeField] public string chapterName;
[SerializeField] public List<Lesson> thisChapter = new();
#if UNITY_EDITOR
private void OnValidate()
{
foreach (Lesson lesson in thisChapter)
{
if (lesson is Story)
{
lesson.LessonType = LessonTypes.Story;
}
if (lesson is Puzzle)
{
lesson.LessonType = LessonTypes.Puzzle;
}
}
}
#endif
}
public enum LessonTypes
{
Story,
Puzzle
}