C# List with multiple variables

I have this list which contains values for each property in the game. But when i add a value and try to access it it says “Object reference not set to an instance of an object”.
This is not the whole code but i have something like 800 lines of code that is irrelevant so i added only the important parts. I have another script that adds Properties to player with playerprefs. I am really lost right now don’t know whats wrong

    public string propertiesName { get; set; }
    public int propertiesPrice { get; set; }
    public string propertiesAddress { get; set; }
    public int propertiesAge { get; set; }
    public int propertiesRooms { get; set; }
    public int propertiesBathrooms { get; set; }
    public string propertiesLocation { get; set; }
    public int propertiesMonthlyExpense { get; set; }
    public int propertiesCondition { get; set; }

    int propertiesAmount = 0;

    public PropertiesSc(string propertiesNameX, int propertiesPriceX, string propertiesAddressX, int propertiesAgeX, int propertiesRoomsX, int propertiesBathroomsX, string propertiesLocationX, int propertiesMonthlyExpenseX, int propertiesConditionX)
    {
        propertiesName = propertiesNameX;
        propertiesPrice = propertiesPriceX;
        propertiesAddress = propertiesAddressX;
        propertiesAge = propertiesAgeX;
        propertiesRooms = propertiesRoomsX;
        propertiesBathrooms = propertiesBathroomsX;
        propertiesLocation = propertiesLocationX;
        propertiesMonthlyExpense = propertiesMonthlyExpenseX;
        propertiesCondition = propertiesConditionX;
    }

    public void SetAssetsProperties()
    {
        isPropertyAssetActive = true;
        propertiesAmount = PlayerPrefs.GetInt("PropertiesAmount");
        for (int i = 0; i < propertiesAmount; i++)
        {
            string name = PlayerPrefs.GetString("Property" +  (i+1).ToString() + "Name");
            int price = PlayerPrefs.GetInt("Property" +  (i+1).ToString() + "Price");
            string address = PlayerPrefs.GetString("Property" +  (i+1).ToString() + "Address");
            int age = PlayerPrefs.GetInt("Property" +  (i+1).ToString() + "Age");
            int rooms = PlayerPrefs.GetInt("Property" +  (i+1).ToString() + "Rooms");
            int bathrooms = PlayerPrefs.GetInt("Property" + (i+1).ToString() + "Bathrooms");
            string location = PlayerPrefs.GetString("Property" + (i+1).ToString() + "Location");
            int monthlyExpense = PlayerPrefs.GetInt("Property" +  (i+1).ToString() + "MonthlyExpense");
            int condition = PlayerPrefs.GetInt("Property" +  (i+1).ToString() + "Condition");
            PlayerPrefs.SetInt("Property" + (i+1).ToString() + "Number", i);
            var propertyInfo = new PropertiesSc(name, price, address, age, rooms, bathrooms, location, monthlyExpense, condition);
            propertiesList.Add(propertyInfo);
        }
    }

    public void SetPlayerPrefsProperties()
    {
        PlayerPrefs.SetInt("PropertiesAmount", propertiesAmount);
        for (int i = 0; i < propertiesAmount; i++)
        {
            PlayerPrefs.SetString("Property" +  (i+1).ToString() + "Name", propertiesList[i].propertiesName);
            PlayerPrefs.SetInt("Property" +  (i+1).ToString() + "Price", propertiesList[i].propertiesPrice);
            PlayerPrefs.SetString("Property" +  (i+1).ToString() + "Address", propertiesList[i].propertiesAddress);
            PlayerPrefs.SetInt("Property" +  (i+1).ToString() + "Age", propertiesList[i].propertiesAge);
            PlayerPrefs.SetInt("Property" +  (i+1).ToString() + "Rooms", propertiesList[i].propertiesRooms);
            PlayerPrefs.SetInt("Property" + (i+1).ToString() + "Bathrooms", propertiesList[i].propertiesBathrooms);
            PlayerPrefs.SetString("Property" + (i+1).ToString() + "Location", propertiesList[i].propertiesLocation);
            PlayerPrefs.SetInt("Property" +  (i+1).ToString() + "MonthlyExpense", propertiesList[i].propertiesMonthlyExpense);
            PlayerPrefs.SetInt("Property" +  (i+1).ToString() + "Condition", propertiesList[i].propertiesCondition);
        }
    }

