From dc7922d80c1d133b6261b8af1d521567d2c0a35d Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 30 十月 2025 16:51:39 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts
---
Main/Component/UI/Common/ScreenMoveTo.cs | 260 +++++++++++++++++++++++++--------------------------
1 files changed, 128 insertions(+), 132 deletions(-)
diff --git a/Main/Component/UI/Common/ScreenMoveTo.cs b/Main/Component/UI/Common/ScreenMoveTo.cs
index 8c71560..b5bb44e 100644
--- a/Main/Component/UI/Common/ScreenMoveTo.cs
+++ b/Main/Component/UI/Common/ScreenMoveTo.cs
@@ -1,5 +1,5 @@
锘�//--------------------------------------------------------
-// [Author]: 绗簩涓栫晫
+// [Author]: 鐜╀釜娓告垙
// [ Date ]: Thursday, September 07, 2017
//--------------------------------------------------------
using UnityEngine;
@@ -7,164 +7,160 @@
using UnityEngine.UI;
using System;
-namespace vnxbqy.UI
+public class ScreenMoveTo : MonoBehaviour
{
- public class ScreenMoveTo : MonoBehaviour
+ [SerializeField]
+ LerpType m_LerpType = LerpType.Linear;
+
+ [SerializeField]
+ Vector2 m_Destination;
+ public Vector2 destination {
+ get { return m_Destination; }
+ set { m_Destination = value; }
+ }
+
+ [SerializeField]
+ float m_Duration = 0.5f;
+ public float duration {
+ get { return m_Duration; }
+ set { m_Duration = value; }
+ }
+
+ [SerializeField]
+ bool m_IsLocal = true;
+ public bool isLocal {
+ get { return m_IsLocal; }
+ }
+
+ bool disableOnEnd = true;
+ float endTime = 0f;
+
+ Vector3 startPosition = Vector3.zero;
+ Vector3 startLocalPosition = Vector3.zero;
+ Vector3 refPosition = Vector3.zero;
+
+ bool end = false;
+ Action endCallBack = null;
+
+ public void Begin(bool _deActiveOnEnd = true)
{
+ endTime = Time.time + duration;
+ end = false;
+ disableOnEnd = _deActiveOnEnd;
+ startPosition = this.transform.position;
+ startLocalPosition = this.transform.localPosition;
+ refPosition = Vector3.zero;
+ endCallBack = null;
- [SerializeField]
- LerpType m_LerpType = LerpType.Linear;
-
- [SerializeField]
- Vector2 m_Destination;
- public Vector2 destination {
- get { return m_Destination; }
- set { m_Destination = value; }
- }
-
- [SerializeField]
- float m_Duration = 0.5f;
- public float duration {
- get { return m_Duration; }
- set { m_Duration = value; }
- }
-
- [SerializeField]
- bool m_IsLocal = true;
- public bool isLocal {
- get { return m_IsLocal; }
- }
-
- bool disableOnEnd = true;
- float endTime = 0f;
-
- Vector3 startPosition = Vector3.zero;
- Vector3 startLocalPosition = Vector3.zero;
- Vector3 refPosition = Vector3.zero;
-
- bool end = false;
- Action endCallBack = null;
-
- public void Begin(bool _deActiveOnEnd = true)
+ this.enabled = true;
+ if (!this.gameObject.activeInHierarchy)
{
- endTime = Time.time + duration;
- end = false;
- disableOnEnd = _deActiveOnEnd;
- startPosition = this.transform.position;
- startLocalPosition = this.transform.localPosition;
- refPosition = Vector3.zero;
- endCallBack = null;
-
- this.enabled = true;
- if (!this.gameObject.activeInHierarchy)
- {
- this.SetActive(true);
- }
+ this.SetActive(true);
}
+ }
- public void Begin(Action _callBack, bool _disableOnEnd = true)
+ public void Begin(Action _callBack, bool _disableOnEnd = true)
+ {
+ endTime = Time.time + duration;
+ end = false;
+ disableOnEnd = _disableOnEnd;
+ startPosition = this.transform.position;
+ startLocalPosition = this.transform.localPosition;
+ refPosition = Vector3.zero;
+ endCallBack = _callBack;
+
+ this.enabled = true;
+ if (!this.gameObject.activeInHierarchy)
{
- endTime = Time.time + duration;
- end = false;
- disableOnEnd = _disableOnEnd;
- startPosition = this.transform.position;
- startLocalPosition = this.transform.localPosition;
- refPosition = Vector3.zero;
- endCallBack = _callBack;
-
- this.enabled = true;
- if (!this.gameObject.activeInHierarchy)
- {
- this.SetActive(true);
- }
+ this.SetActive(true);
}
+ }
- private void LateUpdate()
+ private void LateUpdate()
+ {
+ switch (m_LerpType)
{
- switch (m_LerpType)
- {
- case LerpType.Linear:
- if (Time.time < endTime)
- {
- var t = Mathf.Clamp01(1f - (endTime - Time.time) / m_Duration);
- if (isLocal)
- {
- this.transform.localPosition = Vector3.Lerp(startLocalPosition, destination, t);
- }
- else
- {
- this.transform.position = Vector3.Lerp(startPosition, destination, t);
- }
- }
- else
- {
- end = true;
- if (isLocal)
- {
- this.transform.localPosition = destination;
- }
- else
- {
- this.transform.position = destination;
- }
- }
- break;
- case LerpType.Smooth:
-
+ case LerpType.Linear:
+ if (Time.time < endTime)
+ {
+ var t = Mathf.Clamp01(1f - (endTime - Time.time) / m_Duration);
if (isLocal)
{
- if (Vector3.Distance(this.transform.localPosition, new Vector3(destination.x, destination.y)) > 1)
- {
- this.transform.localPosition = Vector3.SmoothDamp(this.transform.localPosition, destination, ref refPosition, duration);
- }
- else
- {
- this.transform.localPosition = destination;
- end = true;
- }
+ this.transform.localPosition = Vector3.Lerp(startLocalPosition, destination, t);
}
else
{
- if (Vector3.Distance(this.transform.position, new Vector3(destination.x, destination.y)) > 1)
- {
- this.transform.position = Vector3.SmoothDamp(this.transform.position, destination, ref refPosition, duration);
- }
- else
- {
- this.transform.position = destination;
- end = true;
- }
+ this.transform.position = Vector3.Lerp(startPosition, destination, t);
}
- break;
- }
-
- if (end)
- {
- if (endCallBack != null)
- {
- endCallBack();
- endCallBack = null;
}
- }
+ else
+ {
+ end = true;
+ if (isLocal)
+ {
+ this.transform.localPosition = destination;
+ }
+ else
+ {
+ this.transform.position = destination;
+ }
+ }
+ break;
+ case LerpType.Smooth:
- if (end && disableOnEnd)
- {
- this.enabled = false;
- }
-
+ if (isLocal)
+ {
+ if (Vector3.Distance(this.transform.localPosition, new Vector3(destination.x, destination.y)) > 1)
+ {
+ this.transform.localPosition = Vector3.SmoothDamp(this.transform.localPosition, destination, ref refPosition, duration);
+ }
+ else
+ {
+ this.transform.localPosition = destination;
+ end = true;
+ }
+ }
+ else
+ {
+ if (Vector3.Distance(this.transform.position, new Vector3(destination.x, destination.y)) > 1)
+ {
+ this.transform.position = Vector3.SmoothDamp(this.transform.position, destination, ref refPosition, duration);
+ }
+ else
+ {
+ this.transform.position = destination;
+ end = true;
+ }
+ }
+ break;
}
-
- public enum LerpType
+ if (end)
{
- Linear,
- Smooth,
+ if (endCallBack != null)
+ {
+ endCallBack();
+ endCallBack = null;
+ }
+ }
+
+ if (end && disableOnEnd)
+ {
+ this.enabled = false;
}
}
+
+ public enum LerpType
+ {
+ Linear,
+ Smooth,
+ }
+
}
+
--
Gitblit v1.8.0