最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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!

发布评论

评论列表(0)

  1. 暂无评论