小编Ral*_*yph的帖子

Unity构建错误:找不到类型或命名空间名称“Editor”

我有一个脚本Item.cs,负责设置玩家库存中项目的参数。在其中,我连接 Unity Editor 库并创建一个继承自 Editor 类的类。直到最近,我还在使用 Unity 版本2020.3.0f1,一切都构建得很好,但现在我安装了2021.3.9f1,但开始遇到问题。

当我构建项目时,我收到以下错误:

Assets\Inventory\Items.cs(31,31):错误 CS0246:找不到类型或命名空间名称“Editor”(您是否缺少 using 指令或程序集引用?)

Assets\Inventory\Items.cs(30,5):错误 CS0246:找不到类型或命名空间名称“CustomEditorAttribute”(您是否缺少 using 指令或程序集引用?)

Assets\Inventory\Items.cs(30,5):错误 CS0246:找不到类型或命名空间名称“CustomEditor”(您是否缺少 using 指令或程序集引用?)

Assets\Inventory\Items.cs(32,28):错误CS0115:'Items.ItemsEditor.OnInspectorGUI()':找不到合适的方法来覆盖

代码:

using UnityEngine;
using UnityEditor;

public class Items : MonoBehaviour {
   public enum itemTypes { Weapon, Potion, Amulet }
   public enum potionType { Health, Poison, Strong, Beer }
   public enum amuletType { Health, Defense, Speed }

   [Header("Main Settings")]
   public itemTypes ItemTypes;
   [HideInInspector] public GameObject Model;
   [HideInInspector] public Texture2D Icon;
   [HideInInspector] public string …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

7
推荐指数
1
解决办法
8856
查看次数

标签 统计

c# ×1

unity-game-engine ×1