public void SaveSceneToJson()
        {
            SceneSaveData data = new SceneSaveData
            {
                GravConst = SimulationControl.Instance.GravitationalConstant,
                ScaleMlt  = 1f,
                TimeScale = SimulationControl.Instance.TimeScale
            };

            if (Application.isPlaying)
            {
                data.Bodies = new BodySaveData[ActorsManager.Instance.Actors.Count];
                for (int i = 0; i < data.Bodies.Length; i++)
                {
                    data.Bodies[i] = new BodySaveData()
                    {
                        Scale          = ActorsManager.Instance.Actors[i].TransformRef.localScale.x,
                        Position       = ActorsManager.Instance.Actors[i].CelestialBodyRef.Position,
                        Velocity       = ActorsManager.Instance.Actors[i].CelestialBodyRef.Velocity,
                        Mass           = ActorsManager.Instance.Actors[i].CelestialBodyRef.Mass,
                        Name           = ActorsManager.Instance.Actors[i].GameObjectRef.name,
                        IsKeplerMotion = ActorsManager.Instance.Actors[i].CelestialBodyRef.UseKeplerMotion
                    };
                }
            }
            else
            {
                var _bodies = GameObject.FindObjectsOfType <CelestialBody>();
                data.Bodies = new BodySaveData[_bodies.Length];
                for (int i = 0; i < data.Bodies.Length; i++)
                {
                    data.Bodies[i] = new BodySaveData()
                    {
                        Position       = _bodies[i].Position,
                        Velocity       = _bodies[i].Velocity,
                        Mass           = _bodies[i].Mass,
                        Name           = _bodies[i].name,
                        Scale          = _bodies[i].transform.localScale.x,
                        IsKeplerMotion = _bodies[i].UseKeplerMotion
                    };
                }
            }
            string filename = "SavedScene";

            // Not persistence data path, because we can save only in editor.
            string path = Application.dataPath + "/SpaceGravity2D/Demo/JsonData/";
            int    t    = 0;

            while (t < 100 && System.IO.File.Exists(path + filename + ".txt"))
            {
                t++;
                filename = "SavedScene (" + t + ")";
            }
            System.IO.File.WriteAllText(path + filename + ".txt", JsonUtility.ToJson(data, true));
            UnityEditor.AssetDatabase.Refresh();
            Debug.Log("SpaceGravity2D: Objects saved to " + filename);
        }
        public void SaveSceneToJson()
        {
#if UNITY_EDITOR
            SceneSaveData data = new SceneSaveData
            {
                gravConst      = simControl.GravitationalConstant,
                isKeplerMotion = _isKeplerMotion,
                scaleMlt       = 1f,
                timeScale      = simControl.timeScale
            };
            if (Application.isPlaying)
            {
                data.bodies = new BodySaveData[pool.Count];
                for (int i = 0; i < data.bodies.Length; i++)
                {
                    if (!pool[i].isReady)
                    {
                        data.bodies[i] = new BodySaveData()
                        {
                            scale    = pool[i].body.transformRef.localScale.x,
                            position = pool[i].body.position,
                            velocity = pool[i].body.velocity,
                            color    = pool[i].meshRend.material.color,
                            mass     = pool[i].body.mass,
                            name     = pool[i].go.name
                        };
                    }
                }
                data.bodies = data.bodies.Where(b => b != null).ToArray();
            }
            else
            {
                var _bodies = GameObject.FindObjectsOfType <CelestialBody>();
                data.bodies = new BodySaveData[_bodies.Length];
                for (int i = 0; i < data.bodies.Length; i++)
                {
                    if (_bodies[i].gameObject.activeSelf)
                    {
                        var col = _bodies[i].GetComponent <MeshRenderer>() != null ? _bodies[i].GetComponent <MeshRenderer>().sharedMaterial.color : new Color();
                        data.bodies[i] = new BodySaveData()
                        {
                            position = _bodies[i].position,
                            velocity = _bodies[i].velocity,
                            mass     = _bodies[i].mass,
                            name     = _bodies[i].name,
                            scale    = _bodies[i].transform.localScale.x,
                            color    = col
                        };
                    }
                }
                data.bodies = data.bodies.Where(b => b != null).ToArray();
            }
            string filename = "SavedScene";
            string path     = Application.dataPath + "/SpaceGravity2D/Demo/JsonData/";
            int    t        = 0;
            while (t < 100 && System.IO.File.Exists(path + filename + ".txt"))
            {
                t++;
                filename = "SavedScene (" + t + ")";
            }
            System.IO.File.WriteAllText(path + filename + ".txt", JsonUtility.ToJson(data, true));
            UnityEditor.AssetDatabase.Refresh();
            Debug.Log("SpaceGravity2D: Objects saved to " + filename);
#endif
        }