can t add script unity

I am trying to add a script with my object in unity. But it seems «Cant add script behavior AssemblyInfo.cs. The script needs to derive from MonoBehavior». How can I fix the problem please..

I have already checked the script and class name which are same already.Moreover I’ve copy and pasted the code in another file but it didn’t fix.

1 Answer 1

This is typically caused when a script is created outside of the Unity project. If you created the script with visual studio, file explorer, or simply copy/pasting the file, it may not be included in the Unity project.

Rather than try to re-build the assembly, simply create a new «PlayerMovement.cs» script using the Unity editor (right-click > create script) and write your code in that file.

Not the answer you’re looking for? Browse other questions tagged c# unity3d or ask your own question.

Hot Network Questions

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2019 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2019.11.15.35459

Когда хочу поставить скрипт на обьект мне пишет это can’t add script behaviour Perlin.The script needs to derive from MonoBehaviour.
Вот сам скрипт (Весь вставить не могу, только начало)

using System.Collections;
using System;
using UnityEngine;

/* Perlin noise use example:

Perlin perlin = new Perlin();
var value : float = perlin.Noise(2);
var value : float = perlin.Noise(2, 3, );
var value : float = perlin.Noise(2, 3, 4);

SmoothRandom use example:

var p = SmoothRandom.GetVector3(3);

Помогите плиз срочно надо (делаю игру типа Minecraft,Кто хочет помочь делать присойденяйтесь, вот мой скайп Zordaxo)

I’m a beginner in unity so I got this problem. Here is the script:

I don’t know why but it keep saying that Can’t add script component ‘Player control’ because the script class cannot be found.Make sure that there no compile errors and that the file name and class name match.

2 Answers 2

Check the file name of the script and make sure it’s the same as the class name. I’ve had this problem before after renaming a script through the editor.

You either have a compile error in this script, or you have one in a different script. If this is the first time you’re trying to use this script, the entire solution needs to compile before Unity knows about this new class you’re introducing.

Locate your error and correct it before trying to add this script. It could be a compile error or something like a name mismatch like SanSolo suggests.

Not the answer you’re looking for? Browse other questions tagged c# unity or ask your own question.

Hot Network Questions

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2019 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2019.11.15.35459

Оцените статью