滚动列表
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.UI;
|
||||
using UnityEngine;
|
||||
using Yarn.Unity;
|
||||
|
||||
|
||||
@@ -12,28 +12,29 @@ namespace AibisDream
|
||||
public override void RunLine(LocalizedLine dialogueLine, Action onDialogueLineFinished)
|
||||
{
|
||||
string lineId = dialogueLine.TextID;
|
||||
string shortText = dialogueLine.TextWithoutCharacterName.Text.Length > 30
|
||||
? dialogueLine.TextWithoutCharacterName.Text.Substring(0, 30) + "..."
|
||||
string shortText = dialogueLine.TextWithoutCharacterName.Text.Length > 30
|
||||
? dialogueLine.TextWithoutCharacterName.Text.Substring(0, 30) + "..."
|
||||
: dialogueLine.TextWithoutCharacterName.Text;
|
||||
|
||||
|
||||
Debug.Log($"[对话流程] [{lineId}] ===== 开始处理 =====");
|
||||
Debug.Log($"[对话流程] [{lineId}] 文本内容: {shortText}");
|
||||
|
||||
EnumEventSystem.Global.Send(DialogEventEnum.LineStart, DialogText.GetLine(dialogueLine));
|
||||
|
||||
EnumEventSystem.Global.Send(DialogEventEnum.LineStart,
|
||||
DialogText.GetLine(dialogueLine, DialogController.Instance.GetCurLocalizedTableName()));
|
||||
|
||||
HandleLineOutput(dialogueLine, onDialogueLineFinished);
|
||||
|
||||
if (DialogController.Instance.quickRunMode)
|
||||
{
|
||||
Debug.Log($"[快速模式] [{lineId}] ===== 快速处理开始 =====");
|
||||
|
||||
|
||||
// 快速模式:直接跳过文本显示并继续
|
||||
bool skipResult = DialogCanvasManager.Instance.TrySkipLine(true);
|
||||
Debug.Log($"[快速模式] [{lineId}] TrySkipLine结果: {skipResult}");
|
||||
|
||||
|
||||
EnumEventSystem.Global.Send(DialogEventEnum.LineShown);
|
||||
Debug.Log($"[快速模式] [{lineId}] LineShown事件已发送");
|
||||
|
||||
|
||||
DialogCanvasManager.Instance.NextStep();
|
||||
Debug.Log($"[快速模式] [{lineId}] NextStep已调用");
|
||||
Debug.Log($"[快速模式] [{lineId}] ===== 快速处理完成 =====");
|
||||
@@ -42,7 +43,7 @@ namespace AibisDream
|
||||
{
|
||||
Debug.Log($"[正常模式] [{lineId}] 等待用户交互");
|
||||
}
|
||||
|
||||
|
||||
Debug.Log($"[对话流程] [{lineId}] ===== 处理完成 =====");
|
||||
}
|
||||
|
||||
@@ -51,7 +52,8 @@ namespace AibisDream
|
||||
string lineId = dialogueLine.TextID;
|
||||
Debug.Log($"[文本显示] [{lineId}] 开始显示文本");
|
||||
DialogCanvasManager.Instance.ShowLine(dialogueLine.TextWithoutCharacterName.Text,
|
||||
dialogueLine.GetCharacterVo(), onDialogueLineFinished, dialogueLine.TextID, dialogueLine.IsAutoSkipLine());
|
||||
dialogueLine.GetCharacterVo(), onDialogueLineFinished, dialogueLine.TextID,
|
||||
dialogueLine.IsAutoSkipLine());
|
||||
}
|
||||
|
||||
public override void RunOptions(DialogueOption[] dialogueOptions, Action<int> onOptionSelected)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using AibisDream.FixSystem;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.UI;
|
||||
using Cinemachine;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.FixSystem
|
||||
|
||||
@@ -72,5 +72,20 @@ namespace AibisDream.Framework
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadAssetAsync<T>(string key, Action<T> callback) where T : UnityEngine.Object
|
||||
{
|
||||
Addressables.LoadAssetAsync<T>(key).Completed += operation =>
|
||||
{
|
||||
if (operation.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
callback(operation.Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"资源{key}不存在");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.UI;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace AibisDream
|
||||
PlugOut,
|
||||
SceneLoad,
|
||||
FixStateSwitch,
|
||||
CutStart,
|
||||
CutEnd
|
||||
}
|
||||
|
||||
@@ -46,36 +45,17 @@ namespace AibisDream
|
||||
public string line;
|
||||
public CharacterVo actor;
|
||||
public string lineId;
|
||||
public string localizationTableName;
|
||||
|
||||
/// <summary>
|
||||
/// 获取进行记录的对话
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetDialogText()
|
||||
{
|
||||
// 先去掉换行
|
||||
var realLine = Regex.Replace(line, "[<|{].*?[>|}]", string.Empty);
|
||||
|
||||
if (!isOption)
|
||||
{
|
||||
return string.IsNullOrEmpty(actor.GetActorName())
|
||||
? realLine + "<br>"
|
||||
: actor.GetActorName() + ":" + realLine + "<br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "-> " + realLine + "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
public static DialogText GetLine(LocalizedLine dialogueLine)
|
||||
public static DialogText GetLine(LocalizedLine dialogueLine, string projName)
|
||||
{
|
||||
return new DialogText
|
||||
{
|
||||
isOption = false,
|
||||
line = dialogueLine.TextWithoutCharacterName.Text,
|
||||
lineId = dialogueLine.TextID,
|
||||
actor = dialogueLine.GetCharacterVo()
|
||||
actor = dialogueLine.GetCharacterVo(),
|
||||
localizationTableName = projName
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using AibisDream.FixSystem;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.UI;
|
||||
using AibisDream.Utility;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
@@ -1,352 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AibisDream.FixSystem;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.Utility;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using Yarn.Unity;
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
/// <summary>
|
||||
/// 优化版本的GameManager,解决性能问题
|
||||
/// </summary>
|
||||
public class GameManagerOptimized : Singleton<GameManagerOptimized>, IGameManager
|
||||
{
|
||||
#region 运行模式相关
|
||||
|
||||
private TalkSceneSO[] _totalSceneSos;
|
||||
private bool _isSceneSosLoaded = false;
|
||||
|
||||
public RunMode runMode;
|
||||
|
||||
[Header("生产环境数据(一般不动)")] public TalkSceneSO firstTalkSo;
|
||||
[Header("单场景测试")] public TalkSceneSO testTalkSo;
|
||||
[Header("存档测试")] public string saveFileName;
|
||||
|
||||
#endregion
|
||||
|
||||
private BindProperty<TalkSceneSO> _currentTalkSceneSo;
|
||||
private readonly GameLoopData _data = new();
|
||||
|
||||
// 缓存组件引用,避免重复查找
|
||||
private UIManager _uiManager;
|
||||
private SceneLoader _sceneLoader;
|
||||
private DialogController _dialogController;
|
||||
private AudioManager _audioManager;
|
||||
private ScreenEffectManager _screenEffectManager;
|
||||
private DialogCanvasManager _dialogCanvasManager;
|
||||
private CameraKit _cameraKit;
|
||||
private StorageSystem _storageSystem;
|
||||
|
||||
// 性能监控
|
||||
private PerformanceProfiler _performanceProfiler;
|
||||
private PerformanceOptimizer _performanceOptimizer;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// 预缓存所有需要的组件引用
|
||||
CacheComponentReferences();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 管理游戏开始时各部分的初始化
|
||||
SettingLoader.Init();
|
||||
|
||||
// 数据类注册
|
||||
_storageSystem.RegisterData(_data);
|
||||
|
||||
// 场景So事件注册
|
||||
_currentTalkSceneSo = new BindProperty<TalkSceneSO>();
|
||||
_currentTalkSceneSo.Register(item => _data.curSceneSoName = item.name);
|
||||
|
||||
// 事件广播
|
||||
EnumEventSystem.Global.Send(GameLoopEnum.AppStart);
|
||||
|
||||
// 异步加载SO,避免阻塞主线程
|
||||
StartCoroutine(LoadSceneSOsAsync());
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (runMode == RunMode.SingleScene)
|
||||
{
|
||||
StartWithLevel(testTalkSo);
|
||||
}
|
||||
else if (runMode == RunMode.SaveFile)
|
||||
{
|
||||
StartWithSaveFile($"{ConstRef.TestSaveFilePath}/{saveFileName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(LoadInitialSceneAsync());
|
||||
}
|
||||
#else
|
||||
_sceneLoader.LoadScene("ClinicOut");
|
||||
runMode = RunMode.Product;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 缓存组件引用,避免重复的FindObjectOfType调用
|
||||
/// </summary>
|
||||
private void CacheComponentReferences()
|
||||
{
|
||||
_uiManager = UIManager.Instance;
|
||||
_sceneLoader = SceneLoader.Instance;
|
||||
_dialogController = DialogController.Instance;
|
||||
_audioManager = AudioManager.Instance;
|
||||
_screenEffectManager = ScreenEffectManager.Instance;
|
||||
_dialogCanvasManager = DialogCanvasManager.Instance;
|
||||
_cameraKit = CameraKit.Instance;
|
||||
_storageSystem = StorageSystem.Instance;
|
||||
|
||||
// 性能监控组件
|
||||
_performanceProfiler = FindObjectOfType<PerformanceProfiler>();
|
||||
_performanceOptimizer = FindObjectOfType<PerformanceOptimizer>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载场景SO,避免阻塞主线程
|
||||
/// </summary>
|
||||
private IEnumerator LoadSceneSOsAsync()
|
||||
{
|
||||
var handle = Addressables.LoadAssetsAsync<TalkSceneSO>("SceneSO", null);
|
||||
|
||||
while (!handle.IsDone)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
_totalSceneSos = handle.Result.ToArray();
|
||||
_isSceneSosLoaded = true;
|
||||
Debug.Log($"成功加载 {_totalSceneSos.Length} 个场景SO");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("加载场景SO失败");
|
||||
}
|
||||
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载初始场景
|
||||
/// </summary>
|
||||
private IEnumerator LoadInitialSceneAsync()
|
||||
{
|
||||
yield return _uiManager.GetPanel<PlayToolPanel>().FadeInAsync(0);
|
||||
yield return _sceneLoader.LoadSceneAsync("ClinicOut");
|
||||
yield return _uiManager.GetPanel<PlayToolPanel>().FadeOutAsync();
|
||||
}
|
||||
|
||||
#region 游戏循环
|
||||
|
||||
public void StartNewGame()
|
||||
{
|
||||
// 游戏开始
|
||||
EnumEventSystem.Global.Send(GameLoopEnum.GameStart);
|
||||
|
||||
// 重置屏幕效果
|
||||
_screenEffectManager?.ResetSaturation();
|
||||
|
||||
// 序列
|
||||
_currentTalkSceneSo.Value = firstTalkSo;
|
||||
StartCoroutine(LoadFirstScene());
|
||||
}
|
||||
|
||||
public void StartWithLevel(TalkSceneSO sceneSo)
|
||||
{
|
||||
// 游戏开始
|
||||
EnumEventSystem.Global.Send(GameLoopEnum.GameStart);
|
||||
|
||||
// 重置屏幕效果
|
||||
_screenEffectManager?.ResetSaturation();
|
||||
|
||||
_currentTalkSceneSo.Value = sceneSo;
|
||||
StartCoroutine(LoadFirstScene());
|
||||
}
|
||||
|
||||
public void StartWithSaveFile(string fileName)
|
||||
{
|
||||
// 游戏开始
|
||||
EnumEventSystem.Global.Send(GameLoopEnum.GameStart);
|
||||
|
||||
_storageSystem.Load(fileName);
|
||||
}
|
||||
|
||||
private IEnumerator LoadFirstScene()
|
||||
{
|
||||
yield return _uiManager.GetPanel<PlayToolPanel>().FadeInAsync(0.5f);
|
||||
yield return _sceneLoader.LoadSceneAsync(_currentTalkSceneSo.Value.firstSceneName);
|
||||
_dialogController.StartDialog(_currentTalkSceneSo.Value.yarnProject);
|
||||
}
|
||||
|
||||
public void PauseGame()
|
||||
{
|
||||
// 系统暂停
|
||||
Time.timeScale = 0;
|
||||
|
||||
// 交互继续
|
||||
EnumEventSystem.Global.Send(GameLoopEnum.PauseGame);
|
||||
|
||||
// 音频全部暂停
|
||||
_audioManager.PauseAll();
|
||||
|
||||
// 关闭Dialog
|
||||
_dialogCanvasManager.CloseCanvas();
|
||||
}
|
||||
|
||||
public void ContinueGame()
|
||||
{
|
||||
// 系统继续
|
||||
Time.timeScale = 1;
|
||||
|
||||
// 交互继续
|
||||
EnumEventSystem.Global.Send(GameLoopEnum.UnPauseGame);
|
||||
|
||||
// 音频继续
|
||||
_audioManager.UnPauseAll();
|
||||
|
||||
// 打开Dialog
|
||||
_dialogCanvasManager.OpenCanvas();
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
// 系统继续
|
||||
Time.timeScale = 1;
|
||||
|
||||
// 重置屏幕效果
|
||||
_screenEffectManager?.ResetSaturation();
|
||||
|
||||
// 卸载当前场景
|
||||
StartCoroutine(RestartCoroutine());
|
||||
}
|
||||
|
||||
public void QuitApp()
|
||||
{
|
||||
// 清理资源
|
||||
CleanupResources();
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源,避免内存泄漏
|
||||
/// </summary>
|
||||
private void CleanupResources()
|
||||
{
|
||||
// 记录性能数据
|
||||
_performanceProfiler?.LogPerformanceData();
|
||||
|
||||
// 清理对象池
|
||||
var objectPool = FindObjectOfType<ObjectPool>();
|
||||
objectPool?.ClearAllPools();
|
||||
|
||||
// 清理其他资源
|
||||
Resources.UnloadUnusedAssets();
|
||||
System.GC.Collect();
|
||||
}
|
||||
|
||||
private IEnumerator RestartCoroutine()
|
||||
{
|
||||
_uiManager.GetPanel<PlayToolPanel>().FadeInSync(0.1f);
|
||||
|
||||
// 清理所有系统注册
|
||||
if (FixSystemCenter.SystemDic != null)
|
||||
{
|
||||
FixSystemCenter.SystemDic.Clear();
|
||||
}
|
||||
|
||||
// 执行场景切换等功能
|
||||
_cameraKit.ResetCamera();
|
||||
yield return _sceneLoader.LoadSceneAsync("ClinicOut");
|
||||
_dialogController.StopDialog();
|
||||
EnumEventSystem.Global.Send(GameLoopEnum.GameQuit);
|
||||
|
||||
// 音频继续
|
||||
_audioManager.UnPauseAll();
|
||||
|
||||
// 打开Dialog
|
||||
_dialogCanvasManager.OpenCanvas();
|
||||
|
||||
yield return _uiManager.GetPanel<PlayToolPanel>().FadeOutAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 分辨率与屏幕模式
|
||||
|
||||
public void SetScreenMode(string windowMode)
|
||||
{
|
||||
switch (windowMode)
|
||||
{
|
||||
case "FullScreen":
|
||||
Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, FullScreenMode.FullScreenWindow);
|
||||
break;
|
||||
case "Windowed":
|
||||
Screen.SetResolution(1920, 1080, FullScreenMode.Windowed);
|
||||
break;
|
||||
case "MaximizedWindow":
|
||||
Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, FullScreenMode.MaximizedWindow);
|
||||
break;
|
||||
default:
|
||||
Debug.Log($"{windowMode} err");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public IEnumerator NextSceneSo()
|
||||
{
|
||||
if (_currentTalkSceneSo.Value && _currentTalkSceneSo.Value.nextScene)
|
||||
{
|
||||
_currentTalkSceneSo.Value = _currentTalkSceneSo.Value.nextScene;
|
||||
yield return _uiManager.GetPanel<PlayToolPanel>().FadeInAsync();
|
||||
yield return _sceneLoader.LoadSceneAsync(_currentTalkSceneSo.Value.firstSceneName);
|
||||
_dialogController.StartDialog(_currentTalkSceneSo.Value.yarnProject);
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return null;
|
||||
Debug.Log("没有下个场景了");
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSceneSoByName(string soName)
|
||||
{
|
||||
if (!_isSceneSosLoaded)
|
||||
{
|
||||
Debug.LogWarning("场景SO尚未加载完成,无法设置场景");
|
||||
return;
|
||||
}
|
||||
|
||||
_currentTalkSceneSo.Value = Array.Find(_totalSceneSos, so => so.name == soName);
|
||||
}
|
||||
|
||||
public void StartDialog()
|
||||
{
|
||||
_dialogController.LoadDialog(_currentTalkSceneSo.Value.yarnProject);
|
||||
}
|
||||
|
||||
public string GetSceneSoName()
|
||||
{
|
||||
return _currentTalkSceneSo.Value.name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取性能报告
|
||||
/// </summary>
|
||||
public void GetPerformanceReport()
|
||||
{
|
||||
_performanceOptimizer?.CreatePerformanceReport();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae939fca7f9be304ca856afaa6a28f9b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.UI;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace AibisDream
|
||||
|
||||
#region 对话回顾
|
||||
|
||||
private StringBuilder DialogRecord => UIManager.Instance.GetPanel<RecordPanel>().recordStr;
|
||||
private RecordPanel RecordPanel => UIManager.Instance.GetPanel<RecordPanel>();
|
||||
|
||||
/// <summary>
|
||||
/// 记录对话
|
||||
@@ -347,12 +347,12 @@ namespace AibisDream
|
||||
/// <param name="line">对话</param>
|
||||
private void AddDialogueLine(DialogText line)
|
||||
{
|
||||
DialogRecord.Append(line.GetDialogText());
|
||||
RecordPanel.AppendDialogLine(line);
|
||||
}
|
||||
|
||||
private void CleanDialogHistory()
|
||||
{
|
||||
DialogRecord.Clear();
|
||||
RecordPanel.ClearDialog();
|
||||
}
|
||||
|
||||
public void CloseCanvas()
|
||||
|
||||
@@ -4,7 +4,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public class ChapterPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
@@ -12,6 +12,8 @@ namespace AibisDream
|
||||
|
||||
public ChapterController chapterController;
|
||||
public Animator animator;
|
||||
public Image background;
|
||||
|
||||
public RectTransform chapterContentRect;
|
||||
public TMP_Text errorInfo;
|
||||
|
||||
@@ -24,7 +26,6 @@ namespace AibisDream
|
||||
|
||||
#endregion
|
||||
|
||||
public Color backgroundColor = new(10.0f / 255.0f, 10.0f / 255.0f, 10.0f / 255.0f, 0.6f);
|
||||
public float delayTime = 0.5f;
|
||||
private GameObject _background;
|
||||
|
||||
@@ -48,37 +49,14 @@ namespace AibisDream
|
||||
|
||||
private void AddBackground()
|
||||
{
|
||||
var bgTex = new Texture2D(1, 1);
|
||||
bgTex.SetPixel(0, 0, backgroundColor);
|
||||
bgTex.Apply();
|
||||
|
||||
_background = new GameObject("PopupBackground");
|
||||
var image = _background.AddComponent<Image>();
|
||||
var rect = new Rect(0, 0, bgTex.width, bgTex.height);
|
||||
var sprite = Sprite.Create(bgTex, rect, new Vector2(0.5f, 0.5f), 1);
|
||||
// Clone the material, which is the default UI material, to avoid changing it permanently.
|
||||
image.material = new Material(image.material);
|
||||
image.material.mainTexture = bgTex;
|
||||
image.sprite = sprite;
|
||||
var newColor = image.color;
|
||||
image.color = newColor;
|
||||
image.canvasRenderer.SetAlpha(0.0f);
|
||||
image.CrossFadeAlpha(1.0f, 0.4f, false);
|
||||
|
||||
var canvas = GetComponentInParent<Canvas>();
|
||||
_background.transform.localScale = new Vector3(1, 1, 1);
|
||||
_background.GetComponent<RectTransform>().sizeDelta = canvas.GetComponent<RectTransform>().sizeDelta;
|
||||
_background.transform.SetParent(transform, false);
|
||||
_background.transform.SetAsFirstSibling();
|
||||
background.canvasRenderer.SetAlpha(0.0f);
|
||||
background.gameObject.SetActive(true);
|
||||
background.CrossFadeAlpha(1.0f, 0.4f, false);
|
||||
}
|
||||
|
||||
private void RemoveBackground()
|
||||
{
|
||||
var image = _background.GetComponent<Image>();
|
||||
if (image != null)
|
||||
{
|
||||
image.CrossFadeAlpha(0.0f, 0.2f, false);
|
||||
}
|
||||
background.CrossFadeAlpha(0.0f, 0.2f, false);
|
||||
}
|
||||
|
||||
#region 绘制关卡信息部分
|
||||
@@ -119,6 +97,8 @@ namespace AibisDream
|
||||
chapterContentRect.DestroyAllChildren();
|
||||
gameObject.SetActive(false);
|
||||
Destroy(_background);
|
||||
|
||||
background.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void OnChapterSelected(ChapterVo chapterVo)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using AibisDream.Utility;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public class EndPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public class MainPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ using RainbowArt.CleanFlatUI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 主要用来放置淡入淡出,图片展示等演出工具
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 109240ef40ab401693ed206abd98a89b
|
||||
timeCreated: 1757673374
|
||||
@@ -0,0 +1,30 @@
|
||||
using AibisDream.Utility;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Localization.Components;
|
||||
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public class RecordItem : MonoBehaviour
|
||||
{
|
||||
#region 索引
|
||||
|
||||
[SerializeField] private LocalizeStringEvent actorName;
|
||||
[SerializeField] private LocalizeStringEvent dialogLine;
|
||||
|
||||
#endregion
|
||||
|
||||
public void Init(DialogText dialogText)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
actorName.SetTable(ConstRef.ActorNameTable);
|
||||
actorName.SetEntry(dialogText.actor.key);
|
||||
dialogLine.SetTable(dialogText.localizationTableName);
|
||||
dialogLine.SetEntry(dialogText.lineId);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0df5ddfccd99400d98c249484a3c8eb6
|
||||
timeCreated: 1757673184
|
||||
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.Utility;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public class RecordPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
public bool IsOpen => gameObject.activeSelf;
|
||||
public bool IsCloseable => true;
|
||||
|
||||
#region 索引
|
||||
|
||||
[SerializeField] private Image popupBackground;
|
||||
[SerializeField] private Button closeBtn;
|
||||
[SerializeField] private LoopVerticalScrollRect recordScroll;
|
||||
[SerializeField] private Transform content;
|
||||
[SerializeField] private Transform inactiveRoot;
|
||||
|
||||
#endregion
|
||||
|
||||
private readonly List<DialogText> _recordDataList = new();
|
||||
// private RecordSource _recordSource;
|
||||
|
||||
public void Show()
|
||||
{
|
||||
GameManager.Instance.PauseGame();
|
||||
gameObject.SetActive(true);
|
||||
|
||||
popupBackground.canvasRenderer.SetAlpha(0);
|
||||
popupBackground.gameObject.SetActive(true);
|
||||
popupBackground.CrossFadeAlpha(1, 0.4f, false);
|
||||
|
||||
closeBtn.onClick.AddListener(ReturnGame);
|
||||
|
||||
// 打开场景
|
||||
ShowRecord();
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
GameManager.Instance.ContinueGame();
|
||||
// 关闭背景
|
||||
popupBackground.CrossFadeAlpha(0, 0.2f, false);
|
||||
ActionKit.Delay(0.2f, () => popupBackground.gameObject.SetActive(false)).Start(this);
|
||||
|
||||
// 关闭时停止渲染
|
||||
closeBtn.onClick.RemoveAllListeners();
|
||||
|
||||
HideRecord();
|
||||
}
|
||||
|
||||
public void AppendDialogLine(DialogText dialogText)
|
||||
{
|
||||
_recordDataList.Add(dialogText);
|
||||
}
|
||||
|
||||
public void ClearDialog()
|
||||
{
|
||||
_recordDataList.Clear();
|
||||
}
|
||||
|
||||
private void ShowRecord()
|
||||
{
|
||||
var resource = new RecordSource(content, inactiveRoot, _recordDataList);
|
||||
|
||||
recordScroll.prefabSource = resource;
|
||||
recordScroll.dataSource = resource;
|
||||
recordScroll.totalCount = resource.TotalCount;
|
||||
recordScroll.RefillCells();
|
||||
}
|
||||
|
||||
private void HideRecord()
|
||||
{
|
||||
content.DestroyAllChildren();
|
||||
}
|
||||
|
||||
private void ReturnGame()
|
||||
{
|
||||
UIManager.Instance.HidePanel<RecordPanel>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.Collections.Generic;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public class RecordSource : ILoopScrollDataSource, ILoopScrollPrefabSource
|
||||
{
|
||||
private readonly SimpleObjectPool<RecordItem> _pool;
|
||||
|
||||
private readonly GameObject _itemPrefab;
|
||||
private readonly Transform _contentRoot;
|
||||
private readonly Transform _tempRoot;
|
||||
|
||||
private List<DialogText> _dialogTexts;
|
||||
|
||||
public int TotalCount => _dialogTexts.Count;
|
||||
|
||||
public RecordSource(Transform content, Transform tempRoot, List<DialogText> dialogTexts)
|
||||
{
|
||||
_contentRoot = content;
|
||||
_tempRoot = tempRoot;
|
||||
|
||||
_dialogTexts = dialogTexts;
|
||||
|
||||
_itemPrefab = ResourceKit.LoadAssetSync<GameObject>(ConstRef.RecordPrefab);
|
||||
_pool = new SimpleObjectPool<RecordItem>(InstantiateItem);
|
||||
}
|
||||
|
||||
private RecordItem InstantiateItem()
|
||||
{
|
||||
return Object.Instantiate(_itemPrefab, _tempRoot).GetComponent<RecordItem>();
|
||||
}
|
||||
|
||||
#region 滚动功能
|
||||
|
||||
public void ProvideData(Transform transform, int idx)
|
||||
{
|
||||
var item = transform.GetComponent<RecordItem>();
|
||||
if (item != null)
|
||||
{
|
||||
item.Init(_dialogTexts[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject GetObject(int index)
|
||||
{
|
||||
var obj = _pool.Allocate().gameObject;
|
||||
obj.transform.SetParent(_contentRoot);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public void ReturnObject(Transform trans)
|
||||
{
|
||||
Debug.Log("return obj");
|
||||
|
||||
trans.SetParent(_tempRoot);
|
||||
|
||||
var record = trans.GetComponent<RecordItem>();
|
||||
record.Dispose();
|
||||
_pool.Recycle(record);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 616a80ca37a1406e808457bc971323b1
|
||||
timeCreated: 1757673398
|
||||
@@ -1,52 +0,0 @@
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
public class RecordPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
public bool IsOpen => gameObject.activeSelf;
|
||||
public bool IsCloseable => true;
|
||||
|
||||
public readonly StringBuilder recordStr = new();
|
||||
|
||||
public void Show()
|
||||
{
|
||||
ShowText();
|
||||
GameManager.Instance.PauseGame();
|
||||
gameObject.SetActive(true);
|
||||
|
||||
var btn = transform.Find("Return").GetComponent<Button>();
|
||||
btn.onClick.AddListener(ReturnGame);
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
GameManager.Instance.ContinueGame();
|
||||
// 关闭时停止渲染
|
||||
ClearText();
|
||||
var btn = transform.Find("Return").GetComponent<Button>();
|
||||
btn.onClick.RemoveAllListeners();
|
||||
}
|
||||
|
||||
private void ShowText()
|
||||
{
|
||||
var text = transform.Find("Log View").GetComponentInChildren<TMP_Text>();
|
||||
text.text = recordStr.ToString();
|
||||
}
|
||||
|
||||
private void ClearText()
|
||||
{
|
||||
var text = transform.Find("Log View").GetComponentInChildren<TMP_Text>();
|
||||
text.text = null;
|
||||
}
|
||||
|
||||
private void ReturnGame()
|
||||
{
|
||||
UIManager.Instance.HidePanel<RecordPanel>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public class SavesPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using AibisDream.Utility;
|
||||
|
||||
namespace AibisDream
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public class SettingPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ using AibisDream.Utility;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public class StartPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace AibisDream
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public interface IUIPanel
|
||||
{
|
||||
|
||||
@@ -57,6 +57,8 @@ namespace AibisDream.Utility
|
||||
|
||||
public const string PipelinePrefabAddress = "PipelinePrefab";
|
||||
|
||||
public const string RecordPrefab = "RecordItem";
|
||||
|
||||
#endregion
|
||||
|
||||
#region 动画配置
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -324,7 +325,7 @@ namespace AibisDream.Utility
|
||||
}
|
||||
|
||||
var resultString = Regex.Replace(obj, "[^0-9.]", "");
|
||||
var result = resultString.Length == 0 ? 0M : decimal.Parse(resultString);
|
||||
var result = resultString.Length == 0 ? 0M : decimal.Parse(resultString, CultureInfo.CurrentCulture);
|
||||
if (obj.StartsWith("-"))
|
||||
{
|
||||
result *= -1M;
|
||||
@@ -355,7 +356,7 @@ namespace AibisDream.Utility
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (float.TryParse(normalStr, out var result))
|
||||
if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
|
||||
return result;
|
||||
else
|
||||
return 0;
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace AibisDream.Utility
|
||||
|
||||
public static JObject ReadJObject(string path)
|
||||
{
|
||||
string json = File.ReadAllText(FormatAsJsonPath(path));
|
||||
string json = File.ReadAllText(FormatAsJsonPath(path), System.Text.Encoding.UTF8);
|
||||
return JObject.Parse(json);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user