Unity 6.3
0 онлайн 88 гостей 3 в системе
Вход
Модульная игровая архитектура на ScriptableObjects Глава 10 из 12 Оригинал, стр. 70

Знакомство с примером проекта

Explore the sample project

Accompanying this guide is a sample project for you to work with and learn about ScriptableObjects. Inspired by classic ball and paddle game mechanics, this project is a great opportunity to see how ScriptableObjects can improve the architecture of your Unity project. By following SOLID principles and using techniques often employed in larger projects, you can demonstrate how ScriptableObjects can help to restructure your code.

The sample project

Here, you will have the chance to see how ScriptableObjects can be applied, and gain a better understanding of how they can be used to improve the efficiency and organization of your projects. The sample includes many of the patterns explored in this guide: —

Data containers: Shared settings data is extracted as ScriptableObjects. Then, gameplay settings or common states are stored as assets in the project. Also, you can change the initial level layout by swapping ScriptableObjects.

Extendable enums: Empty ScriptableObjects function as enums to categorize different players.

Delegate objects: A simple audio delegate shows how you can randomize the ball’s collision sounds just by swapping ScriptableObjects. Objectives are also ScriptableObjects that plug into the game management system for determining win-lose conditions.

Event channels: The observer pattern helps you set up game events for UI, sounds, and scoring. Different GameObjects can subscribe to different “event channels,” similar to tuning in to a specific radio broadcast.

Dual serialization: Some game data is stored like the level layout in ScriptableObjects for ease of use in the Editor but with the option to save it as JSON files. Externally modded JSON data can then rebuild a ScriptableObject, which works with the original setup script.

Of course, the game itself is not the main focus of this sample. A paddle-and-ball arcade game can be built with far fewer lines of code. Instead, the idea with the sample project is to demonstrate how ScriptableObjects can help you create components that are testable and scalable, while still being designer-friendly.