(client) chore:修复子弹属性错误,人物属性错误,侧边消息堆叠错误
This commit is contained in:
@ -482,7 +482,8 @@ namespace Managers
|
||||
|
||||
if (result && result.entity is Bullet bullet)
|
||||
{
|
||||
bullet.bulletSource = source;
|
||||
bullet.SetBulletSource(source);
|
||||
|
||||
if (source) bullet.affiliation = source.affiliation;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Base;
|
||||
using Data;
|
||||
using Prefab;
|
||||
using UnityEngine;
|
||||
@ -26,7 +25,7 @@ namespace Managers
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
}
|
||||
|
||||
public void DisplayMessage(string message, Data.PromptDisplayCategory type,Color? color=null)
|
||||
public void DisplayMessage(string message, PromptDisplayCategory type,Color? color=null)
|
||||
{
|
||||
if (!_canvas)
|
||||
{
|
||||
@ -43,7 +42,8 @@ namespace Managers
|
||||
TemporaryAnimationManager.Instance.GenerateTemporaryAnimation(message,
|
||||
Program.Instance.FocusedEntity.Position, 5); // 5秒显示时间
|
||||
break;
|
||||
|
||||
|
||||
case PromptDisplayCategory.Default:
|
||||
case PromptDisplayCategory.PassiveHint:
|
||||
if (_passiveHintContainer == null)
|
||||
{
|
||||
@ -55,22 +55,21 @@ namespace Managers
|
||||
var hintTextInstance = Instantiate(_temporaryAnimatorTextPrefab, _passiveHintContainer.transform);
|
||||
|
||||
// 确保它在Layout Group中正确显示
|
||||
var hintTextRect = hintTextInstance.GetComponent<RectTransform>();
|
||||
// var hintTextRect = hintTextInstance.GetComponent<RectTransform>();
|
||||
|
||||
// 如果temporaryAnimatorText有ContentSizeFitter,这里可能不需要设置sizeDelta,但为了LayoutGroup能识别,可以添加LayoutElement
|
||||
var layoutElement = hintTextInstance.GetComponent<LayoutElement>();
|
||||
if (layoutElement == null) layoutElement = hintTextInstance.gameObject.AddComponent<LayoutElement>();
|
||||
layoutElement.minHeight = 30; // 最小高度
|
||||
layoutElement.preferredWidth = _passiveHintContainer.sizeDelta.x; // 适应容器的宽度
|
||||
// var layoutElement = hintTextInstance.GetComponent<LayoutElement>();
|
||||
// if (layoutElement == null) layoutElement = hintTextInstance.gameObject.AddComponent<LayoutElement>();
|
||||
// layoutElement.minHeight = 30; // 最小高度
|
||||
// layoutElement.preferredWidth = _passiveHintContainer.sizeDelta.x; // 适应容器的宽度
|
||||
|
||||
// 设置字体样式
|
||||
var hintTmpText = hintTextInstance.GetComponent<TMP_Text>();
|
||||
if (hintTmpText != null)
|
||||
var hintTmpText = hintTextInstance.text;
|
||||
if (hintTmpText)
|
||||
{
|
||||
hintTmpText.fontSize = 24; // 较小的字体
|
||||
hintTmpText.alignment = TextAlignmentOptions.TopLeft; // 左上对齐
|
||||
hintTmpText.enableAutoSizing = false; // 关闭自动调整字体,保持统一
|
||||
hintTmpText.SetText(message); // 先设置文本,确保布局计算正确
|
||||
if(color.HasValue)
|
||||
hintTmpText.color = color.Value;
|
||||
}
|
||||
@ -106,7 +105,7 @@ namespace Managers
|
||||
// textInstance.lifeTime 可以在 Init 方法内部设置,如果 Init 没有提供参数,这里就无法直接设置。
|
||||
// 假设 Init 已经处理好生命周期。
|
||||
break;
|
||||
case PromptDisplayCategory.Default:
|
||||
|
||||
break;
|
||||
case PromptDisplayCategory.FocusedEntityChatBubble:
|
||||
break;
|
||||
@ -186,7 +185,7 @@ namespace Managers
|
||||
_passiveHintContainer.anchorMin = new Vector2(0, 0.5f);
|
||||
_passiveHintContainer.anchorMax = new Vector2(0, 0.5f);
|
||||
_passiveHintContainer.pivot = new Vector2(0, 0.5f); // 锚点和枢轴都在左中
|
||||
_passiveHintContainer.anchoredPosition = new Vector2(100, 0); // 从左边距100(示例值),Y轴中心
|
||||
_passiveHintContainer.anchoredPosition = new Vector2(0, 0); // 从左边距100(示例值),Y轴中心
|
||||
_passiveHintContainer.sizeDelta = new Vector2(400, 600); // 示例宽度和高度
|
||||
|
||||
// 添加VerticalLayoutGroup
|
||||
@ -194,13 +193,8 @@ namespace Managers
|
||||
layoutGroup.childAlignment = TextAnchor.UpperLeft; // 子元素靠左上排布
|
||||
layoutGroup.spacing = 10; // 消息之间的间距
|
||||
layoutGroup.padding = new RectOffset(10, 10, 10, 10); // 容器内边距
|
||||
|
||||
// 添加ContentSizeFitter,以便容器根据内容调整大小 (可选,根据实际需求)
|
||||
// fitter 会自动调整自身大小以适应子内容
|
||||
var fitter = containerGO.AddComponent<ContentSizeFitter>();
|
||||
fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
||||
layoutGroup.childControlHeight = true;
|
||||
layoutGroup.childForceExpandHeight = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user