public static GameObjectSurrogate getInstance()
        {
            if (instance == null)
            {
                GameObject gameObject = new GameObject("AndroidScreenBarsSurrogate");
                instance = gameObject.AddComponent <GameObjectSurrogate>();
            }

            return(instance);
        }
示例#2
0
 private static GameObjectSurrogate getGameObject()
 {
     if (surrogate == null)
     {
         // We create a GameObject so we can run end-of-frame updates for flags (see queueFlagUpdates() for details)
         GameObject surrogateObject = new GameObject("AndroidScreenBarsSurrogate");
         surrogate = surrogateObject.AddComponent <GameObjectSurrogate>();
     }
     return(surrogate);
 }
示例#3
0
 private static void initializeFocusControl()
 {
     // In addition to queueing actual flag setting, we want to save a separate copy of the flag values
     // every time focus is lost, and restore them once the application gains focus again, so we add
     // events to handle that. This needs to be done because Unity itself overwrites all flags (likely
     // to enforce the behavior expected by System.fullScreen's current value).
     if (!focusControlInitialized)
     {
         saveCurrentFlags();
         GameObjectSurrogate.getInstance().onGainedFocus += restoreCurrentFlags;
         GameObjectSurrogate.getInstance().onLostFocus   += saveCurrentFlags;
         focusControlInitialized = true;
     }
 }
示例#4
0
 private static void queueFlagUpdates()
 {
     // We perform View.* and Window.* flag updates in a pretty roundabout way:
     // we call a coroutine at the end of the current frame, which then asks Android to run
     // some code on the UI thread.
     // This potentially adds a frame of delay to screen bar updates, but is done because:
     // * we can successive calls to setViewFlag()/setWindowFlag() to stack correctly,
     //   without transient flag states that can be reverted by the OS (plus, we want
     //   getViewFlags() and getWindowFlags() to return the correct flag status, even
     //   if unset)
     // * view flags can only be set on Android's UI thread
     if (!hasQueuedFlagUpdates)
     {
         hasQueuedFlagUpdates = true;
         initializeFocusControl();
         GameObjectSurrogate.getInstance().StartCoroutine(performFlagUpdatesOnUiThread());
     }
 }