private void Awake() { UnityEngine.Debug.LogWarning("MainMenuPromoPopup::Awake"); this.sprite = base.GetComponentInChildren <UnmanagedSprite>(); this.closeSprite = base.transform.Find("Close").gameObject.GetComponent <Sprite>(); if (AdvertisementHandler.MainMenuPromoRenderable != null) { if (AdvertisementHandler.GetMainMenuPopupTexture() != null) { UnityEngine.Debug.LogWarning("MainMenuPromoPopup::Awake::OnRenderableReady"); this.OnRenderableReady(true); } } else { UnityEngine.Debug.LogWarning("MainMenuPromoPopup::Awake::MainMenuPromoRenderable is NULL"); } Dialog component = base.GetComponent <Dialog>(); if (component != null) { component.onOpen += this.HideObjects; base.GetComponent <Dialog>().onClose += this.HandleClose; } EventManager.Connect(new EventManager.OnEvent <LevelLoadedEvent>(this.OnLevelLoaded)); UnityEngine.Object.DontDestroyOnLoad(this); }
private void OnLevelLoaded(LevelLoadedEvent data) { GameManager.GameState gameState = Singleton <GameManager> .Instance.GetGameState(); if (base.gameObject.activeSelf && (gameState == GameManager.GameState.Level || gameState == GameManager.GameState.Cutscene)) { base.GetComponent <Dialog>().Close(); } else if (!base.gameObject.activeSelf && AdvertisementHandler.GetMainMenuPopupTexture() != null) { this.OnRenderableReady(true); } }
private void OnRenderableReady(bool isReady) { if (!UnityEngine.Application.isPlaying) { return; } if (AdvertisementHandler.MainMenuPromoRenderable == null || !isReady) { return; } UnityEngine.Debug.LogWarning("MainMenuPromoPopup::OnRenderableReady texture set"); this.sprite.GetComponent <Renderer>().sharedMaterial.mainTexture = AdvertisementHandler.GetMainMenuPopupTexture(); if (this.IsAllowedToShow()) { CoroutineRunner.Instance.StartCoroutine(this.DelayShow()); } }