淡入淡出
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Yarn.Unity;
|
||||
|
||||
namespace AibisDream
|
||||
@@ -14,15 +12,17 @@ namespace AibisDream
|
||||
|
||||
private Dictionary<string, Action<YarnOption[]>> commandMap;
|
||||
|
||||
public bool quickRunMode;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
dialogueRunner = GetComponentInChildren<DialogueRunner>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// �����Ի�
|
||||
/// 开启对话
|
||||
/// </summary>
|
||||
/// <param name="yarnProject"></param>
|
||||
/// <param name="yarnProject">Yarn组</param>
|
||||
public void StartDialog(YarnProject yarnProject)
|
||||
{
|
||||
dialogueRunner.SetProject(yarnProject);
|
||||
@@ -30,12 +30,17 @@ namespace AibisDream
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ִ��ָ��
|
||||
/// 调用命令
|
||||
/// </summary>
|
||||
/// <param name="commandName">ָ������</param>
|
||||
/// <param name="commandName">命令名</param>
|
||||
/// <param name="options">选项</param>
|
||||
public void InvokeOptionCommand(string commandName, YarnOption[] options)
|
||||
{
|
||||
if (commandName == null) { }
|
||||
if (commandName == null)
|
||||
{
|
||||
Debug.Log("命令名为空");
|
||||
return;
|
||||
}
|
||||
|
||||
if (commandMap.TryGetValue(commandName, out var action))
|
||||
{
|
||||
@@ -43,29 +48,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,21 +79,22 @@ namespace AibisDream
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"���� {commandName} ��δע�ᣬ����ע����滻��ָ��");
|
||||
Debug.Log($"命令 {commandName} 不存在");
|
||||
}
|
||||
}
|
||||
|
||||
#region ��������
|
||||
#region 命令名
|
||||
|
||||
[YarnCommand("switch_tv")]
|
||||
public static void SwitchTV(string picName)
|
||||
{
|
||||
Debug.Log($"switch_tv {picName}");
|
||||
MainUIController.Instance.SwitchTV(picName);
|
||||
}
|
||||
|
||||
[YarnCommand("indoor")]
|
||||
public static void Indoor()
|
||||
public static void Indoor(float duration = 1)
|
||||
{
|
||||
MainUIController.Instance.HideMainUI();
|
||||
MainUIController.Instance.TVFadeOut(duration);
|
||||
}
|
||||
|
||||
[YarnCommand("character_into")]
|
||||
@@ -110,21 +116,24 @@ namespace AibisDream
|
||||
}
|
||||
|
||||
[YarnCommand("load_scene")]
|
||||
public static IEnumerator LoadScene(string sceneName)
|
||||
public static IEnumerator LoadScene(string sceneName, float duration = 1)
|
||||
{
|
||||
HideDialog();
|
||||
yield return MainUIController.Instance.FadeInSync(duration);
|
||||
yield return SceneLoader.Instance.LoadSceneAsync(sceneName);
|
||||
yield return MainUIController.Instance.FadeOutSync(duration);
|
||||
}
|
||||
|
||||
[YarnCommand("unload_scene")]
|
||||
public static IEnumerator UnloadScene(string sceneName)
|
||||
{
|
||||
yield return SceneLoader.Instance.UnloadSceneAsync(sceneName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[YarnCommand("init_fix")]
|
||||
public static void InitFix()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
[YarnCommand("hide_dialog")]
|
||||
@@ -132,7 +141,19 @@ namespace AibisDream
|
||||
{
|
||||
DialogUiViewer.Instance.HideDialog();
|
||||
}
|
||||
|
||||
[YarnCommand("fade_in")]
|
||||
public static IEnumerator FadeIn(float duration = 1)
|
||||
{
|
||||
return MainUIController.Instance.FadeInSync(duration);
|
||||
}
|
||||
|
||||
[YarnCommand("fade_out")]
|
||||
public static IEnumerator FadeOut(float duration = 1)
|
||||
{
|
||||
return MainUIController.Instance.FadeOutSync(duration);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user