Please show the definition and declaration of propertiesList. It would also help a lot if you told us which line produces the error.

this is all, i only have another script that sets the playerprefs. Error is in the line 54

List<PropertiesSc> propertiesList = new List<PropertiesSc>();

You really shoul show all relevant code, as it’s hard to piece together the info when you are hiding it. What is the definition of PropertiesSc? In any event, it looks like propertiesList isn’t initialized or contains a null entry. Log i when you access it so you know which entries are iterated successfully, and which dont.

Here is the full code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class PropertiesSc : MonoBehaviour
{
    public string propertiesName { get; set; }
    public int propertiesPrice { get; set; }
    public string propertiesAddress { get; set; }
    public int propertiesAge { get; set; }
    public int propertiesRooms { get; set; }
    public int propertiesBathrooms { get; set; }
    public string propertiesLocation { get; set; }
    public int propertiesMonthlyExpense { get; set; }
    public int propertiesCondition { get; set; }
    public int propertiesAmount;

    textbox tbscript;
    AssetsAndShopping assetsScript;
    [SerializeField] GameObject propertyInfoObject;
    [SerializeField] GameObject propertiesPrefab;

    [SerializeField] GameObject propertyParent;

    //TextArea
    [SerializeField] TextMeshProUGUI propertyHeaderText;
    [SerializeField] TextMeshProUGUI propertySizeText;
    [SerializeField] TextMeshProUGUI propertyWorthText;
    [SerializeField] TextMeshProUGUI propertyAgeText;
    [SerializeField] TextMeshProUGUI propertyLocationText;
    [SerializeField] TextMeshProUGUI propertyMonthlyExpensesText;
    [SerializeField] TextMeshProUGUI propertyConditionText;

    //Buttons
    [SerializeField] GameObject sellButton;
    [SerializeField] GameObject renovateButton;
    [SerializeField] GameObject partyButton;

    [SerializeField] GameObject propertyAuctionObject;
    [SerializeField] GameObject areYouSureParty;
    [SerializeField] TextMeshProUGUI partyPropertyText;

    [SerializeField] TextMeshProUGUI auctionTimerText;
    [SerializeField] TextMeshProUGUI auctionCurrentBidText;

    [SerializeField] Button acceptButton;
    [SerializeField] Button rejectButton;

    [SerializeField] GameObject propertyRenovateAreYouSure;

    [SerializeField] TextMeshProUGUI propertyRenewalPriceText;

    [SerializeField] GameObject noPropertyObject;

    //bools
    bool isPropertyAssetActive = false;

    public PropertiesSc(string propertiesNameX, int propertiesPriceX, string propertiesAddressX, int propertiesAgeX, int propertiesRoomsX, int propertiesBathroomsX, string propertiesLocationX, int propertiesMonthlyExpenseX, int propertiesConditionX)
    {
        propertiesName = propertiesNameX;
        propertiesPrice = propertiesPriceX;
        propertiesAddress = propertiesAddressX;
        propertiesAge = propertiesAgeX;
        propertiesRooms = propertiesRoomsX;
        propertiesBathrooms = propertiesBathroomsX;
        propertiesLocation = propertiesLocationX;
        propertiesMonthlyExpense = propertiesMonthlyExpenseX;
        propertiesCondition = propertiesConditionX;
    }

    List<PropertiesSc> propertiesList = new List<PropertiesSc>();
    // Start is called before the first frame update
    void Start()
    {
        tbscript = FindObjectOfType<textbox>();
        assetsScript = FindObjectOfType<AssetsAndShopping>();
    }

    public void ClosePropAssets()
    {
        isPropertyAssetActive = false;
    }
    public void SetAssetsProperties()
    {
        isPropertyAssetActive = true;
        propertiesAmount = PlayerPrefs.GetInt("PropertiesAmount");
        for (int i = 0; i < propertiesAmount; i++)
        {
            string name = PlayerPrefs.GetString("Property" +  (i+1).ToString() + "Name");
            int price = PlayerPrefs.GetInt("Property" +  (i+1).ToString() + "Price");
            string address = PlayerPrefs.GetString("Property" +  (i+1).ToString() + "Address");
            int age = PlayerPrefs.GetInt("Property" +  (i+1).ToString() + "Age");
            int rooms = PlayerPrefs.GetInt("Property" +  (i+1).ToString() + "Rooms");
            int bathrooms = PlayerPrefs.GetInt("Property" + (i+1).ToString() + "Bathrooms");
            string location = PlayerPrefs.GetString("Property" + (i+1).ToString() + "Location");
            int monthlyExpense = PlayerPrefs.GetInt("Property" +  (i+1).ToString() + "MonthlyExpense");
            int condition = PlayerPrefs.GetInt("Property" +  (i+1).ToString() + "Condition");
            PlayerPrefs.SetInt("Property" + (i+1).ToString() + "Number", i);
            var propertyInfo = new PropertiesSc(name, price, address, age, rooms, bathrooms, location, monthlyExpense, condition);
            propertiesList.Add(propertyInfo);
        }
    }

    public void SetPlayerPrefsProperties()
    {
        PlayerPrefs.SetInt("PropertiesAmount", propertiesAmount);
        for (int i = 0; i < propertiesAmount; i++)
        {
            PlayerPrefs.SetString("Property" +  (i+1).ToString() + "Name", propertiesList[i].propertiesName);
            PlayerPrefs.SetInt("Property" +  (i+1).ToString() + "Price", propertiesList[i].propertiesPrice);
            PlayerPrefs.SetString("Property" +  (i+1).ToString() + "Address", propertiesList[i].propertiesAddress);
            PlayerPrefs.SetInt("Property" +  (i+1).ToString() + "Age", propertiesList[i].propertiesAge);
            PlayerPrefs.SetInt("Property" +  (i+1).ToString() + "Rooms", propertiesList[i].propertiesRooms);
            PlayerPrefs.SetInt("Property" + (i+1).ToString() + "Bathrooms", propertiesList[i].propertiesBathrooms);
            PlayerPrefs.SetString("Property" + (i+1).ToString() + "Location", propertiesList[i].propertiesLocation);
            PlayerPrefs.SetInt("Property" +  (i+1).ToString() + "MonthlyExpense", propertiesList[i].propertiesMonthlyExpense);
            PlayerPrefs.SetInt("Property" +  (i+1).ToString() + "Condition", propertiesList[i].propertiesCondition);
        }
    }

    public void PlaceProperties()
    {
        int locationObj = 37;
        for (int i = 0; i < propertiesAmount; i++)
        {
            GameObject propertyObject = Instantiate(propertiesPrefab, new Vector3(0,locationObj,0), Quaternion.identity);
            locationObj -= 110;
            propertyObject.transform.SetParent(propertyParent.transform, false);
            var objectTransform = propertyObject.transform;
            var header = objectTransform.GetChild(0);
            var textUnder = objectTransform.GetChild(1);
            var button = objectTransform.GetChild(2);
            TextMeshProUGUI headerText = header.GetComponent<TextMeshProUGUI>();
            TextMeshProUGUI textUnderText = textUnder.GetComponent<TextMeshProUGUI>();
            textUnderText.text = "$" + propertiesList[i].propertiesPrice.ToString();
            headerText.text = propertiesList[i].propertiesName + " (" + propertiesList[i].propertiesAddress + ")";
            button.name = "Property" + (i+1).ToString();
            PlayerPrefs.SetInt("Property" + (i+1).ToString() + "Number", i+1);
            Button buttonObj = button.GetComponent<Button>();
            buttonObj.onClick.AddListener(OnClickProperty);
        }
    }

    public void NoProperty()
    {
        if (propertiesAmount == 0)
        {
            noPropertyObject.SetActive(true);
        }
        else
        {
            noPropertyObject.SetActive(false);
        }
    }

    public void OnClickProperty()
    {
        var go = EventSystem.current.currentSelectedGameObject;
        string name = go.name;
        propertyHeaderText.text = PlayerPrefs.GetString(name + "Name") + " (" + PlayerPrefs.GetString(name + "Address") + ")";
        propertySizeText.text = "Size: " + PlayerPrefs.GetInt(name + "Rooms").ToString() + "br/" + PlayerPrefs.GetInt(name + "Bathrooms").ToString() + "ba";
        propertyWorthText.text = "Worth: $" + PlayerPrefs.GetInt(name + "Price");
        propertyAgeText.text = "Age: " + PlayerPrefs.GetInt(name + "Age") + " Years";
        propertyLocationText.text = "Location: " + PlayerPrefs.GetString(name + "Location");
        propertyMonthlyExpensesText.text = "Monthly Expenses: " + PlayerPrefs.GetInt(name + "MonthlyExpense") + "$";
        if (PlayerPrefs.GetInt(name + "Condition") >= 0 && PlayerPrefs.GetInt(name + "Condition") <= 20)
        {
            propertyConditionText.text = "Condition: Very Poor";
        }
        else if (PlayerPrefs.GetInt(name+ "Condition") >= 21 && PlayerPrefs.GetInt(name + "Condition") <= 40)
        {
            propertyConditionText.text = "Condition: Poor";
        }
        else if (PlayerPrefs.GetInt(name+ "Condition") >= 41 && PlayerPrefs.GetInt(name + "Condition") <= 60)
        {
            propertyConditionText.text = "Condition: Fair";
        }
        else if (PlayerPrefs.GetInt(name+ "Condition") >= 61 && PlayerPrefs.GetInt(name + "Condition") <= 80)
        {
            propertyConditionText.text = "Condition: Good";
        }
        else if (PlayerPrefs.GetInt(name+ "Condition") >= 81 && PlayerPrefs.GetInt(name + "Condition") <= 100)
        {
            propertyConditionText.text = "Condition: Very Good";
        }
        partyButton.name = name;
        renovateButton.name = name;
        sellButton.name = name;
    }

    public void OnClickParty()
    {
        var go = EventSystem.current.currentSelectedGameObject;
        int rooms = PlayerPrefs.GetInt(go.name + "Rooms");
        int bathrooms = PlayerPrefs.GetInt(go.name + "Bathrooms");
        PlayerPrefs.SetString("HouseType", PlayerPrefs.GetString(go.name + "Name").ToLower());
        int size = rooms + bathrooms;
        SetPartyMood();
        SetPartySize(size);
        partyPropertyText.text = PlayerPrefs.GetString(go.name + "Name");
        areYouSureParty.SetActive(true);
        propertyInfoObject.SetActive(false);
    }

    public void OnClickYes()
    {
        isPropertyAssetActive = false;
        tbscript.ThrowParty();
        areYouSureParty.SetActive(false);
        assetsScript.CloseAll();
    }

    private static void SetPartySize(int size)
    {
        if (size > 0 && size <= 2)
        {
            int partySize = Random.Range(5, 20);
            PlayerPrefs.SetInt("PartySize", partySize);
        }
        else if (size > 2 && size <= 5)
        {
            int partySize = Random.Range(10, 30);
            PlayerPrefs.SetInt("PartySize", partySize);
        }
        else if (size > 5 && size <= 10)
        {
            int partySize = Random.Range(20, 50);
            PlayerPrefs.SetInt("PartySize", partySize);
        }
        else if (size > 10)
        {
            int partySize = Random.Range(40, 100);
            PlayerPrefs.SetInt("PartySize", partySize);
        }
    }

    public void SetPartyMood()
    {
        int i = Random.Range(0,3);
        if (i == 0)
        {
            PlayerPrefs.SetString("PartyMood", "It was a boring party.");
        }
        else if (i == 1)
        {
            PlayerPrefs.SetString("PartyMood", "It was a decent party.");
        }
        else if (i == 2)
        {
            PlayerPrefs.SetString("PartyMood", "It was a great party.");
        }
    }

    public void OnClickSell()
    {
        var go = EventSystem.current.currentSelectedGameObject;
        PlayerPrefs.SetInt("LastPropNumber", PlayerPrefs.GetInt(go.name + "Number"));
        int condition = PlayerPrefs.GetInt(go.name + "Condition");
        PlayerPrefs.SetInt("LastPropertyWorth", PlayerPrefs.GetInt(go.name + "Price"));
        PlayerPrefs.SetString("LastPropertyCondition", propertyConditionText.text);
        int currentPrice = Mathf.RoundToInt(PlayerPrefs.GetInt(go.name + "Price") * 0.01f * Random.Range(8,11)) * 10;
        propertyAuctionObject.SetActive(true);
        propertyInfoObject.SetActive(false);
        StartCoroutine(PropertyAuctionTimer(currentPrice, condition));
        acceptButton.interactable = false;
        rejectButton.interactable = false;
    }

   
    public void NewBid(int currentPrice, int condition)
    {
        int newPrice = Mathf.RoundToInt(currentPrice / 1000) * 10 * Random.Range(2,11);
        currentPrice = newPrice;
        auctionCurrentBidText.text = "Current Bid: $" + currentPrice.ToString();
        StartCoroutine(PropertyAuctionTimer(currentPrice, condition));
    }

    public void SoldAuction(int currentPrice)
    {
        auctionTimerText.text = "Final Bid";
        PlayerPrefs.SetInt("PropertyLastBid", currentPrice);
        acceptButton.interactable = true;
        rejectButton.interactable = true;
    }

    public void AcceptBid()
    {
        PlayerPrefs.SetInt("Money", PlayerPrefs.GetInt("Money") + PlayerPrefs.GetInt("PropertyLastBid"));
        PlayerPrefs.SetString("SoldPropertyName", propertiesList[PlayerPrefs.GetInt("LastPropNumber")].propertiesName);
        PlayerPrefs.SetString("SoldPropertyAddress", propertiesList[PlayerPrefs.GetInt("LastPropNumber")].propertiesAddress);
        var list = propertiesList[PlayerPrefs.GetInt("LastPropNumber")];
        propertiesAmount -= 1;
        isPropertyAssetActive = false;
        propertiesList.Remove(list);
        tbscript.SellProperty();
        propertyAuctionObject.SetActive(false);
        assetsScript.CloseAll();
    }

    IEnumerator PropertyAuctionTimer(int currentPrice, int condition)
    {
        int i = 3;
        for (int t = 0; t < 3; t --)
        {
            if (i > 1)
            {
                yield return new WaitForSeconds(1f);
                i -= 1;
                if (condition >= 50)
                {
                    if (Random.Range(0,2) == 0)
                    {
                        NewBid(currentPrice, condition);
                        break;
                    }
                }
                else
                {
                    if (Random.Range(0,4) == 0)
                    {
                        NewBid(currentPrice, condition);
                        break;
                    }
                }
            }
            else if (i == 1)
            {
                yield return new WaitForSeconds(1f);
                i -= 1;
                if (condition >= 50)
                {
                    if (Random.Range(0,2) == 0)
                    {
                        NewBid(currentPrice, condition);
                    }
                    else
                    {
                        SoldAuction(currentPrice);
                    }
                }
                else
                {
                    if (Random.Range(0,4) == 0)
                    {
                        NewBid(currentPrice, condition);
                    }
                    else
                    {
                        SoldAuction(currentPrice);
                    }
                }
            }
            SetAuctionTimerText(i);
        }
    }

    private void SetAuctionTimerText(int i)
    {
        if (i > 1)
        {
            auctionTimerText.text = i + " Seconds";
        }
        else if (i == 1)
        {
            auctionTimerText.text = i + " Second";
        }
        else if (i == 0)
        {
            auctionTimerText.text = i + " Seconds";
        }
    }

    public void OnClickRenovate()
    {
        var go = EventSystem.current.currentSelectedGameObject;
        PlayerPrefs.SetInt("PropertyRenovateCurrentNumber", PlayerPrefs.GetInt(name + "Number"));
        PlayerPrefs.SetString("PropertyRenovate", go.name);
        int renovatePrice;
        if (PlayerPrefs.GetInt(go.name + "Condition") >= 50)
        {
            int propValue = PlayerPrefs.GetInt(go.name + "Price");
            renovatePrice = Mathf.RoundToInt(propValue / 200) * 10 * Random.Range(2, 5);
        }
        else
        {
            int propValue = PlayerPrefs.GetInt(go.name + "Price");
            renovatePrice = Mathf.RoundToInt(propValue / 200) * 10 * Random.Range(4, 7);
        }
        SetActiveRenovate(renovatePrice);
        propertyRenewalPriceText.text = "$" + renovatePrice.ToString();
    }

    private void SetActiveRenovate(int renovatePrice)
    {
        isPropertyAssetActive = false;
        if (PlayerPrefs.GetInt("Money") >= renovatePrice)
        {
            PlayerPrefs.SetInt("RenovatePriceLastProp", renovatePrice);
            propertyRenovateAreYouSure.SetActive(true);
            propertyInfoObject.SetActive(false);
        }
        else
        {
            tbscript.RenovateCantAfford();
            propertyInfoObject.SetActive(false);
            assetsScript.CloseAll();
        }
    }

    public void OnClickRenovateYes()
    {
        PlayerPrefs.SetInt("Money", PlayerPrefs.GetInt("Money") - PlayerPrefs.GetInt("RenovatePriceLastProp"));
        isPropertyAssetActive = false;
        tbscript.RenovateProperty();
        propertyRenovateAreYouSure.SetActive(false);
        assetsScript.CloseAll();
    }
    // Update is called once per frame
    void Update()
    {
        if (isPropertyAssetActive == true)
        {
            SetPlayerPrefsProperties();
            PlaceProperties();
            NoProperty();
        }
        Debug.Log(propertiesList);
    }

    public void maxCondition()
    {
        for (int i = 0; i < propertiesList.Count; i++)
        {
            if (propertiesList[i].propertiesCondition > 100)
            {
                propertiesList[i].propertiesCondition = 100;
            }
            else if (propertiesList[i].propertiesCondition < 0)
            {
                propertiesList[i].propertiesCondition = 0;
            }
        }
    }
}

