Add automatic Rive asset refresh workflow
This commit is contained in:
@@ -9,6 +9,20 @@ public class MenuFadeIn : MonoBehaviour
|
||||
|
||||
CanvasGroup _group;
|
||||
Coroutine _fadeRoutine;
|
||||
bool _started;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
|
||||
static void ReactivateFadeImages()
|
||||
{
|
||||
var fadeComponents = Resources.FindObjectsOfTypeAll<MenuFadeIn>();
|
||||
foreach (var fadeComponent in fadeComponents)
|
||||
{
|
||||
if (!fadeComponent.gameObject.scene.IsValid())
|
||||
continue;
|
||||
|
||||
fadeComponent.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@@ -16,6 +30,10 @@ public class MenuFadeIn : MonoBehaviour
|
||||
_group = GetComponent<CanvasGroup>();
|
||||
if (_group == null) _group = gameObject.AddComponent<CanvasGroup>();
|
||||
|
||||
var canvas = GetComponentInParent<Canvas>();
|
||||
if (canvas != null)
|
||||
canvas.transform.localScale = Vector3.one;
|
||||
|
||||
_group.alpha = 1f;
|
||||
_group.blocksRaycasts = true;
|
||||
Debug.Log("[MenuFadeIn] Awake - CanvasGroup ensured, alpha=1");
|
||||
@@ -23,14 +41,26 @@ public class MenuFadeIn : MonoBehaviour
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
// Reset state whenever enabled and start the fade
|
||||
if (_group == null) _group = GetComponent<CanvasGroup>() ?? gameObject.AddComponent<CanvasGroup>();
|
||||
|
||||
if (_started)
|
||||
BeginFade();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
_started = true;
|
||||
BeginFade();
|
||||
}
|
||||
|
||||
void BeginFade()
|
||||
{
|
||||
_group.alpha = 1f;
|
||||
_group.blocksRaycasts = true;
|
||||
|
||||
if (_fadeRoutine != null) StopCoroutine(_fadeRoutine);
|
||||
_fadeRoutine = StartCoroutine(Fade());
|
||||
Debug.Log("[MenuFadeIn] OnEnable - starting fade (delay=" + delay + ", duration=" + duration + ")");
|
||||
Debug.Log("[MenuFadeIn] Starting fade (delay=" + delay + ", duration=" + duration + ")");
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
@@ -57,7 +87,6 @@ public class MenuFadeIn : MonoBehaviour
|
||||
|
||||
_group.alpha = 0f;
|
||||
_group.blocksRaycasts = false;
|
||||
Debug.Log("[MenuFadeIn] Fade finished - disabling GameObject");
|
||||
gameObject.SetActive(false);
|
||||
Debug.Log("[MenuFadeIn] Fade finished");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user