加确认框。按钮加tooltips。调整大地图tips的位置。
This commit is contained in:
1 parent
bb4fabc833
commit
1c712ff7d5
18 files changed
+2401
-520
No files matched your search
@@ -11,9 +11,22 @@ namespace Assets.Scripts.UI.Control
|
||||
[RequireComponent(typeof(Text))]
|
||||
public class PFUIText : PFUIComponentBase
|
||||
{
|
||||
private Text text;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return text.text;
|
||||
}
|
||||
set
|
||||
{
|
||||
text.text = value;
|
||||
}
|
||||
}
|
||||
protected void Awake()
|
||||
{
|
||||
|
||||
text = this.transform.GetComponent<Text>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
@@ -16,14 +18,18 @@ namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
Normal,
|
||||
Border,
|
||||
Primary
|
||||
Primary,
|
||||
Image
|
||||
}
|
||||
|
||||
[SerializeField] Type mType;
|
||||
[SerializeField] string Tooltips;
|
||||
private GameObject tooltips;
|
||||
private Image image;
|
||||
public Text text;
|
||||
private Texture2D cursor;
|
||||
private Text text;
|
||||
//private Texture2D cursor;
|
||||
private Outline outline;
|
||||
private Button mButton;
|
||||
|
||||
protected void Awake()
|
||||
{
|
||||
@@ -35,19 +41,35 @@ namespace Assets.Scripts.UI.Control
|
||||
}
|
||||
|
||||
//设置光标
|
||||
cursor = Resources.Load<Texture2D>("Images/PointerButtonHover");
|
||||
//cursor = Resources.Load<Texture2D>("Images/PointerButtonHover");
|
||||
|
||||
image = gameObject.GetComponent<Image>();
|
||||
text = this.transform.Find("Text").GetComponent<Text>();
|
||||
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
if(mType == Type.Image)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
text.gameObject.SetActive(false);
|
||||
}
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height*0.5f, 0));
|
||||
image.material = material;
|
||||
else
|
||||
{
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
}
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.5f, 0));
|
||||
image.material = material;
|
||||
}
|
||||
|
||||
tooltips = this.transform.Find("Tooltips").gameObject;
|
||||
if (!string.IsNullOrWhiteSpace(Tooltips))
|
||||
{
|
||||
//
|
||||
tooltips.transform.Find("Text").GetComponent<Text>().text = Tooltips;
|
||||
}
|
||||
tooltips.SetActive(false);
|
||||
|
||||
mButton = this.GetComponent<Button>();
|
||||
|
||||
InitColor();
|
||||
BindEvent();
|
||||
@@ -87,8 +109,13 @@ namespace Assets.Scripts.UI.Control
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerEnter, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
Cursor.SetCursor(cursor, Vector2.zero, CursorMode.Auto);
|
||||
|
||||
//Cursor.SetCursor(cursor, Vector2.zero, CursorMode.Auto);
|
||||
if (!string.IsNullOrWhiteSpace(Tooltips))
|
||||
{
|
||||
tooltips.GetComponent<CanvasGroup>().alpha = 0f;
|
||||
tooltips.SetActive(true);
|
||||
tooltips.GetComponent<CanvasGroup>().DOFade(1f, 0.2f);
|
||||
}
|
||||
switch (mType)
|
||||
{
|
||||
case Type.Normal:
|
||||
@@ -112,10 +139,14 @@ namespace Assets.Scripts.UI.Control
|
||||
}));
|
||||
|
||||
//鼠标离开
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerExit, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerExit, new UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
if (!string.IsNullOrWhiteSpace(Tooltips))
|
||||
{
|
||||
tooltips.SetActive(false);
|
||||
}
|
||||
//Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
switch (mType)
|
||||
{
|
||||
case Type.Normal:
|
||||
@@ -170,7 +201,7 @@ namespace Assets.Scripts.UI.Control
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerUp, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
//Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
|
||||
switch (mType)
|
||||
{
|
||||
@@ -200,6 +231,7 @@ namespace Assets.Scripts.UI.Control
|
||||
public void SetEnabled(bool value)
|
||||
{
|
||||
base.enabled = value;
|
||||
mButton.enabled = value;
|
||||
if (base.enabled)
|
||||
{
|
||||
InitColor();
|
||||
|
||||
Reference in new issue
Block a user