Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question [Help] How can I show an exit popup in a specific case?

Discussion in 'WebGL' started by hwk9120, Jul 7, 2023.

  1. hwk9120

    hwk9120

    Joined:
    May 9, 2023
    Posts:
    15
    Hi, I want to show an exit popup by using onbeforeunload like below.

    Code (JavaScript):
    1. <script>
    2.     window.onbeforeunload = function () {
    3.         if (specific case) return "show popup"; // show popup and then close window.
    4.         else return "";  // just close window
    5.     }
    6. </script>
    But the specific case what I want is a global variable(bool) on a C# script (This script is a singleton instance).
    How can I get this C# script variable state in the index.html?
     
  2. hwk9120

    hwk9120

    Joined:
    May 9, 2023
    Posts:
    15