最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

c# - Why can't I add the script to my Game Object? - Stack Overflow

matteradmin4PV0评论

So I recently got an asset from the Unity Asset Store that's mean to make ropes, but when I tried to use it, It said it couldn't add the script to the game object?

This was the error:

Can't add script component 'RopeEditor' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.

And This was the Important part of the code (I think for this error anyways)

using UnityEngine;
using UnityEditor;

namespace GogoGaga.OptimizedRopesAndCables
{
    [CustomEditor(typeof(Rope))]
    public class RopeEditor : Editor
    {

If anyone could help me understand the problem and help me try to fix that'd be great because I'd rather tamper than try to find something else.

So I recently got an asset from the Unity Asset Store that's mean to make ropes, but when I tried to use it, It said it couldn't add the script to the game object?

This was the error:

Can't add script component 'RopeEditor' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.

And This was the Important part of the code (I think for this error anyways)

using UnityEngine;
using UnityEditor;

namespace GogoGaga.OptimizedRopesAndCables
{
    [CustomEditor(typeof(Rope))]
    public class RopeEditor : Editor
    {

If anyone could help me understand the problem and help me try to fix that'd be great because I'd rather tamper than try to find something else.

Share Improve this question asked Nov 18, 2024 at 10:12 DuckieIsADevDuckieIsADev 112 bronze badges 1
  • 3 Because it is an editor class not a monobehavior – BugFinder Commented Nov 18, 2024 at 10:51
Add a comment  | 

2 Answers 2

Reset to default 0

You want to add the Rope component to your GameObject!

This RopeEditor just controls how the Inspector of that Rope component will then look like.

You can add a script to a GameObject if the class is derived from MonoBehaviour.

In this case:

public class RopeEditor : Editor

The class "RopeEditor" is derived from "Editor". There is probably a script called "Rope" which can be added to your game objects. Good luck!

Post a comment

comment list (0)

  1. No comments so far