示例#1
0
    protected void OnGUI()
    {
        const float padding = 10;

        GUILayout.BeginArea(new Rect(padding, padding, Screen.width - padding - padding, Screen.height - padding - padding));
        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Map File");
        filename = GUILayout.TextField(filename, GUILayout.MinWidth(100));
        #if UNITY_EDITOR
        if (GUILayout.Button("Browse"))
        {
            filename = UnityEditor.EditorUtility.OpenFilePanel("Select Map File", filename, "map");
        }
#endif
        if (GUILayout.Button("Load"))
        {
            var blob = new WorldSerialization();
            Debug.Log("Loading");

            //

            //
            //StringPool


            blob.Load(filename);
            Load(blob);
        }
        if (GUILayout.Button("Save"))
        {
            Terrain            terrain = GameObject.FindGameObjectWithTag("Land").GetComponent <Terrain>();
            Terrain            water   = GameObject.FindGameObjectWithTag("Water").GetComponent <Terrain>();
            WorldSerialization world   = WorldConverter.terrainToWorld(terrain, water);

            Debug.Log("Out: " + world.world.maps.Count);
            Debug.Log("Out: " + world.world.prefabs.Count);
            Debug.Log("Out: " + world.world.paths.Count);

            world.Save(@"C:\Users\Jason\rust test\test.map");
            Debug.Log(world.Checksum);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        //GUILayout.TextArea(result);

        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
示例#2
0
    public void Save(string path)
    {
        if (selectedLandLayer != null)
        {
            selectedLandLayer.save();
        }
        saveTopologyLayer();
        Terrain terrain = GameObject.FindGameObjectWithTag("Land").GetComponent <Terrain>();
        Terrain water   = GameObject.FindGameObjectWithTag("Water").GetComponent <Terrain>();

        if (water == null)
        {
            Debug.LogError("Water object is not enabled");
        }
        if (terrain == null)
        {
            Debug.LogError("Land object is not enabled");
        }

        WorldSerialization world = WorldConverter.terrainToWorld(terrain, water);

        world.Save(path);
        //Debug.Log("Map hash: " + world.Checksum);
    }