Compare commits

..

No commits in common. "84401b875d10a74db6b7331730f07e93af73eadb" and "c08be8e8837885de1ad9084cf429da20ebebb1d2" have entirely different histories.

2 changed files with 67 additions and 97 deletions

View File

@ -15,20 +15,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
Rect labelRect, hyperlinkButtonRect; Rect labelRect, hyperlinkButtonRect;
(labelRect, position) = position.HorizontalSliceLeft(EditorGUIUtility.labelWidth * 0.65f); (labelRect, position) = position.HorizontalSliceLeft(EditorGUIUtility.labelWidth * 0.65f);
var eventType = Event.current.type;
Rect dropRect = position;
dropRect.yMax = position.yMin + EditorGUIUtility.singleLineHeight;
int controlID = GUIUtility.GetControlID(s_ObjectFieldHash, FocusType.Keyboard, position);
bool containsMouse = dropRect.Contains(Event.current.mousePosition);
if(containsMouse && eventType == EventType.Repaint && DragAndDrop.activeControlID == controlID)
{
EditorStyles.selectionRect.Draw(dropRect.AddPadding(-1), GUIContent.none, controlID, false, false);
}
(position, hyperlinkButtonRect) = position.HorizontalSliceRight(18f); (position, hyperlinkButtonRect) = position.HorizontalSliceRight(18f);
bool drawFoldout = property.hasMultipleDifferentValues == false; bool drawFoldout = property.hasMultipleDifferentValues == false;
@ -73,9 +59,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
Rect dropRect = position;
dropRect.yMax = position.yMin + EditorGUIUtility.singleLineHeight;
if (!containsMouse || !GUI.enabled) var eventType = Event.current.type;
int controlID = GUIUtility.GetControlID(s_ObjectFieldHash, FocusType.Keyboard, position);
if (!dropRect.Contains(Event.current.mousePosition) || !GUI.enabled)
{ {
return; return;
} }
@ -84,8 +74,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
DragAndDrop.visualMode = DragAndDropVisualMode.Generic; DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
} }
if (eventType == EventType.DragPerform || eventType == EventType.DragUpdated)
{
if (eventType == EventType.DragPerform) if (eventType == EventType.DragPerform)
{ {
entlong ent = default; entlong ent = default;
@ -153,8 +141,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
DragAndDrop.activeControlID = controlID; DragAndDrop.activeControlID = controlID;
} }
}
//Event.current.Use();
} }
private bool TryFindEntlong(Object uniObj, out entlong ent) private bool TryFindEntlong(Object uniObj, out entlong ent)

View File

@ -82,14 +82,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
ResetWrappers(); ResetWrappers();
IsUnmanaged = UnsafeUtility.IsUnmanaged(type); IsUnmanaged = UnsafeUtility.IsUnmanaged(type);
IsUnityObjectType = typeof(UnityObject).IsAssignableFrom(type); IsUnityObjectType = typeof(UnityObject).IsAssignableFrom(type);
IsUnitySerializable = IsUnitySerializable = IsUnityObjectType || (!type.IsGenericType && type.IsSerializable);
IsUnityObjectType ||
//typeof(Array).IsAssignableFrom(type) ||
//(type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>)) ||
//type.IsPrimitive ||
//type == typeof(string) ||
//type.IsEnum ||
(!type.IsGenericType && type.IsSerializable && type.HasAttribute<System.SerializableAttribute>());
if (type == typeof(void)) { return; } if (type == typeof(void)) { return; }
@ -115,7 +108,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
public readonly Type FieldType; public readonly Type FieldType;
public readonly string UnityFormatName; public readonly string UnityFormatName;
public readonly bool IsUnityObjectField; public readonly bool IsUnityObjectField;
public readonly bool IsPassToUnitySerialize; public readonly bool IsPassToSerialize;
public readonly RuntimeComponentReflectionCache ValueTypeReflectionCache; public readonly RuntimeComponentReflectionCache ValueTypeReflectionCache;
public FieldInfoData(FieldInfo fieldInfo) public FieldInfoData(FieldInfo fieldInfo)
{ {
@ -123,7 +116,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
FieldType = fieldInfo.FieldType; FieldType = fieldInfo.FieldType;
IsUnityObjectField = typeof(UnityObject).IsAssignableFrom(fieldInfo.FieldType); IsUnityObjectField = typeof(UnityObject).IsAssignableFrom(fieldInfo.FieldType);
UnityFormatName = UnityEditorUtility.TransformFieldName(fieldInfo.Name); UnityFormatName = UnityEditorUtility.TransformFieldName(fieldInfo.Name);
IsPassToUnitySerialize = IsPassToSerialize =
(fieldInfo.IsPublic || fieldInfo.HasAttribute<SerializeField>() || fieldInfo.HasAttribute<SerializeReference>()) && (fieldInfo.IsPublic || fieldInfo.HasAttribute<SerializeField>() || fieldInfo.HasAttribute<SerializeReference>()) &&
(fieldInfo.IsInitOnly || fieldInfo.HasAttribute<System.NonSerializedAttribute>()) == false; (fieldInfo.IsInitOnly || fieldInfo.HasAttribute<System.NonSerializedAttribute>()) == false;
ValueTypeReflectionCache = FieldType.IsValueType ? GetRuntimeComponentReflectionCache(FieldType) : null; ValueTypeReflectionCache = FieldType.IsValueType ? GetRuntimeComponentReflectionCache(FieldType) : null;
@ -134,7 +127,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
FieldType = fieldType; FieldType = fieldType;
UnityFormatName = unityFormatName; UnityFormatName = unityFormatName;
IsUnityObjectField = typeof(UnityObject).IsAssignableFrom(fieldType); IsUnityObjectField = typeof(UnityObject).IsAssignableFrom(fieldType);
IsPassToUnitySerialize = isPassToSerialize; IsPassToSerialize = isPassToSerialize;
ValueTypeReflectionCache = FieldType.IsValueType ? GetRuntimeComponentReflectionCache(FieldType) : null; ValueTypeReflectionCache = FieldType.IsValueType ? GetRuntimeComponentReflectionCache(FieldType) : null;
} }
public RuntimeComponentReflectionCache GetReflectionCache(Type type) public RuntimeComponentReflectionCache GetReflectionCache(Type type)
@ -380,8 +373,6 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
if (isExpanded) if (isExpanded)
{ {
using (EcsGUI.UpIndentLevel()) using (EcsGUI.UpIndentLevel())
{
if (cache != null)
{ {
for (int j = 0, jMax = cache.Fields.Length; j < jMax; j++) for (int j = 0, jMax = cache.Fields.Length; j < jMax; j++)
{ {
@ -394,8 +385,6 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
} }
} }
} }
}
} }
} }
else else
@ -438,16 +427,9 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
wrapper.IsExpanded = isExpanded; wrapper.IsExpanded = isExpanded;
try try
{
if (fieldInfoData.IsPassToUnitySerialize)
{ {
EditorGUILayout.PropertyField(wrapper.Property, label, true); EditorGUILayout.PropertyField(wrapper.Property, label, true);
} }
else
{
EditorGUILayout.LabelField(label, " ");
}
}
catch (ArgumentException) catch (ArgumentException)
{ {
if (Event.current.type != EventType.Repaint) if (Event.current.type != EventType.Repaint)