Exemplo n.º 1
0
        public static Scene Load(string path)
        {
            SceneFileEnvironment sfe;

            JsonSerializer serializer = new JsonSerializer(JsonSerializerSettings.Default);

            using (FileStream stream = new FileStream(path, FileMode.Open))
            {
                sfe = (SceneFileEnvironment)serializer.Deserialize(stream, typeof(SceneFileEnvironment));
            }

            string directory = Path.GetDirectoryName(path);

            {
                string[] assembliesPaths = Array.ConvertAll(File.ReadAllText(directory + sfe.AssembliesList)
                                                            .Trim('\n', ' ').Split("\n"),
                                                            str => str.Trim(' '))
                                           .Where(str => !string.IsNullOrWhiteSpace(str))
                                           .ToArray();
                for (int i = 0; i < assembliesPaths.Length; i++)
                {
                    AssemblyLoader.Load(assembliesPaths[i]);
                }
            }

            Scene scene;

            {
                scene = SceneSerializer.DeserializeJson(File.ReadAllText(directory + sfe.Scene));
            }

            Log.Core.Info("loaded scene");

            return(scene);
        }
Exemplo n.º 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");
        }
Exemplo n.º 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();
        }