This commit is contained in:
2024-10-16 00:03:41 +08:00
commit 897058435c
5033 changed files with 1009728 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
using UnityEngine;
namespace Views.Common
{
public abstract class ACommonTipBoxMessage : MonoBehaviour
{
public virtual Vector2 ExtraDistance => Vector2.one * 0.5f;
public abstract void Init ();
public abstract void ShowTipBpx (object message);
public abstract void ReleaseTipBox ();
public virtual void CloseBox ()
{
gameObject.SetActive (false);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8b5e5cb31a0042efa9fb360fea033423
timeCreated: 1722830445

View File

@@ -0,0 +1,87 @@
using System.Collections.Generic;
using Framework.Timer;
using Sirenix.Utilities;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Views.Common
{
public class CommonTipBox : ACommonTipBoxMessage
{
public class Message
{
public string title;
public string content;
}
public Vector2 extraDistance = Vector2.one * 0.5f;
public TMP_Text _title;
public TMP_Text _content;
public override Vector2 ExtraDistance => this.extraDistance;
public float _maxDuration = 5f;
private TimeHandler _timeHandler;
public bool HasClickScreenClose = true;
public override void Init ()
{
this._title.text = "";
this._content.text = "";
this.gameObject.SetActive (false);
}
public override void ShowTipBpx (object message)
{
this.gameObject.SetActive (false);
this._timeHandler?.Kill ();
if (message is Message msg)
{
this._timeHandler?.Kill ();
this._timeHandler = GameUpdateMgr.Instance.CreateTimer (this._maxDuration , CloseBox);
this._title.gameObject.SetActive (!msg.title.IsNullOrWhitespace ());
this._title.text = msg.title;
this._content.text = msg.content;
this.gameObject.SetActive (true);
LayoutRebuilder.ForceRebuildLayoutImmediate(this.transform as RectTransform);
}
}
public override void ReleaseTipBox ()
{
this._timeHandler?.Kill ();
this.gameObject.SetActive (false);
}
private void Update ()
{
if (this.gameObject.activeSelf)
{
//如果点击了屏幕,通过射线检测,关闭提示框
if (HasClickScreenClose && Input.GetMouseButtonDown (0))
{
PointerEventData SaveMousePosition = new PointerEventData (EventSystem.current);
SaveMousePosition.position = Input.mousePosition;
List<RaycastResult> result = new List<RaycastResult> ();
EventSystem.current.RaycastAll (SaveMousePosition, result);
if (result.Count > 0)
{
foreach (var raycastResult in result)
{
if (raycastResult.gameObject == this.gameObject)
{
return;
}
}
ReleaseTipBox ();
}
else
{
ReleaseTipBox ();
}
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b36c47c754f540058b7cdc3690506bff
timeCreated: 1722851424

View File

@@ -0,0 +1,54 @@
using System;
using Cysharp.Threading.Tasks;
using Framework.Utils;
using Framework.Utils.UITools;
using UnityEngine;
using CameraType = Framework.Utils.CameraType;
namespace Views.Common
{
public class CommonTipBoxFrame : MonoBehaviour
{
public ACommonTipBoxMessage TipBox;
public CameraType cameraType = CameraType.Base;
public bool rayClose;
private RectTransform _rectTransform;
private AdjustBox _adjustBox;
public void InitBox ()
{
var boxTransform = this.TipBox.transform as RectTransform;
this._rectTransform = this.transform as RectTransform;
this._adjustBox = new AdjustBox (CameraGroup.Instance.GetCamera (this.cameraType), this._rectTransform, boxTransform,
new Vector2Int (0, 0));
this.TipBox.Init ();
}
public async void ShowTipBox (RectTransform targetRect, object message)
{
this.gameObject.SetActive (true);
this.TipBox.ShowTipBpx (message);
await UniTask.DelayFrame (1);
this._adjustBox.AutoController (targetRect , this.TipBox.ExtraDistance , null , true);
}
private void OnMouseDown ()
{
if (this.rayClose)
{
this.TipBox.CloseBox ();
}
}
public void CloseTipBox ()
{
this.TipBox.CloseBox ();
}
public void ReleaseTipBox ()
{
this.TipBox.ReleaseTipBox ();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 41818aa9c7f64beebd65ce32d2e3fb22
timeCreated: 1722828231

View File

@@ -0,0 +1,15 @@
using TMPro;
using UnityEngine;
namespace Views.Common
{
public class WeaponTipBanner : MonoBehaviour
{
public TMP_Text _content;
public void ShowTipBanner (string content)
{
this._content.text = content;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 42fa24af5aea493e9ed2e488fe6b329c
timeCreated: 1722936858