|
@@ -4,6 +4,7 @@ using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using TMPro;
|
|
using Sirenix.OdinInspector;
|
|
using Sirenix.OdinInspector;
|
|
|
|
+using KairoEngine.Core;
|
|
|
|
|
|
namespace KairoEngine.UI.ActivityMessages
|
|
namespace KairoEngine.UI.ActivityMessages
|
|
{
|
|
{
|
|
@@ -29,54 +30,58 @@ namespace KairoEngine.UI.ActivityMessages
|
|
private bool hasFadedIn = false;
|
|
private bool hasFadedIn = false;
|
|
private ActivityMessageController controller;
|
|
private ActivityMessageController controller;
|
|
|
|
|
|
- private void Update()
|
|
|
|
- {
|
|
|
|
- if (fadeIn && !hasFadedIn)
|
|
|
|
- {
|
|
|
|
- fadeCounter += Time.deltaTime;
|
|
|
|
- Color color = textUi.color;
|
|
|
|
- color.a = fadeCounter / fadeTimer;
|
|
|
|
- textUi.color = color;
|
|
|
|
- buttonImage.color = color;
|
|
|
|
- if (fadeCounter >= fadeTimer)
|
|
|
|
- {
|
|
|
|
- fadeCounter = 0f;
|
|
|
|
- hasFadedIn = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (autoHide && hasFadedIn || fadeIn == false)
|
|
|
|
- {
|
|
|
|
- hideCounter += Time.deltaTime;
|
|
|
|
- if(hideCounter >= hideTimer)
|
|
|
|
- {
|
|
|
|
- hideCounter = 0f;
|
|
|
|
- isFading = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (fadeOut && isFading)
|
|
|
|
- {
|
|
|
|
- fadeCounter += Time.deltaTime;
|
|
|
|
- Color color = textUi.color;
|
|
|
|
- color.a = 1f - (fadeCounter / fadeTimer);
|
|
|
|
- textUi.color = color;
|
|
|
|
- buttonImage.color = color;
|
|
|
|
- if (fadeCounter >= fadeTimer)
|
|
|
|
- {
|
|
|
|
- fadeCounter = 0f;
|
|
|
|
- if(controller != null)
|
|
|
|
- {
|
|
|
|
- //controller.messages.Remove(message);
|
|
|
|
- controller.activeMessages.Remove(this);
|
|
|
|
- }
|
|
|
|
- Destroy(this.gameObject);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // private void Update()
|
|
|
|
+ // {
|
|
|
|
+ // if (fadeIn && !hasFadedIn)
|
|
|
|
+ // {
|
|
|
|
+ // fadeCounter += Time.deltaTime;
|
|
|
|
+ // Color color = textUi.color;
|
|
|
|
+ // color.a = fadeCounter / fadeTimer;
|
|
|
|
+ // textUi.color = color;
|
|
|
|
+ // buttonImage.color = color;
|
|
|
|
+ // if (fadeCounter >= fadeTimer)
|
|
|
|
+ // {
|
|
|
|
+ // fadeCounter = 0f;
|
|
|
|
+ // hasFadedIn = true;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // if (autoHide && hasFadedIn || fadeIn == false)
|
|
|
|
+ // {
|
|
|
|
+ // hideCounter += Time.deltaTime;
|
|
|
|
+ // if(hideCounter >= hideTimer)
|
|
|
|
+ // {
|
|
|
|
+ // hideCounter = 0f;
|
|
|
|
+ // isFading = true;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // if (fadeOut && isFading)
|
|
|
|
+ // {
|
|
|
|
+ // fadeCounter += Time.deltaTime;
|
|
|
|
+ // Color color = textUi.color;
|
|
|
|
+ // color.a = 1f - (fadeCounter / fadeTimer);
|
|
|
|
+ // textUi.color = color;
|
|
|
|
+ // buttonImage.color = color;
|
|
|
|
+ // if (fadeCounter >= fadeTimer)
|
|
|
|
+ // {
|
|
|
|
+ // fadeCounter = 0f;
|
|
|
|
+ // if(controller != null)
|
|
|
|
+ // {
|
|
|
|
+ // //controller.messages.Remove(message);
|
|
|
|
+ // controller.activeMessages.Remove(this);
|
|
|
|
+ // }
|
|
|
|
+ // Destroy(this.gameObject);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
|
|
public void OnClick()
|
|
public void OnClick()
|
|
{
|
|
{
|
|
if(message.action != null) message.action();
|
|
if(message.action != null) message.action();
|
|
- if(hideOnClick) isFading = true;
|
|
|
|
|
|
+ if(hideOnClick)
|
|
|
|
+ {
|
|
|
|
+ //isFading = true;
|
|
|
|
+ Remove();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public void Setup(ActivityMessageController controller, ActivityMessage newMessage)
|
|
public void Setup(ActivityMessageController controller, ActivityMessage newMessage)
|
|
@@ -93,13 +98,27 @@ namespace KairoEngine.UI.ActivityMessages
|
|
iconImage.gameObject.SetActive(true);
|
|
iconImage.gameObject.SetActive(true);
|
|
}
|
|
}
|
|
else iconImage.gameObject.SetActive(false);
|
|
else iconImage.gameObject.SetActive(false);
|
|
|
|
+ if(!message.sticky)
|
|
|
|
+ {
|
|
|
|
+ Timer.ExecuteRealTime(message.time * 1000, () => {
|
|
|
|
+ Remove();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- public void Remove(ActivityMessageController controller)
|
|
|
|
|
|
+ public void Remove()
|
|
{
|
|
{
|
|
- this.controller = controller;
|
|
|
|
- autoHide = true;
|
|
|
|
- hideTimer = 0f;
|
|
|
|
|
|
+ controller.RemoveActivityMessageFromList(message);
|
|
|
|
+ if(this == null) return;
|
|
|
|
+ UiAnimator uiAnimator = gameObject.GetComponent<UiAnimator>();
|
|
|
|
+ if(uiAnimator != null)
|
|
|
|
+ {
|
|
|
|
+ uiAnimator.Disable();
|
|
|
|
+ Timer.ExecuteRealTime(uiAnimator.animationTime * 1000, () => {
|
|
|
|
+ if(this != null) Destroy(this.gameObject);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ else if(this != null) Destroy(this.gameObject);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|