- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
[Intended Not A Bug] Unity Demo - Visual Element Reference Breaks Entering Playmode The Second Time.
So I ran into some fun little Serialization fun times apparently. This is intended and honestly easy to avoid once you know what is happening. Links at bottom for people wanting to read it.
So Unity has a hot reload for objects in editor. During a code reload or certain asset database refreshes this can cause the hot reload to happen. Since VisualElementReference is a normal C# class Unity will give it a default value even when private and serialize it during a hot reload or when inspecting it in editor. This can be confusing in some cases when not expected, but is useful in the end.
For example this is used when you tell the inspector to go into debug mode and it will show non public values. You can than see the private variables, but to prevent an error during the proces of showing inspector field values for normal classes they give private base C# classes as in ones that don't inherit from Unity's Object, a default value to prevent null errors in editor.
There are other cases as well that are useful for editor code.
You can have private values be saved and used in custom editors/inspectors. Think conditional showing of certain fields if a certain value like a bool is set to false.
Link to Hot Reload documentation. Keypart here is the last sentence in the section talking about the editor serializing private fields by default during reloading.
https://docs.unity3d.com/6000.6/Documentation/Manual/AssetDatabaseRefreshing.html#hotreloading
Видео [Intended Not A Bug] Unity Demo - Visual Element Reference Breaks Entering Playmode The Second Time. канала Shatter Fantasy
So Unity has a hot reload for objects in editor. During a code reload or certain asset database refreshes this can cause the hot reload to happen. Since VisualElementReference is a normal C# class Unity will give it a default value even when private and serialize it during a hot reload or when inspecting it in editor. This can be confusing in some cases when not expected, but is useful in the end.
For example this is used when you tell the inspector to go into debug mode and it will show non public values. You can than see the private variables, but to prevent an error during the proces of showing inspector field values for normal classes they give private base C# classes as in ones that don't inherit from Unity's Object, a default value to prevent null errors in editor.
There are other cases as well that are useful for editor code.
You can have private values be saved and used in custom editors/inspectors. Think conditional showing of certain fields if a certain value like a bool is set to false.
Link to Hot Reload documentation. Keypart here is the last sentence in the section talking about the editor serializing private fields by default during reloading.
https://docs.unity3d.com/6000.6/Documentation/Manual/AssetDatabaseRefreshing.html#hotreloading
Видео [Intended Not A Bug] Unity Demo - Visual Element Reference Breaks Entering Playmode The Second Time. канала Shatter Fantasy
Комментарии отсутствуют
Информация о видео
2 июня 2026 г. 19:55:23
00:03:11
Другие видео канала
