mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 17:34:34 +08:00
Compare commits
2 Commits
7c6fdcfb6f
...
67477ef90d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
67477ef90d | ||
![]() |
ba4e103337 |
@ -163,7 +163,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
if (_fieldProperty != null)
|
if (_fieldProperty != null)
|
||||||
{
|
{
|
||||||
_fieldProperty.managedReferenceValue = cmptmp.Clone();
|
_fieldProperty.managedReferenceValue = cmptmp.Clone_Reflection();
|
||||||
_fieldProperty.serializedObject.ApplyModifiedProperties();
|
_fieldProperty.serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,20 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
|||||||
{
|
{
|
||||||
return self.IsSubclassOf(typeof(UnityObject));
|
return self.IsSubclassOf(typeof(UnityObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static MethodInfo memberwiseCloneMethdo = typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
|
internal static object Clone_Reflection(this object obj)
|
||||||
|
{
|
||||||
|
if (obj is ICloneable cloneable)
|
||||||
|
{
|
||||||
|
return cloneable.Clone();
|
||||||
|
}
|
||||||
|
return memberwiseCloneMethdo.Invoke(obj, null);
|
||||||
|
}
|
||||||
|
internal static object Clone_Reflection<T>(this T obj)
|
||||||
|
{
|
||||||
|
return Clone_Reflection((object)obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,7 +50,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
private static void SelectComponent(ComponentTemplatesDropDown.Item item)
|
private static void SelectComponent(ComponentTemplatesDropDown.Item item)
|
||||||
{
|
{
|
||||||
//EcsGUI.Changed = true;
|
//EcsGUI.Changed = true;
|
||||||
currentProperty.managedReferenceValue = item.Obj.Clone();
|
currentProperty.managedReferenceValue = item.Obj.Clone_Reflection();
|
||||||
currentProperty.isExpanded = false;
|
currentProperty.isExpanded = false;
|
||||||
currentProperty.serializedObject.ApplyModifiedProperties();
|
currentProperty.serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_defaultValueType = (T)field.GetValue(null);
|
_defaultValueType = (T)field.GetValue(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_defaultValueTypeInit = true;
|
||||||
}
|
}
|
||||||
return _defaultValueType;
|
return _defaultValueType;
|
||||||
}
|
}
|
||||||
@ -144,22 +145,6 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS.Unity.Internal
|
|
||||||
{
|
|
||||||
internal static class ComponentTemplateExtensions
|
|
||||||
{
|
|
||||||
private static MethodInfo memberwiseCloneMethdo = typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic);
|
|
||||||
internal static IComponentTemplate Clone(this IComponentTemplate obj)
|
|
||||||
{
|
|
||||||
if(obj is ICloneable cloneable)
|
|
||||||
{
|
|
||||||
return (IComponentTemplate)cloneable.Clone();
|
|
||||||
}
|
|
||||||
return (IComponentTemplate)memberwiseCloneMethdo.Invoke(obj, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
namespace DCFApixels.DragonECS.Unity.Editors
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
{
|
{
|
||||||
@ -181,10 +166,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
Type interfaceType = typeof(IComponentTemplate);
|
Type interfaceType = typeof(IComponentTemplate);
|
||||||
|
|
||||||
_types = UnityEditorUtility._serializableTypes.Where(type => interfaceType.IsAssignableFrom(type)).ToArray();
|
_types = UnityEditorUtility._serializableTypes.Where(type => interfaceType.IsAssignableFrom(type)).ToArray();
|
||||||
foreach (var type in _types)
|
//foreach (var type in _types)
|
||||||
{
|
//{
|
||||||
EcsDebugUtility.GetTypeMeta(type);
|
// EcsDebugUtility.GetTypeMeta(type);
|
||||||
}
|
//}
|
||||||
_dummies = new IComponentTemplate[_types.Length];
|
_dummies = new IComponentTemplate[_types.Length];
|
||||||
|
|
||||||
for (int i = 0; i < _types.Length; i++)
|
for (int i = 0; i < _types.Length; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user