mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 17:34:34 +08:00
Compare commits
3 Commits
c08be8e883
...
84401b875d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
84401b875d | ||
![]() |
fdbdb94b0c | ||
![]() |
a8f08f2137 |
@ -15,6 +15,20 @@ 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;
|
||||
@ -59,13 +73,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
|
||||
|
||||
Rect dropRect = position;
|
||||
dropRect.yMax = position.yMin + EditorGUIUtility.singleLineHeight;
|
||||
|
||||
|
||||
var eventType = Event.current.type;
|
||||
int controlID = GUIUtility.GetControlID(s_ObjectFieldHash, FocusType.Keyboard, position);
|
||||
if (!dropRect.Contains(Event.current.mousePosition) || !GUI.enabled)
|
||||
if (!containsMouse || !GUI.enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -74,6 +84,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
|
||||
}
|
||||
|
||||
if (eventType == EventType.DragPerform || eventType == EventType.DragUpdated)
|
||||
{
|
||||
if (eventType == EventType.DragPerform)
|
||||
{
|
||||
entlong ent = default;
|
||||
@ -141,8 +153,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
DragAndDrop.activeControlID = controlID;
|
||||
}
|
||||
}
|
||||
|
||||
//Event.current.Use();
|
||||
}
|
||||
|
||||
private bool TryFindEntlong(Object uniObj, out entlong ent)
|
||||
|
@ -82,7 +82,14 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
||||
ResetWrappers();
|
||||
IsUnmanaged = UnsafeUtility.IsUnmanaged(type);
|
||||
IsUnityObjectType = typeof(UnityObject).IsAssignableFrom(type);
|
||||
IsUnitySerializable = IsUnityObjectType || (!type.IsGenericType && type.IsSerializable);
|
||||
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>());
|
||||
|
||||
if (type == typeof(void)) { return; }
|
||||
|
||||
@ -108,7 +115,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
||||
public readonly Type FieldType;
|
||||
public readonly string UnityFormatName;
|
||||
public readonly bool IsUnityObjectField;
|
||||
public readonly bool IsPassToSerialize;
|
||||
public readonly bool IsPassToUnitySerialize;
|
||||
public readonly RuntimeComponentReflectionCache ValueTypeReflectionCache;
|
||||
public FieldInfoData(FieldInfo fieldInfo)
|
||||
{
|
||||
@ -116,7 +123,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
||||
FieldType = fieldInfo.FieldType;
|
||||
IsUnityObjectField = typeof(UnityObject).IsAssignableFrom(fieldInfo.FieldType);
|
||||
UnityFormatName = UnityEditorUtility.TransformFieldName(fieldInfo.Name);
|
||||
IsPassToSerialize =
|
||||
IsPassToUnitySerialize =
|
||||
(fieldInfo.IsPublic || fieldInfo.HasAttribute<SerializeField>() || fieldInfo.HasAttribute<SerializeReference>()) &&
|
||||
(fieldInfo.IsInitOnly || fieldInfo.HasAttribute<System.NonSerializedAttribute>()) == false;
|
||||
ValueTypeReflectionCache = FieldType.IsValueType ? GetRuntimeComponentReflectionCache(FieldType) : null;
|
||||
@ -127,7 +134,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
||||
FieldType = fieldType;
|
||||
UnityFormatName = unityFormatName;
|
||||
IsUnityObjectField = typeof(UnityObject).IsAssignableFrom(fieldType);
|
||||
IsPassToSerialize = isPassToSerialize;
|
||||
IsPassToUnitySerialize = isPassToSerialize;
|
||||
ValueTypeReflectionCache = FieldType.IsValueType ? GetRuntimeComponentReflectionCache(FieldType) : null;
|
||||
}
|
||||
public RuntimeComponentReflectionCache GetReflectionCache(Type type)
|
||||
@ -373,6 +380,8 @@ 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++)
|
||||
{
|
||||
@ -385,6 +394,8 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -427,9 +438,16 @@ 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)
|
||||
|
Loading…
Reference in New Issue
Block a user