Merge branch 'develop' into feature/extra-command

This commit is contained in:
2024-08-16 02:10:57 +08:00
56 changed files with 9469 additions and 1055 deletions
@@ -20,7 +20,7 @@ namespace AibisDream
}
/// <summary>
/// 开启对话
/// Ի
/// </summary>
/// <param name="yarnProject"></param>
public void StartDialog(YarnProject yarnProject)
@@ -30,9 +30,9 @@ namespace AibisDream
}
/// <summary>
/// 执行指令
/// ִָ
/// </summary>
/// <param name="commandName">指令名称</param>
/// <param name="commandName">ָ</param>
public void InvokeOptionCommand(string commandName, YarnOption[] options)
{
if (commandName == null) { }
@@ -43,29 +43,29 @@ namespace AibisDream
}
else
{
Debug.LogWarning($"没有找到 {commandName} 命令");
Debug.LogWarning($"ûҵ {commandName} ");
}
}
/// <summary>
/// 注册带选项指令
/// עѡָ
/// </summary>
/// <param name="commandName">指令名称</param>
/// <param name="commandAction">指令函数</param>
/// <param name="commandName">ָ</param>
/// <param name="commandAction">ָ</param>
public void RegisterOptionCommand(string commandName, Action<YarnOption[]> commandAction)
{
if (commandMap.ContainsKey(commandName))
{
Debug.Log($"命令 {commandName} 并未注册,重新注册会替换旧指令");
Debug.Log($" {commandName} δעעָ");
}
commandMap[commandName] = commandAction;
}
/// <summary>
/// 卸载指令
/// жָ
/// </summary>
/// <param name="commandName">指令名称</param>
/// <param name="commandName">ָ</param>
public void RemoveOptionCommand(string commandName)
{
if (commandMap.ContainsKey(commandName))
@@ -74,11 +74,11 @@ namespace AibisDream
}
else
{
Debug.Log($"命令 {commandName} 并未注册,重新注册会替换旧指令");
Debug.Log($" {commandName} δעעָ");
}
}
#region
#region
[YarnCommand("switch_tv")]
public static void SwitchTV(string picName)
{
@@ -114,6 +114,12 @@ namespace AibisDream
{
yield return SceneLoader.Instance.LoadSceneAsync(sceneName);
}
[YarnCommand("unload_scene")]
public static IEnumerator UnloadScene(string sceneName)
{
yield return SceneLoader.Instance.UnloadSceneAsync(sceneName);
}
[YarnCommand("init_fix")]
public static void InitFix()
+19
View File
@@ -52,6 +52,25 @@ namespace AibisDream
isLoading = false;
}
}
public IEnumerator UnloadSceneAsync(string sceneToUnload)
{
if (isLoading)
{
yield return null;
}
else
{
isLoading = true;
if (currentScene == sceneToUnload)
{
yield return Addressables.UnloadSceneAsync(_loadHandle, true);
currentScene = null;
}
isLoading = false;
}
}
}
}
+7 -4
View File
@@ -77,10 +77,13 @@ namespace AibisDream
// 生成新按钮
foreach (DialogueOption option in dialogueOptions)
{
var choiceInstance = Instantiate(choiceButtonPrefab, Vector3.zero, Quaternion.identity);
choiceInstance.transform.SetParent(choiceBox.transform);
choiceInstance.GetComponentInChildren<TextMeshProUGUI>().text = option.Line.TextWithoutCharacterName.Text;
choiceInstance.GetComponent<Button>().onClick.AddListener(() => onOptionSelected.Invoke(option.DialogueOptionID));
if (option.IsAvailable)
{
var choiceInstance = Instantiate(choiceButtonPrefab, Vector3.zero, Quaternion.identity);
choiceInstance.transform.SetParent(choiceBox.transform);
choiceInstance.GetComponentInChildren<TextMeshProUGUI>().text = option.Line.TextWithoutCharacterName.Text;
choiceInstance.GetComponent<Button>().onClick.AddListener(() => onOptionSelected.Invoke(option.DialogueOptionID));
}
}
}