top of page
2021. Pavel Rumayncev. Copying or distribution of the materials outside the website is strictly prohibited.

View-Data separation

1. View-Data separation technique

2. About Data element

3. Introducing 'Capitalist' project

4. Scriptable Objects

5. Developing 'Capitalist' project

6. Lesson takeaways

Key takeaways
  1. It's important to develop skill of identifying data models

  2. Data models need to be implemented as separate elements, classes or scriptable objects

  3. Key responsibilities of data models:

    1. Serve as data containers​

    2. Provide API for modify and initialize the data

    3. Provide events to notify listeners about data change

  4. Unity's ScriptableObjects can be used for implement data models and provide following benefits:​

    1. Change and mock the model's data in Unity Editor​ and Runtime

    2. It's possible to create custom editors for complex data model

  5. It is not necessary to use ScriptableObjects for data models. it's all about convenience and visibility of real data in the Unity inspector

The purpose of view-data separation
  1. Deal with complexity by splitting the logic into two parts - visual and data

  2. Provide global access to the data (Single place to change)

  3. Abstract from visual representation of the data (view can be 2d / 3d / UI/ with complex animations / A2B / etc., but all this aspects aren't related to the data layer)

  4. Allows multiple Views for single data model

  5. Easily add / remove / change Views

  6. Testability - enables writing of automatic unit tests

  7. Facilitate parallel development - art team works on the Views, programmers on data layer

Scriptable Objects

Scriptable Object(SO) is

  1. Data Container

  2. Unity asset

This means that you can store data within it and it's serializable. From Unity's asset database perspective, Scriptable Objects are regular assets, like Textures, Models, Materials etc. The difference between, for example, Texture asset and SO asset is that Texture asset contains array of color data (one element for every single pixel), when SO asset contains data of any serializable type.

Additionally you can implement logic/API for accessing and modifying the data stored in the SO.

Reading materials

Unity manual - Scriptable Objects 

Unity Blog - Making cool stuff with Scriptable Objects 

Paul Rumyancev - UML Class Diagram arrows guide

בשיעור הווידאו הזה אני חושף עקרונות חשובים ומורכבים וטכניקות מתקדמות שבהן משתמשים מקצוענים בכל יום. הבנת החומר עשויה להיות מורכבת עבור ג'וניורים ואפילו עבור מפתחים מנוסים. נדרש ניסיון רב על מנת להתפתח ולהבין באופן מלא. אני ישמח לעזור לכם לא רק להבין, אלא גם להסביר כיצד להשתמש בטכניקות אלה בפועל. זה יסייע לכם להתפתח כמפתחי משחקים מקצועיים.

תזמינו שיעור אישי איתי.


Capitalist game

Project Assets pack


Data Models and Scriptable Objects

Create Data Model and View for Card game

Game Configuration System

Create useful configuration system

שיעורים קשורים

Basics of game architecture

משך השיעור: 01:21:35

C# Internals. Delegates and Events

משך השיעור: 01:48:58

מספר תרגילים: 3

C# abstractions. Abstract classes

משך השיעור: 02:01:24

מספר תרגילים: 3

C# abstractions. Interfaces

משך השיעור: 01:50:39

מספר תרגילים: 3

הזמן שיעור פרטי

אשמח לעזור להבין ולענות על כל שאלה

bottom of page