Why is my parameter not being registered?

I am trying to use a scriptable object to add some data to a tile in a tilemap. However, when I make a variable (tileDatas) using the scriptable object class (TileData), I am getting an error saying it cannot be found.

using UnityEngine;
using UnityEngine.Tilemaps;
using System;
using System.Collections.Generic;

public class MapTileData : MonoBehaviour
{
    public TileData tileDatas;
    private Dictionary<TileBase, tileDatas> datafromTiles;

    void Start()
    {
        datafromTiles = new Dictionary<TileBase, tileDatas>();
        foreach (TileData tileData in tileDatas)
        {
            foreach (var tile in tileData.tiles)
            {
                datafromTiles.Add(tile, tileData);
            }
        }
    }
}

If it helps, here is the TileData script:

using UnityEngine;
using UnityEngine.Tilemaps;
using System;
using System.Collections.Generic;

[CreateAssetMenu]
public class TileData : ScriptableObject
{
    public TileBase[] tiles;
    public int[] health;
}

I want to take in the TileData scriptable object I have made as a parameter in the monobehaiour script that I can assign to in the object inspector window, does anyone know what is wrong with this?

Please post the exact error message.

Hi all! I’ve solved this now, I was confused between a type and variable when creating a dictionary. The problem was line 9 and 13, where I used tileDatas instead of the class type TileData.

2 Likes

Mr Knot, in the arrow-brackets called ‘generic’ sometimes, you should use only type (I do not even know if reflexion is allowed), but not the name of variables…
My pardon, I did not see your answer. :slight_smile: