Tz2/Assets/Framework/Manager/TutorialGuideConfig.cs

77 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using NaughtyAttributes;
using UnityEngine;
namespace Framework.Manager
{
/// <summary>
/// 引导步骤类型枚举
/// </summary>
public enum GuideStepType
{
MustClickUI, // 必须点击指定UI才能继续
ClickNextButton, // 点击下一步按钮继续
Click3DObject // 点击3D物体继续
}
[Serializable]
public class GuideStepConfig
{
public string stepName; // 步骤名称
public string uiObjectName; // UI对象名称
[ReadOnly] public int order; // 顺序
public bool isOpenUI = false;
// [Header("引导类型设置")]
// [Tooltip("引导步骤类型,决定用户需要如何操作才能继续")]
// public GuideStepType stepType = GuideStepType.MustClickUI;
//
// [Tooltip("是否严格要求点击正确目标才能继续false时允许容错")]
// public bool requireExactClick = true;
// [TextArea(1, 3)]
// public string description; // 步骤描述
}
[CreateAssetMenu(fileName = "TutorialGuideConfig", menuName = "Framework/Config/引导配置")]
public class TutorialGuideConfig : ScriptableObject
{
public List<GuideStepConfig> guideSteps = new List<GuideStepConfig>();
// // 根据步骤名称获取配置
// public GuideStepConfig GetStepByName(string stepName)
// {
// return guideSteps.Find(step => step.stepName == stepName);
// }
// 根据UI对象名称获取配置
public GuideStepConfig GetStepByUIName(string uiName)
{
return guideSteps.Find(step => step.uiObjectName == uiName);
}
// 获取所有步骤,按顺序排序
public List<GuideStepConfig> GetOrderedSteps()
{
var orderedSteps = new List<GuideStepConfig>(guideSteps);
orderedSteps.Sort((a, b) => a.order.CompareTo(b.order));
return orderedSteps;
}
// 在编辑器中自动更新order值
private void OnValidate()
{
UpdateOrderValues();
}
// 根据列表位置更新order值
private void UpdateOrderValues()
{
for (int i = 0; i < guideSteps.Count; i++)
{
guideSteps[i].order = i + 1;
}
}
}
}