Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        EditorGUILayout.BeginVertical();

        //
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Map Size:", map.mapSize.x + "x" + map.mapSize.y);

        //
        EditorGUILayout.Space();
        EditorGUILayout.LabelField(
            "Map Items:",
            EditorStyle.guiMessageStyle
            );

        //
        var oldItems = map.mapItems;

        itemList.DoLayoutList();
        serializedObject.ApplyModifiedProperties();
        if (oldItems != map.mapItems)
        {
            LoadGemItemSpritesAsCache();
            UpdateCalculations();
            NewBrush();
        }

        if (GUILayout.Button("Save Map Items"))
        {
            FileAccessor.WriteData(map.SaveItems(), "Save Gem Items", ReadPostName() + "_items.txt", "txt");
        }
        if (GUILayout.Button("Load Map Items"))
        {
            map.LoadItems(FileAccessor.ReadTextFromFile("Load Gem Items", "txt"));
        }

        //
        if (map.mapItems.Count == 0)
        {
            EditorGUILayout.HelpBox(
                "You have not selected a texture 2D yet.",
                MessageType.Warning
                );
        }
        else
        {
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Gem Size:", map.itemSize.x + "x" + map.itemSize.y);
            EditorGUILayout.LabelField("Grid Size In Units:", map.gridSize.x + "x" + map.gridSize.y);
            EditorGUILayout.LabelField("Pixels To Units:", map.pixelsToUnits.ToString());
            UpdateBrush(map.currentItemBrush);
        }

        EditorGUILayout.EndVertical();
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        EditorGUILayout.Space();
        level.Name = EditorGUILayout.TextField("Level Name:", level.Name);

        //
        EditorGUILayout.Space();
        level.tileMap = (TileMap)EditorGUILayout.ObjectField("Tile Map: ", level.tileMap, typeof(TileMap), true);

        level.gravityMap = (GravityMap)EditorGUILayout.ObjectField("Gravity Map: ", level.gravityMap, typeof(GravityMap), true);

        level.gemMap = (GemMap)EditorGUILayout.ObjectField("Gem Map: ", level.gemMap, typeof(GemMap), true);

        //
        EditorGUILayout.Space();
        var oldSize = level.mapSize;

        level.mapSize = EditorGUILayout.Vector2Field("Map Size:", level.mapSize);
        if (level.mapSize != oldSize)
        {
            level.tileMap.mapSize
                    = level.gravityMap.mapSize
                    = level.gemMap.mapSize
                    = level.mapSize;
        }

        //
        EditorGUILayout.Space();
        level.moves = EditorGUILayout.IntField("Moves:", level.moves);

        //
        EditorGUILayout.Space();
        var property = serializedObject.FindProperty("gemTypesAvailable");

        serializedObject.Update();
        EditorGUILayout.PropertyField(property, true);
        serializedObject.ApplyModifiedProperties();

        //
        EditorGUILayout.Space();
        property = serializedObject.FindProperty("missions");
        serializedObject.Update();
        EditorGUILayout.PropertyField(property, true);
        serializedObject.ApplyModifiedProperties();

        // if (GUILayout.Button("Clear Gem Map")) {
        //  if (EditorUtility.DisplayDialog(
        //      "Clear map's gems?",
        //      "Are you sure?",
        //      "Clear",
        //      "Do not clear"
        //  )) {
        //      ClearGemMap();
        //  }
        // }

        //
        EditorGUILayout.Space();
        if (GUILayout.Button("Save Level"))
        {
            FileAccessor.WriteData(SaveGemMap(), "Save Level", level.Name + ".json", "json");
        }

        if (GUILayout.Button("Load Level"))
        {
            LoadGemMap(FileAccessor.ReadTextFromFile("Load Level", "json"));
        }
    }