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;
(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);
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;
}
@ -84,8 +74,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
}
if (eventType == EventType.DragPerform || eventType == EventType.DragUpdated)
{
if (eventType == EventType.DragPerform)
{
entlong ent = default;
@ -107,7 +95,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
foreach (var beh in go.GetComponents<MonoBehaviour>())
{
if (TryFindEntlong(beh, out ent))
if(TryFindEntlong(beh, out ent))
{
isValide = true;
break;
@ -153,8 +141,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
DragAndDrop.activeControlID = controlID;
}
}
//Event.current.Use();
}
private bool TryFindEntlong(Object uniObj, out entlong ent)

View File

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