信息显示Bug修复
This commit is contained in:
parent
731a8b10bb
commit
c36ab84ce7
@ -48,8 +48,22 @@ public class CharacterClick : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (instantiatedPanel == null)
|
if (instantiatedPanel == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (UIContorl.instance.NowShowInfo!=null)
|
||||||
|
{
|
||||||
|
Destroy(UIContorl.instance.NowShowInfo._closePanel);
|
||||||
|
HideAttackRange(UIContorl.instance.NowAttackRange);
|
||||||
|
}
|
||||||
|
|
||||||
instantiatedPanel = GameObject.Instantiate(panelPrefab, GameObject.Find("Canvas").transform);
|
instantiatedPanel = GameObject.Instantiate(panelPrefab, GameObject.Find("Canvas").transform);
|
||||||
ShowAttackRange();
|
UIContorl.instance.NowShowInfo = instantiatedPanel.GetComponent<charainfoPanel>();
|
||||||
|
UIContorl.instance.NowAttackRange = attackRange;
|
||||||
|
ShowAttackRange(UIContorl.instance.NowAttackRange);
|
||||||
|
instantiatedPanel.GetComponent<charainfoPanel>().closeBtn.onClick.AddListener(() => {
|
||||||
|
|
||||||
|
Destroy(instantiatedPanel.GetComponent<charainfoPanel>()._closePanel);
|
||||||
|
HideAttackRange(UIContorl.instance.NowAttackRange);
|
||||||
|
});
|
||||||
RectTransform panelRect = instantiatedPanel.GetComponent<RectTransform>();
|
RectTransform panelRect = instantiatedPanel.GetComponent<RectTransform>();
|
||||||
// 确保生成的面板不会挡住父物体
|
// 确保生成的面板不会挡住父物体
|
||||||
panelRect.SetAsLastSibling(); // 将面板放到 Canvas 层级的最上层
|
panelRect.SetAsLastSibling(); // 将面板放到 Canvas 层级的最上层
|
||||||
@ -64,13 +78,14 @@ public class CharacterClick : MonoBehaviour
|
|||||||
panelRect.GetComponent<charainfoPanel>().UpDateShow("1", MyCharacter.Name, MyCharacter.Info, MyCharacter.MaxAttack + "~" + MyCharacter.MinAttack, MyCharacter.AttackRange, MyCharacter.AttackCD);
|
panelRect.GetComponent<charainfoPanel>().UpDateShow("1", MyCharacter.Name, MyCharacter.Info, MyCharacter.MaxAttack + "~" + MyCharacter.MinAttack, MyCharacter.AttackRange, MyCharacter.AttackCD);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HideAttackRange();
|
//HideAttackRange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void ShowAttackRange()
|
public void ShowAttackRange(GameObject attackRange)
|
||||||
{
|
{
|
||||||
if (attackRange!=null)
|
if (attackRange!=null)
|
||||||
{
|
{
|
||||||
@ -82,7 +97,7 @@ public class CharacterClick : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void HideAttackRange()
|
public void HideAttackRange(GameObject attackRange)
|
||||||
{
|
{
|
||||||
if (attackRange != null )
|
if (attackRange != null )
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,8 @@ public class UIContorl : Base
|
|||||||
public static UIContorl instance;
|
public static UIContorl instance;
|
||||||
public Text BloodText;
|
public Text BloodText;
|
||||||
[Header("最大血量")]public int MaxHp;
|
[Header("最大血量")]public int MaxHp;
|
||||||
|
[Header("现在显示的信息面板")] public charainfoPanel NowShowInfo;
|
||||||
|
[Header("现在显示的攻击范围面板")] public GameObject NowAttackRange;
|
||||||
private int hp;
|
private int hp;
|
||||||
public int Hp
|
public int Hp
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@ public class cardContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD
|
|||||||
// 拖拽结束
|
// 拖拽结束
|
||||||
public void OnEndDrag(PointerEventData eventData)
|
public void OnEndDrag(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
mY.GetComponentInChildren<CharacterClick>().HideAttackRange();
|
mY.GetComponentInChildren<CharacterClick>().HideAttackRange(mY.GetComponentInChildren<CharacterClick>().attackRange);
|
||||||
if (mY.GetComponent<cardPlace>().isInTrigger)
|
if (mY.GetComponent<cardPlace>().isInTrigger)
|
||||||
{
|
{
|
||||||
mY.transform.position = mY.GetComponent<cardPlace>().tower.transform.position;
|
mY.transform.position = mY.GetComponent<cardPlace>().tower.transform.position;
|
||||||
|
@ -31,10 +31,10 @@ public class charainfoPanel : Base
|
|||||||
//await PanelminTobig(_panel);
|
//await PanelminTobig(_panel);
|
||||||
PanelminTobig(_panel);
|
PanelminTobig(_panel);
|
||||||
|
|
||||||
closeBtn.onClick.AddListener(() => {
|
//closeBtn.onClick.AddListener(() => {
|
||||||
|
|
||||||
Destroy(_closePanel);
|
// Destroy(_closePanel);
|
||||||
});
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void PanelminTobig(GameObject _panel)
|
public virtual void PanelminTobig(GameObject _panel)
|
||||||
|
Loading…
Reference in New Issue
Block a user