c# - 标记为覆盖但找不到合适的方法覆盖的 Unity 错误
问题描述
我正在编写一个统一的字符控制器。我是 C# 编程的新手,我写了一些代码,
using UnityEngine;
using UnityEditor;
[CustomPorpertyDrawer(typeof(AxisKeys))]
public class PlayerAxisKeysDrawer: PropertyDrawer{
public override void onGUI(Rect position, SerializedProperty property, GUIContent label)
{
//don't indent
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
//ensure override works on entire property
EditorGUI.BeginProperty(position, label, property);
//label
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
//set position rects;
Rect posLabel = new Rect(position.x, position.y, 15, position.height);
Rect posField = new Rect(position.x + 20, position.y, 50, position.height);
Rect negLabel = new Rect(position.x, position.y, 15, position.height);
Rect negField = new Rect(position.x + 20, position.y, 50, position.height);
GUIContent posGUI = new GUIContent("+");
GUIContent negGUI = new GUIContent("-");
//draw fields
EditorGUI.LabelField(posLabel, posGUI);
EditorGUI.PropertyField(posField, property.FindPropertyRelative("positive"), GUIContent.none);
EditorGUI.LabelField(negLabel, negGUI);
EditorGUI.PropertyField(negField, property.FindPropertyRelative("negative"), GUIContent.none);
//reset indent
EditorGUI.indentlevel = indent;
//end property
EditorGUI.EndProperty();
}
}
但是得到这个错误。有人可以帮忙吗?
error CS0115: `PlayerAxisKeysDrawer.onGUI(UnityEngine.Rect, UnityEditor.SerializedProperty, UnityEngine.GUIContent)' is marked as an override but no suitable method found to override
解决方案
您有拼写错误,更改OnInspectecorGUI
为OnInspectorGUI
它应该可以工作:)
推荐阅读
- sql - 创建位图索引-ora-00921
- javascript - 自动从 https/ws 服务器获取服务器证书
- html - .m3u8 视频源仅在 macOS 上运行
- vue.js - 使用 Vuejs 时如何优化我的 app.js 文件
- arrays - Bash 数组未正确写入变量
- javascript - 有 2 个名称的 JavaScript 函数?
- amazon-web-services - Amazon Redshift 是否有自己的存储后端
- python - 使用 if 根据值添加列值
- bash - Bash 终端:仅将特定行写入日志文件
- docker - 如何使用 docker run 命令传递环境变量?