Skip to content

Commit

Permalink
Fix choice button fade out and fade speed
Browse files Browse the repository at this point in the history
  • Loading branch information
drojf committed Jul 31, 2022
1 parent 9c04813 commit 4a4db90
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 0 additions & 1 deletion Assets.Scripts.Core.Buriko/BurikoScriptFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,6 @@ private BurikoVariable OperationSelect()
}
gameSystem.DisplayChoices(stringList, num);
gameSystem.ExecuteActions();
gameSystem.AddWait(new Wait(1f, WaitTypes.WaitForTime, null));
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion Assets.Scripts.Core/GameSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public void CloseChoiceIfExists()
public void LeaveChoices()
{
PopStateStack();
AddWait(new Wait(0.5f, WaitTypes.WaitForTime, delegate
AddWait(new Wait(ChoiceButton.fadeTime, WaitTypes.WaitForTime, delegate
{
ChoiceController.Destroy();
ChoiceController = null;
Expand Down
21 changes: 17 additions & 4 deletions Assets.Scripts.UI.Choice/ChoiceButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public class ChoiceButton : MonoBehaviour

public TextMeshPro ButtonTextMesh;

private float fadeInTime = 0.5f;
public static float fadeTime = .25f;
private float tweenTimer;

// This prevents the user selecting a choice before the choices are fully loaded
private float fadeInTime = fadeTime/2;

private ClickCallback clickCallback;

Expand All @@ -26,7 +30,8 @@ private void FadeToColor(Color c)
{
LeanTween.cancel(base.gameObject);
Color color = ButtonTextMesh.color;
LeanTween.value(base.gameObject, UpdateColor, color, c, fadeInTime);
tweenTimer = fadeTime;
LeanTween.value(base.gameObject, UpdateColor, color, c, tweenTimer);
}

private void OnClick()
Expand All @@ -43,7 +48,7 @@ private void OnClick()

private void OnHover(bool ishover)
{
if (GameSystem.Instance.GameState == GameState.ChoiceScreen)
if (GameSystem.Instance.GameState == GameState.ChoiceScreen && isEnabled)
{
if (ishover)
{
Expand Down Expand Up @@ -82,7 +87,15 @@ private void Start()

private void Update()
{
fadeInTime -= Time.deltaTime;
if(tweenTimer > 0)
{
tweenTimer -= Time.deltaTime;
}

if(fadeInTime > 0)
{
fadeInTime -= Time.deltaTime;
}
}
}
}

0 comments on commit 4a4db90

Please sign in to comment.