Skip to content

Fix credits not appearing in Play Mode #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 30, 2025
Merged

Fix credits not appearing in Play Mode #567

merged 8 commits into from
Apr 30, 2025

Conversation

j9liu
Copy link
Contributor

@j9liu j9liu commented Apr 17, 2025

Fixes #564. Definitely try to break this while testing and find any edge cases. Things I've tested so far:

  • Switching quickly between Play and Edit modes
  • Opening multiple simultaneous scene tabs
  • Switching between Game and Scene views during Play Mode
  • Adding and removing scenes

@j9liu j9liu changed the title Force credit system to recreate entering playmode Fix credits not appearing in Play Mode Apr 17, 2025
@kring kring added this to the May 2025 Release milestone Apr 22, 2025
@kring kring self-requested a review April 28, 2025 20:42
@kring
Copy link
Member

kring commented Apr 29, 2025

Thanks @j9liu, this is much better! I still see one problem where the Cesium ion logo sometimes disappears. I can reproduce it pretty reliably like this:

  1. Open the Samples project (I'm in Unity 2022.3.41f1, but hopefully it doesn't matter)
  2. Open a Cesium level if one isn't already opened. The Cesium ion logo will appear in the Scene view as expected.
  3. Open a different Cesium level. The Cesium ion logo will be missing:
    image
  4. Press play. The Cesium ion logo appears in the Game view.
  5. Stop play. The Cesium ion shows up in the Scene view now, too. (though it may take a couple of seconds to appear)

@j9liu
Copy link
Contributor Author

j9liu commented Apr 29, 2025

Thanks for the catch @kring ... looks like I forgot to test some common cases in favor of the obscure ones 🤪

@j9liu
Copy link
Contributor Author

j9liu commented Apr 29, 2025

For some reason the HandleClosingSceneView was never being called, so I'm moving the editor state management into an Editor-only class with the [InitializeOnLoad] attribute. That results in more reliable behavior.

@j9liu
Copy link
Contributor Author

j9liu commented Apr 29, 2025

@kring ready for another look! If you want to test runtime scene changes as well, I made these modifications to CesiumSampleScene.cs:

    void Update()
    {
#if ENABLE_INPUT_SYSTEM
        bool pressed1 =
            Keyboard.current.digit1Key.wasPressedThisFrame || Keyboard.current.numpad1Key.wasPressedThisFrame;
        bool pressed2 =
            Keyboard.current.digit2Key.wasPressedThisFrame || Keyboard.current.numpad2Key.wasPressedThisFrame;
        bool shiftPressed = Keyboard.current.shiftKey.isPressed;
#else
        bool pressed1 = Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Keypad1);
        bool pressed2 = Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Keypad2);
        bool shiftPressed = Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift);
#endif

        LoadSceneMode mode = shiftPressed ? LoadSceneMode.Additive : LoadSceneMode.Single;
        if (pressed2)// && EditorWindow.focusedWindow == SceneView.lastActiveSceneView)
        {
            SceneManager.LoadScene("02_CesiumMelbourne", mode);
            //ResetSceneView();
        }
        else if (pressed1)
        {
            SceneManager.LoadScene("01_CesiumWorld", mode);
        }
    }

@kring
Copy link
Member

kring commented Apr 30, 2025

Thanks @j9liu!

@kring kring merged commit e610fb5 into main Apr 30, 2025
7 checks passed
@kring kring deleted the fix-play-mode-credits branch April 30, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Credits missing in Play-in-Editor
2 participants