- Home /
Please help. Can't add script problem.
I have a really big problem with this script. I did an other one before and it worked. this time is this problem that i can't add script. Someone please help. Thank you in advance.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class NewBehaviourScript : MonoBehaviour {
public List<Item> inventory = new List<Item>();
private ItemDatabase database;
// Use this for initialization
void Start () {
database = GameObject.FindGameObjectWithTag("Item Database").GetComponent<ItemDatabase>();
print (database.items [0].itemName);
}
// Update is called once per frame
void Update () {
}
}
You really need to write what the error message you're getting is. The most common reason for why $$anonymous$$onoBehaviour scripts can't be added is that the name of the file and the name of the script are not the same.
So if you have a script named "NewBehaviourScript", it has to be in a file named "NewBehaviourScript.cs". Not "NewerBehaviourScript.cs" or "newbehaviourscript.cs".
Answer by Owen-Reynolds · Jan 19, 2015 at 02:54 AM
Try "unity cant add script." Unity has been around for years, and many people ask this. There are pages and pages of mistakes other people have made, and how they were fixed.
You will find the answer much quicker than a back-and-forth in the comments here.
Your answer
![](https://koobas.hobune.stream/wayback/20220613180801im_/https://answers.unity.com/themes/thub/images/avi.jpg)