コード例 #1
0
ファイル: SceneLoader.cs プロジェクト: Zexyp/CrossEngine
        public static void Save(string path, Scene scene, SceneFileEnvironment sfe)
        {
            // save all other files
            File.WriteAllText(sfe.AssembliesList, String.Join("\n", AssemblyLoader.LoadedAssemblies.Select(pair => pair.Path)));
            File.WriteAllText(sfe.Scene, SceneSerializer.SertializeJson(scene));

            JsonSerializer serializer = new JsonSerializer(JsonSerializerSettings.Default);

            using (FileStream stream = new FileStream(path, FileMode.Create))
            {
                serializer.Serialize(sfe, stream);
            }

            Log.Core.Info("saved scene");
        }
コード例 #2
0
        public void StartPlaymode()
        {
            EditorApplication.Log.Info("starting playmode");

            string json;

            json = SceneSerializer.SertializeJson(Context.Scene);
            //EditorApplication.Log.Debug($"\n{json}");
            workingScene = Context.Scene;
            ClearContext();

            Context.Scene = SceneSerializer.DeserializeJson(json);

            Context.Scene.Load();
            Context.Scene.Start();

            EditorApplication.Log.Info("playmode started");
        }
コード例 #3
0
        public unsafe override void OnRender()
        {
            Profiler.BeginScope($"{nameof(EditorLayer)}.{nameof(EditorLayer.OnRender)}");

            Renderer.Clear();

            ImGuiLayer.Instance.Begin();

            SetupDockspace();

            DrawModals();

            DrawMainMenuBar();

            ImGui.ShowDemoWindow(); // purely dev thing

            // debug
            ImGui.Begin("Debug");
            if (Context.Scene != null)
            {
                Vector3 gr = (Context.Scene.RigidBodyWorld != null) ? Context.Scene.RigidBodyWorld.Gravity : default;
                if (ImGui.DragFloat3("gravity", ref gr))
                {
                    Context.Scene.RigidBodyWorld.Gravity = gr;
                }
                ImGui.Text("editor camera pos:");
                if (EditorCamera != null)
                {
                    ImGui.Text(EditorCamera.Position.ToString("0.00"));
                }
                ImGui.SliderInt("sleep", ref sleep, 0, 1000);
                if (sleep > 0)
                {
                    System.Threading.Thread.Sleep(sleep);
                }

                // test seri
                if (ImGui.Button("seri test"))
                {
                    string json;
                    json = SceneSerializer.SertializeJson(Context.Scene);
                    Log.App.Debug(json);

                    Context.Scene.Unload();
                    ClearContext();
                    Context.Scene = SceneSerializer.DeserializeJson(json);
                    Context.Scene.Load();
                }
            }
            ImGui.End();


            Profiler.BeginScope($"{nameof(EditorLayer)}.{nameof(EditorLayer.DrawPanels)}");
            DrawPanels();
            Profiler.EndScope();

            EndDockspace();

            ImGuiLayer.Instance.End();

            Profiler.EndScope();
        }