This doesn’t line up with when you said the error is on line 54 in your previous post, as there’s nothing on line 54 here.
Can you please post the exact error message?

it was line 54 in the previous code. Its line 113 in this one. “Object reference not set to an instance of an object”.

What happens if you print Debug.Log(propertiesList*.propertiesName); on the line right before that? Maybe PlayerPrefs doesn’t like null inputs.*

For 100% of cases where you get this particular error, something in that line is null. Simply debug each variable involved until you work backwards and resolve the issue.

TBH: I recommend scrapping it. PlayerPrefs is AWFUL for saving anything more complicated than a single primitive type, and one of the reasons why it because you’ll run into errors like this time and time again.

Incorporate a serializer instead - it will literally be easier to learn how to do this than it will be to debug your PlayerPrefs code. You won’t have to have a line of code saving every variable, looping through every item in an array and painstakingly constructing a unique string identifier for each one… you just have all your data in a class, mark that class as [Serializable], and then tell the serializer “put this thing in that file” and you’re done. Here’s a tutorial for doing that with a binary file format, here’s one for saving with JSON.

I will try this, thanks

Note also that you are using a constructor for PropertiesSc with a MonoBehaviour, which (at least some time ago) was seriously discouraged. Log to see if the constructor is invoked.

what can i use instead of constructor for this?

As the article recommends, use Awake or Start, or use a dedicated explicit initializer (e.g. Init()) after new.

i dont get it, i tried this but gives error

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

public class testscript : MonoBehaviour
{

    public int priceHome { get; set; }
    public string nameHome { get; set; }
    public int ageHome { get; set; }
    // Start is called before the first frame update
    public void SetValues(int priceHomeX, string nameHomeX, int ageHomeX)
    {
        priceHome = priceHomeX;
        nameHome = nameHomeX;
        ageHome = ageHomeX;
    }
   
    void Awake()
    {
        SetValues();
    }
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
       
    }
}

We all love to help, but you really should be specific when asking for help. Remember that we did not look over your shoulder when this happened, so assume that we know nothing So:

  • What error did you get (copy and paste entire error message), and
  • where did it occur (make sure the line number matches up, allow for formatting changes in code tags)?

If it is exact this script then it won’t work.
You’re calling SetValues in Awake without supplying any of the parameters it requires.

SetValues has 3 parameters
Awake you called SetValues with 0 parameters, thus giving a compiler error.

I tried this and it worked. but when i tried to create a list with SetValues it gives this error:

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

public class testscript : MonoBehaviour
{

    public int priceHome { get; set; }
    public string nameHome { get; set; }
    public int ageHome { get; set; }
    // Start is called before the first frame update
    public void SetValues(int priceHomeX, string nameHomeX, int ageHomeX)
    {
        priceHome = priceHomeX;
        nameHome = nameHomeX;
        ageHome = ageHomeX;
    }

    List<SetValues> homeList = new List<SetValues>();
   
    void Awake()
    {
        SetValues(priceHome, nameHome, ageHome);
    }
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
       
    }
}

Assets/testscript.cs(19,10): error CS0246: The type or namespace name ‘SetValues’ could not be found (are you missing a using directive or an assembly reference?)

What are you trying to do? List makes no sense. Here, SetValues is a method, not an object type.

And a warning: If you make that List, you’ll end up with a recursion that will crash unity.