How to fix... Can't Add Script component to GameObject (Unity)

preview_player
Показать описание
#unitytips #scripterror #csharp
A common error is to mis-name your class or script name. This video shows you how to correct it & have your scripts able to be added to game objects again
Рекомендации по теме
Комментарии
Автор

Thank you so much 😘😘 + For those who still have the error: The line with the text "PUBLIC CLASS" is followed by the file name. If the file name is not the same as the word after the code, then it gives an error.

Example:

name of C# file: Hello World



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

public class HelloWorld : MonoBehaviour {
...

> Error: Error: Hello World is not the same as HelloWorld..



THIS "HelloWorld" is NOT "Hello World"

alihashemnejad
Автор

When you answered my problem in 30 seconds that I thought would take 50 minutes to find the answer to, I jumped out of my chair and started dancing. #happyday

diegolucano
Автор

I'm still getting the same error unfortunately.. I even tried on a new script and without any editing, I tried to attach to an empty gameobject and the error still popped up... Any suggestions? Thank you.

major
Автор

THANK YOU… goddammit if only i’ve seen this video 3 hours ago!!

pineapple
Автор

25 seconds in and you're explanation gave me a big "derp" moment. Thank you, sir!

ikillomega
Автор

Tysm. I really like videos that go straight into the point, no intro, no shits. Respects.

vinhnguyen-oz
Автор

i am no coder, and you just saved me so much troubles within 1minute. I drank a beer for you! Thank you Sir!

Elphax
Автор

saved my PC from being burned, thanks

MacMaurof
Автор

Thank you much!!! It acturally torture me for two days! Every time when i add script to my game object Unity crashes, and i finally know why

SssuperFastJellyfish
Автор

thank you!!! I'm a beginner and I got so confused as to did the script already have an error.

izzygenie
Автор

Thank you man, I was stuck for 30 minutes trying to find problem

topchagamaster
Автор

ThnxBro. I changed the name after making the script-which resulted this error, the key is to keep the name same as creation name.

krishnachandradas
Автор

Nach 30 Sekunden schon erklärt. Vielen Dank 👍

saern
Автор

thank you, kind sir. i really didnt know why my file didnt want to move to my character. you just earned a new sub, and probably a new regular viewer

DAV
Автор

Super quick and helpful, wish these kinds of videos were in my classes I'm taking right now.

josephmcgourty
Автор

Eyvallah kardeşim senin sayende yazılımcı olabileceğim unity dersleri alıyorum hedef 1 milyon istihdam. Seni asla unutmayacağım ingilizce konuşsanda her dilde konuşan insanlar bile seni anlar o dilini yerim.Saygılarımla Prof.Dr.CukuBik Adam (this text's language is Turkish)

cukubik
Автор

my did not said compile error but this still did the trick and helped me out.

my Script name was "User Interface" inside unity but in visual studio it was " UserInterface "
Changing it in unity from "User Interface" to "UserInterface" just by removing the space i was able to attach it to the camera as a working script.
thank you @Sloan Kelly

asifkaka
Автор

HOLY JESUS REALY THAT WAS IT?!?! ive been sitting here for hours trying to figure out what was wrong T-T But Thanks man!!!

luvcloudy
Автор

Simple and objective. Thanks, man! You helped me a lot!

mariellimarquesini
Автор

Reyis video çok güzel kısa ve net çok da baba bir adama benziyorsun I like it

akifguler
join shbcf.ru