public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();

        MapEditor t = (MapEditor)target;

        if (t == null)
        {
            return;
        }

        Rect  r;
        float space;

        if (t.loadedMap != null)
        {
            EditorGUILayout.LabelField("Loaded map :");
            EditorGUILayout.LabelField(t.loadedMap.name);
        }
        else
        {
            EditorGUILayout.LabelField("No map is currently loaded");
            EditorGUILayout.LabelField("Click on the \"New\" button to create a new map.");
        }

        // Load / Save
        r     = EditorGUILayout.GetControlRect();
        space = 2;

        if (GUI.Button(new Rect(r.x, r.y, (r.width - space) / 2, r.height), "Load"))
        {
            t.LoadMap();
            EditorGUIUtility.ExitGUI();
        }
        if (GUI.Button(new Rect(r.x + (r.width - space) / 2 + space, r.y, (r.width - space) / 2, r.height), "Save"))
        {
            t.SaveMap();
        }

        // Reload / Reset
        r     = EditorGUILayout.GetControlRect();
        space = 2;

        if (GUI.Button(new Rect(r.x, r.y, (r.width - space) / 2, r.height), "New"))
        {
            t.CreateMap();
            EditorGUIUtility.ExitGUI();
        }
        if (GUI.Button(new Rect(r.x + (r.width - space) / 2 + space, r.y, (r.width - space) / 2, r.height), "Reset"))
        {
            t.CreateMap();
        }
    }
    public IEnumerator CustomSize()
    {
        int width = 13;
        int hight = 12;

        m_mapEditor.CreateMap(width, hight);

        Assert.AreEqual(width, m_map.GetWidth());
        Assert.AreEqual(hight, m_map.GetHight());
        Assert.AreEqual(width * hight, m_map.GetTileCount());

        yield return(new WaitForSeconds(0.1f));

        width = 17;
        hight = 11;

        m_mapEditor.CreateMap(width, hight);

        Assert.AreEqual(width, m_map.GetWidth());
        Assert.AreEqual(hight, m_map.GetHight());
        Assert.AreEqual(width * hight, m_map.GetTileCount());

        yield return(new WaitForSeconds(0.1f));
    }
Beispiel #3
0
    public void CreateMap()
    {
        int mapWidth  = 1;
        int mapHeight = 1;

        if (m_widthField.text != "")
        {
            mapWidth = int.Parse(m_widthField.text);
        }

        if (m_heightField.text != "")
        {
            mapHeight = int.Parse(m_heightField.text);
        }

        m_mapEditor.CreateMap(mapWidth, mapHeight);
    }