提交 8acbd171 编写于 作者: 魔术师Dix's avatar 魔术师Dix

【UI】添加保存按钮缓动按钮;

上级 e1939b3e
......@@ -1447,6 +1447,10 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
BtnSave: {fileID: 214173461}
ZoomAniRect: {fileID: 477166402}
ScaleMax: {x: 100, y: 100}
ScaleMin: {x: 60, y: 60}
SacleDuration: 0.75
--- !u!1 &244727596
GameObject:
m_ObjectHideFlags: 0
......@@ -8262,7 +8266,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: -152.56996, y: 0.000014305338}
m_AnchoredPosition: {x: -152.56996, y: 0.000067819456}
m_SizeDelta: {x: 305.14, y: 400.68}
m_Pivot: {x: 0, y: 1}
--- !u!114 &1245554590
......
......@@ -8,6 +8,7 @@
*/
using Sirenix.OdinInspector;
using System;
using UnityEngine;
using UnityEngine.UI;
......@@ -22,6 +23,9 @@ namespace UpmGitTool.UI
[LabelText("保存按钮")]
public Button BtnSave;
[LabelText("缩放缓动效果容器")]
public RectTransform ZoomAniRect;
private void Start()
{
BtnSave.onClick.AddListener(Save);
......@@ -44,5 +48,52 @@ namespace UpmGitTool.UI
private void HideButton() { gameObject.SetActive(false); }
#region 程序控制的缩放缓动动效
[Title("缩放缓动动效参数")]
[ShowInInspector, NonSerialized, LabelText("向内缩放中")]
[DisplayAsString]
private bool IsZoomIn;
[LabelText("最大尺寸")]
[SerializeField]
private Vector2 ScaleMax = new Vector2(100, 100);
[LabelText("最小尺寸")]
[SerializeField]
private Vector2 ScaleMin = new Vector2(60, 60);
[LabelText("缓动周期")]
[SerializeField]
[Range(0.1f, 2)]
private float SacleDuration = 3;
[DisplayAsString]
[ShowInInspector, NonSerialized, LabelText("缩放时间")]
private float ScaleCostTime = 0;
private void Update()
{
ScaleCostTime += Time.deltaTime;
float progress = Mathf.Clamp01(ScaleCostTime / SacleDuration);
Vector2 size;
if (IsZoomIn)
size = Vector2.Lerp(ScaleMax, ScaleMin, progress);
else
size = Vector2.Lerp(ScaleMin, ScaleMax, progress);
ZoomAniRect.sizeDelta = size;
if (progress >= 1)
{
IsZoomIn = !IsZoomIn;
ScaleCostTime = 0;
}
}
#endregion
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册