У нас вы можете посмотреть бесплатно How to Read Large JSON Files in Unity Without Hanging the Game или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
Discover effective techniques to load large JSON files in Unity without causing performance issues. Learn to enhance user feedback and reduce loading times! --- This video is based on the question https://stackoverflow.com/q/66390894/ asked by the user 'Vaggelis Stamkopoulos' ( https://stackoverflow.com/u/14998842/ ) and on the answer https://stackoverflow.com/a/66398207/ provided by the user 'derHugo' ( https://stackoverflow.com/u/7111561/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions. Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: Reading large JSON file without hanging in Unity Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l... The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license. If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com. --- Reading Large JSON Files in Unity Without Hanging the Game If you're developing a mobile game in Unity that requires loading large datasets, such as a 4D integer array from a JSON file, you might run into performance issues, particularly lengthy load times that potentially freeze the game. This problem can disrupt the user experience, as players may not receive any feedback while waiting for the data to load. In this guide, we will explore a solution that allows you to load large JSON files without hanging your game, ensuring a smoother experience for your users. The Problem Imagine you're working on a mobile game that loads a significant amount of data—about 17MB for an array structure, in JSON format. You may have used SimpleJSON for parsing, but as you noticed, using it caused the game to hang for up to 30 seconds. This delay not only frustrates players but also affects perceived performance. Here's a quick summary of your current approach: You load the JSON file using TextAsset. You parse the file content using SimpleJSON. The heavy lifting happens on the main thread, leading to unresponsive gameplay during those 30 seconds. Proposed Solution The key to resolving this issue lies in offloading the JSON parsing work from the main thread to a background thread while keeping user feedback active. Using C# Threads Step 1: Set Up Your Coroutine Start by creating a coroutine that will act as your file loading mechanism. Here's a revised version of your original coroutine: [[See Video to Reveal this Text or Code Snippet]] Step 2: The Background Loading Function Create a method to handle JSON parsing in another thread. The following loading method will be invoked on a separate thread while keeping the main thread responsive. [[See Video to Reveal this Text or Code Snippet]] Conclusion By utilizing multi-threading techniques in C# , you can significantly enhance user experience when loading large JSON files in Unity. This approach allows you to keep the game responsive while parsing the data in the background. Key Takeaways Use C# threads to handle intensive operations. Keep user feedback mechanisms like sliders active for better user experience. Ensure thread safety with ConcurrentQueue for main thread interaction. By following these steps, your game can load large datasets efficiently, providing users with both the data they need and an enjoyable experience.