Commit 3bd6fff1 authored by SherryChaos's avatar SherryChaos

bug fix

parent 94cf7695
...@@ -36,7 +36,7 @@ RectTransform: ...@@ -36,7 +36,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: -0, z: -0} m_LocalEulerAnglesHint: {x: 0, y: -0, z: -0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 22, y: -20} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 44, y: 44} m_SizeDelta: {x: 44, y: 44}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &579422588954085143 --- !u!114 &579422588954085143
......
...@@ -194,15 +194,21 @@ namespace MDPro3 ...@@ -194,15 +194,21 @@ namespace MDPro3
public static string GetConfigDeckName(bool containType = true) public static string GetConfigDeckName(bool containType = true)
{ {
var config = Get("DeckInUse", EMPTY_STRING); var config = Get("DeckInUse", EMPTY_STRING);
if(!containType && config.Contains("/")) if(config.StartsWith("/") && config.Length > 1)
config = config[1..];
if (!containType && config.Contains("/"))
config = Path.GetFileName(config); config = Path.GetFileName(config);
return config; return config;
} }
public static void SetConfigDeck(string deckName, bool needCheck = false) public static void SetConfigDeck(string deckName, bool needCheck = false)
{ {
if(needCheck) if (needCheck)
Set("DeckInUse", $"{Program.instance.deckSelector.DeckType}/{deckName}"); {
var type = Program.instance.deckSelector.DeckType;
var config = type == string.Empty ? deckName : $"{type}/{deckName}";
Set("DeckInUse", config);
}
else else
Set("DeckInUse", deckName); Set("DeckInUse", deckName);
} }
......
...@@ -474,8 +474,7 @@ namespace MDPro3.Net ...@@ -474,8 +474,7 @@ namespace MDPro3.Net
Bad("no token"); Bad("no token");
var token = account.token; var token = account.token;
var url = authUrl; using var request = UnityWebRequest.Get(authUrl);
using var request = UnityWebRequest.Get(url);
request.SetRequestHeader("Authorization", $"Bearer {token}"); request.SetRequestHeader("Authorization", $"Bearer {token}");
request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("Content-Type", "application/json");
await request.SendWebRequest(); await request.SendWebRequest();
......
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using DG.Tweening; using DG.Tweening;
using YgomSystem.UI; using YgomSystem.UI;
using UnityEngine.UI; using DGTween = DG.Tweening.Tween;
namespace MDPro3.UI namespace MDPro3.UI
{ {
...@@ -9,32 +10,105 @@ namespace MDPro3.UI ...@@ -9,32 +10,105 @@ namespace MDPro3.UI
{ {
public float range; public float range;
public float time; public float time;
float startY;
readonly Ease ease = Ease.InOutSine; [Header("Smoothing")]
public Ease ease = Ease.InOutSine;
[Tooltip("Normal = Update, Late = LateUpdate. Late is often smoother for UI.")]
public UpdateType updateType = UpdateType.Late;
[Tooltip("If true, animation ignores Time.timeScale (keeps moving in pause/slowmo).")]
public bool ignoreTimeScale = true;
private RectTransform _rt;
private Image _img;
private float _centerY;
private DGTween _startupTween;
private DGTween _loopTween;
private void Awake()
{
_rt = GetComponent<RectTransform>();
_img = GetComponent<Image>();
}
private void Start() private void Start()
{ {
startY = GetComponent<RectTransform>().anchoredPosition.y; _centerY = _rt.anchoredPosition.y;
foreach (var alpha in GetComponents<TweenAlpha>()) foreach (var alpha in GetComponents<TweenAlpha>())
if (alpha.label == "Show") {
GetComponent<Image>().color = new Color(1, 1, 1, alpha.to); if (alpha.label == "Show" && _img != null)
_img.color = new Color(1f, 1f, 1f, alpha.to);
}
foreach (var position in GetComponents<TweenPosition>()) foreach (var position in GetComponents<TweenPosition>())
{
if (position.label == "Loop") if (position.label == "Loop")
{ {
range = position.from.y - position.to.y; range = position.from.y - position.to.y;
time = position.duration; time = position.duration;
break;
} }
if (time > 0) }
MoveUp();
if (time > 0f && !Mathf.Approximately(range, 0f))
StartSmoothLoop();
} }
void MoveUp() private void StartSmoothLoop()
{ {
GetComponent<RectTransform>().DOAnchorPosY(startY + range, time).SetEase(ease).OnComplete(() => { MoveDown(); }); KillTweens();
float yMin = _centerY - range;
float yMax = _centerY + range;
float curY = _rt.anchoredPosition.y;
float firstTarget = (Mathf.Abs(curY - yMax) <= Mathf.Abs(curY - yMin)) ? yMax : yMin;
float otherTarget = (firstTarget == yMax) ? yMin : yMax;
float fullDist = Mathf.Abs(yMax - yMin);
float firstDist = Mathf.Abs(curY - firstTarget);
float firstTime = (fullDist > 0.0001f) ? time * (firstDist / fullDist) : 0f;
_startupTween = _rt.DOAnchorPosY(firstTarget, firstTime)
.SetEase(ease)
.SetUpdate(updateType, ignoreTimeScale);
_startupTween.OnComplete(() =>
{
_loopTween = _rt.DOAnchorPosY(otherTarget, time)
.SetEase(ease)
.SetLoops(-1, LoopType.Yoyo)
.SetUpdate(updateType, ignoreTimeScale);
});
}
private void OnDisable()
{
if (_startupTween != null && _startupTween.IsActive()) _startupTween.Pause();
if (_loopTween != null && _loopTween.IsActive()) _loopTween.Pause();
} }
void MoveDown()
private void OnEnable()
{
if (_startupTween != null && _startupTween.IsActive()) _startupTween.Play();
if (_loopTween != null && _loopTween.IsActive()) _loopTween.Play();
}
private void OnDestroy()
{
KillTweens();
}
private void KillTweens()
{ {
GetComponent<RectTransform>().DOAnchorPosY(startY - range, time).SetEase(ease).OnComplete(() => { MoveUp(); }); if (_startupTween != null && _startupTween.IsActive()) _startupTween.Kill();
if (_loopTween != null && _loopTween.IsActive()) _loopTween.Kill();
_startupTween = null;
_loopTween = null;
} }
} }
} }
...@@ -381,6 +381,8 @@ namespace MDPro3.UI ...@@ -381,6 +381,8 @@ namespace MDPro3.UI
//NameAreaGroup.SetActive(condition == Condition.Editable); //NameAreaGroup.SetActive(condition == Condition.Editable);
InputDeckName.gameObject.SetActive(condition == Condition.Editable); InputDeckName.gameObject.SetActive(condition == Condition.Editable);
TextDeckName.gameObject.SetActive(condition != Condition.Editable); TextDeckName.gameObject.SetActive(condition != Condition.Editable);
if (condition == Condition.Pickup)
ButtonDeck.gameObject.SetActive(false);
} }
public RectTransform GetDeckLocationParent(DeckLocation location) public RectTransform GetDeckLocationParent(DeckLocation location)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment