Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

help i cant remove the "Assets\scripts\InventorySystem.cs(84,25): error CS0839: Argument missing"

Discussion in 'Visual Scripting' started by Khabi12, Sep 10, 2022.

  1. Khabi12

    Khabi12

    Joined:
    Aug 9, 2022
    Posts:
    22
    here is the code


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class InventorySystem : MonoBehaviour
    6. {
    7.  
    8.    public static InventorySystem Instance { get; set; }
    9.     public GameObject inventoryScreenUI;
    10.  
    11.     public bool isOpen;
    12.  
    13.     public List<GameObject> slotList = new List<GameObject>();
    14.  
    15.     public List<string> itemList = new List<string>();
    16.  
    17.     private GameObject itemToAdd;
    18.  
    19.     private GameObject whatSlotToEquip;
    20.  
    21.     //public bool isFull;
    22.     private void Awake()
    23.     {
    24.         if (Instance != null && Instance != this)
    25.         {
    26.             Destroy(gameObject);
    27.         }
    28.         else
    29.         {
    30.             Instance = this;
    31.         }
    32.     }
    33.  
    34.     void Start()
    35.     {
    36.      
    37.         isOpen = false;
    38.  
    39.         PopulateSlotList();
    40.  
    41.  
    42.        
    43.     }
    44.  
    45.         // it makes it so i dont need to drag and drop the slots to the slotlist [DOES NOT WORK NOW]
    46.     private void PopulateSlotList()
    47.     {
    48.        foreach (Transform child in inventoryScreenUI.transform)
    49.        {
    50.  
    51.           if (child.CompareTag("Slot"))
    52.           {
    53.            Debug.Log("slotlist is working");
    54.              slotList.Add(child.gameObject);
    55.           }
    56.        }
    57.     }
    58. // makes it so i can open the inventory
    59.     void Update()
    60.     {
    61.         if (Input.GetKeyDown(KeyCode.E) && !isOpen)
    62.         {
    63.             Debug.Log("E is pressed");
    64.             Cursor.lockState = CursorLockMode.None;
    65.             inventoryScreenUI.SetActive(true);
    66.             isOpen = true;
    67.         }
    68.         else (Input.GetKeyDown(KeyCode.E) && isOpen);
    69.         {
    70.             Cursor.lockState = CursorLockMode.Locked;
    71.             inventoryScreenUI.SetActive(false);
    72.             isOpen = false;
    73.         }
    74.  
    75.          AddToInventory(,itemName);
    76.         {
    77.  
    78.                isFull = true;
    79.      
    80.                 Debug.Log("inventory is full");
    81.          whatSlotToEquip = FindNextEmptySlot();
    82.  
    83.          itemToAdd = Instantiate(Resources.Load<GameObject>(itemName), whatSlotToEquip.transform.position, whatSlotToEquip.transform.rotation);
    84.          itemToAdd.transform.SetParent(whatSlotToEquip.transform);
    85.  
    86.          itemList.Add(itemName);
    87.          
    88.          
    89.        
    90.          
    91.         }
    92.     }
    93.  
    94.     public bool CheckIsFull()
    95.     {
    96.  
    97.         isFull =true;
    98.  
    99.        int counter = 0;
    100.  
    101.        foreach (GameObject slot in slotList)
    102.        {
    103.           if (slot.transform.childCount >0)
    104.           {
    105.              counter == 1;
    106.           }
    107.  
    108.        }
    109.        if (counter == 21)
    110.           {
    111.              return true;
    112.           }
    113.           else
    114.           {
    115.               return false;
    116.           }  
    117.     }
    118.  
    119.     private GameObject FindNextEmptySlot()
    120.     {
    121.      
    122.        foreach(GameObject slot in slotList)
    123.        {
    124.          Debug.Log("2");
    125.           if (slot.transform.childCount == 0)
    126.           {
    127.             Debug.Log("working 2");
    128.              return slot;
    129.           }
    130.        }
    131.  
    132.        return new GameObject();
    133.     }
    134. }
    135.  
     
  2. Khabi12

    Khabi12

    Joined:
    Aug 9, 2022
    Posts:
    22
    the problem is line 75
     
  3. Khabi12

    Khabi12

    Joined:
    Aug 9, 2022
    Posts:
    22
    i`m missing a argument