Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help Following a vid and gettinga error

Discussion in 'Documentation' started by ShaunChad99, Apr 23, 2020.

  1. ShaunChad99

    ShaunChad99

    Joined:
    Apr 23, 2020
    Posts:
    26
    Im getting this warrning "
    There are inconsistent line endings in the 'Assets/Scripts/Inventory.cs' script. Some are Mac OS X (UNIX) and some are Windows.
    This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands." Please Help
    Thank you in advance.



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

    public class Inventory : MonoBehaviour
    {
    //Variables

    public bool inventoryEnabled;
    public GameObject inventory;
    public GameObject ItemDataBase;
    private Transform[] slot;
    public GameObject slotHolder;

    private bool pickedupItem;


    //Functions

    // Start is called before the first frame update
    void Start()
    {
    GetAllSlots();
    }

    // Update is called once per frame
    void Update()
    {
    //Enabling and disabling the inventory
    if (Input.GetKeyDown(KeyCode.I))
    inventoryEnabled = !inventoryEnabled;

    if (inventoryEnabled)
    inventory.SetActive(true);
    else
    inventory.SetActive(false);
    }

    public void OnTriggerEnter(Collider other)
    {
    if (other.tag == "Item")
    {
    if(pickedupItem == false)
    AddItem(other.gameObject);
    }
    }

    public void AddItem(GameObject item)
    {
    GameObject rootItem;
    rootItem = item.GetComponent<ItemPickup>().rootItem;

    for(int i = 0; i < 25; i++)
    {
    if(slot.GetComponent<Slot>().empty == true)
    {
    slot.GetComponent<Slot>().item = rootItem;
    Destroy(item);
    }
    }
    }

    public void GetAllSlots()
    {
    slot = new Transform[25];
    for (int i = 0; i <25; i++)
    {
    slot[1] = slotHolder.transform.GetChild(i);
    }
    }
    }