ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
SceneSerializer.h
浏览该文件的文档.
1#pragma once
2#include "../Core/Core.h"
3#include <nlohmann/json.hpp>
4
5#include <string>
6#include <vector>
7
8namespace Shit {
9 class Scene;
10
33 public:
36 static nlohmann::json toJson(Scene* scene, const std::vector<std::string>& excludeNames = {});
37
41 static void fromJson(const nlohmann::json& doc, Scene* scene);
42 };
43}
#define SHIT_API
定义 Core.h:14
场景类
定义 Scene.h:34
全场景序列化器 —— .scene 文件的事实标准(v2)
定义 SceneSerializer.h:32
static nlohmann::json toJson(Scene *scene, const std::vector< std::string > &excludeNames={})
序列化整个场景(含层级)为 v2 JSON。被排除的对象(如编辑器相机)不落盘, 其子对象提升为根(parent=-1)。
static void fromJson(const nlohmann::json &doc, Scene *scene)
把 JSON 追加实例化进目标场景(对象 + 组件 + 层级 + 相机兜底)。 调用方负责前置清场(如编辑器"打开"先删旧对象); 实例化失败仅跳过对应对象,不抛异常、不影响已加载部分。
定义 AudioPlayer.h:10