您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

42 行
1.4 KiB

using System;
using System.Reflection;
using UnityEditor;
namespace Unity.Entities.Editor
{
[CustomEditor(typeof(ComponentDataWrapperBase), true), CanEditMultipleObjects]
public class ComponentDataWrapperBaseEditor : UnityEditor.Editor
{
private string m_SerializableError;
protected virtual void OnEnable()
{
var serializedDataProperty = serializedObject.FindProperty("m_SerializedData");
if (serializedDataProperty != null)
return;
FieldInfo field = null;
var type = target.GetType();
while (type.BaseType != typeof(ComponentDataWrapperBase))
{
type = type.BaseType;
field = type.GetField("m_SerializedData", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
break;
}
if (field != null && !Attribute.IsDefined(field, typeof(SerializableAttribute)))
{
m_SerializableError = string.Format(
L10n.Tr("Component type {0} is not marked with {1}"), field.FieldType, typeof(SerializableAttribute)
);
}
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (!string.IsNullOrEmpty(m_SerializableError))
EditorGUILayout.HelpBox(m_SerializableError, MessageType.Error);
}
}
}