public static void Terminate(bool isPlayMode)
 {
     FirebaseEditorDispatcher.ListenToPlayState(false);
     if (!isPlayMode)
     {
         FirebaseEditorDispatcher.StopEditorUpdate();
     }
 }
 internal static void Terminate()
 {
     if (FirebaseHandler.firebaseHandler != null)
     {
         FirebaseEditorDispatcher.Terminate(FirebaseHandler.firebaseHandler.IsPlayMode);
         FirebaseHandler.firebaseHandler.StopMonoBehaviour();
     }
     FirebaseHandler.firebaseHandler = null;
 }
        public static void StopEditorUpdate()
        {
            Type editorApplicationType = FirebaseEditorDispatcher.EditorApplicationType;

            if (editorApplicationType != null)
            {
                FieldInfo field = editorApplicationType.GetField("update");
                if (FirebaseEditorDispatcher.< > f__mg$cache1 == null)
                {
                    FirebaseEditorDispatcher.< > f__mg$cache1 = new Action(FirebaseEditorDispatcher.Update);
                }
                FirebaseEditorDispatcher.AddRemoveCallbackToField(field, FirebaseEditorDispatcher.< > f__mg$cache1, null, false, null);
            }
        }
        public static void StartEditorUpdate()
        {
            Type editorApplicationType = FirebaseEditorDispatcher.EditorApplicationType;

            if (editorApplicationType != null)
            {
                FieldInfo field = editorApplicationType.GetField("update");
                if (FirebaseEditorDispatcher.< > f__mg$cache0 == null)
                {
                    FirebaseEditorDispatcher.< > f__mg$cache0 = new Action(FirebaseEditorDispatcher.Update);
                }
                FirebaseEditorDispatcher.AddRemoveCallbackToField(field, FirebaseEditorDispatcher.< > f__mg$cache0, null, true, "Firebase failed to register for editor update calls. Most Firebase features will fail, as callbacks will notwork properly. This is caused by being unable to resolvethe necessary fields from the UnityEditor.dll.");
            }
        }
 private static void PlayModeStateChanged()
 {
     if (!FirebaseHandler.DefaultInstance.IsPlayMode && FirebaseEditorDispatcher.EditorIsPlaying)
     {
         FirebaseEditorDispatcher.StopEditorUpdate();
         FirebaseHandler.DefaultInstance.StartMonoBehaviour();
         FirebaseHandler.DefaultInstance.IsPlayMode = true;
     }
     else if (FirebaseHandler.DefaultInstance.IsPlayMode && !FirebaseEditorDispatcher.EditorIsPlayingOrWillChangePlaymode)
     {
         FirebaseHandler.DefaultInstance.StopMonoBehaviour();
         FirebaseEditorDispatcher.StartEditorUpdate();
         FirebaseHandler.DefaultInstance.IsPlayMode = false;
     }
 }
 private FirebaseHandler()
 {
     if (Application.isEditor)
     {
         this.IsPlayMode = FirebaseEditorDispatcher.EditorIsPlaying;
         FirebaseEditorDispatcher.ListenToPlayState(true);
     }
     else
     {
         this.IsPlayMode = true;
     }
     if (this.IsPlayMode)
     {
         this.StartMonoBehaviour();
     }
     else
     {
         FirebaseEditorDispatcher.StartEditorUpdate();
     }
 }
        public static void ListenToPlayState(bool start = true)
        {
            Type editorApplicationType = FirebaseEditorDispatcher.EditorApplicationType;

            if (editorApplicationType != null)
            {
                EventInfo @event = editorApplicationType.GetEvent("playModeStateChanged");
                if (@event != null)
                {
                    Type type = Type.GetType("UnityEditor.PlayModeStateChange, UnityEditor");
                    if (type != null)
                    {
                        MethodInfo methodInfo = typeof(FirebaseEditorDispatcher).GetMethod("PlayModeStateChangedWithArg", BindingFlags.Static | BindingFlags.NonPublic);
                        methodInfo = methodInfo.MakeGenericMethod(new Type[]
                        {
                            type
                        });
                        Delegate handler = Delegate.CreateDelegate(@event.EventHandlerType, null, methodInfo);
                        if (start)
                        {
                            @event.AddEventHandler(null, handler);
                        }
                        else
                        {
                            @event.RemoveEventHandler(null, handler);
                        }
                        return;
                    }
                }
                FieldInfo field = editorApplicationType.GetField("playmodeStateChanged");
                if (FirebaseEditorDispatcher.< > f__mg$cache2 == null)
                {
                    FirebaseEditorDispatcher.< > f__mg$cache2 = new Action(FirebaseEditorDispatcher.PlayModeStateChanged);
                }
                Action callback = FirebaseEditorDispatcher.< > f__mg$cache2;
                FirebaseEditorDispatcher.AddRemoveCallbackToField(field, callback, null, start, null);
            }
        }
 private static void PlayModeStateChangedWithArg <T>(T t)
 {
     FirebaseEditorDispatcher.PlayModeStateChanged();
 }