mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 17:34:34 +08:00
Compare commits
4 Commits
84401b875d
...
760c789acb
Author | SHA1 | Date | |
---|---|---|---|
![]() |
760c789acb | ||
![]() |
09f7c6103d | ||
![]() |
236eb3d2bb | ||
![]() |
a7f269a0f2 |
@ -1,4 +1,5 @@
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
|
using DCFApixels.DragonECS.Core.Unchecked;
|
||||||
using DCFApixels.DragonECS.Unity.Internal;
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
@ -50,7 +51,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
SerializedProperty fulleProperty = property.FindPropertyRelative("_full");
|
SerializedProperty fulleProperty = property.FindPropertyRelative("_full");
|
||||||
EntitySlotInfo entity = new EntitySlotInfo(fulleProperty.longValue);
|
EntitySlotInfo entity = new EntitySlotInfo(fulleProperty.longValue);
|
||||||
EcsWorld.TryGetWorld(entity.world, out EcsWorld world);
|
EcsWorld.TryGetWorld(entity.worldID, out EcsWorld world);
|
||||||
|
|
||||||
if (drawFoldout && isExpanded)
|
if (drawFoldout && isExpanded)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
|
using DCFApixels.DragonECS.Core.Unchecked;
|
||||||
using DCFApixels.DragonECS.Unity.Editors.X;
|
using DCFApixels.DragonECS.Unity.Editors.X;
|
||||||
using DCFApixels.DragonECS.Unity.Internal;
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
|
using DCFApixels.DragonECS.Core.Unchecked;
|
||||||
using DCFApixels.DragonECS.Unity.Internal;
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -592,11 +593,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
public static void EntityField(Rect position, DragonGUIContent label, EntitySlotInfo entity)
|
public static void EntityField(Rect position, DragonGUIContent label, EntitySlotInfo entity)
|
||||||
{
|
{
|
||||||
bool isAlive = false;
|
bool isAlive = false;
|
||||||
if (EcsWorld.TryGetWorld(entity.world, out EcsWorld world))
|
if (EcsWorld.TryGetWorld(entity.worldID, out EcsWorld world))
|
||||||
{
|
{
|
||||||
isAlive = world.IsAlive(entity.id, entity.gen);
|
isAlive = world.IsAlive(entity.id, entity.gen);
|
||||||
}
|
}
|
||||||
EntityField_Internal(position, label, entity.id == 0, isAlive ? EntityStatus.Alive : EntityStatus.NotAlive, entity.id, entity.gen, entity.world);
|
EntityField_Internal(position, label, entity.id == 0, isAlive ? EntityStatus.Alive : EntityStatus.NotAlive, entity.id, entity.gen, entity.worldID);
|
||||||
}
|
}
|
||||||
public static void EntityField(Rect position, SerializedProperty property)
|
public static void EntityField(Rect position, SerializedProperty property)
|
||||||
{
|
{
|
||||||
@ -613,11 +614,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool isAlive = false;
|
bool isAlive = false;
|
||||||
if (EcsWorld.TryGetWorld(entity.world, out EcsWorld world))
|
if (EcsWorld.TryGetWorld(entity.worldID, out EcsWorld world))
|
||||||
{
|
{
|
||||||
isAlive = world.IsAlive(entity.id, entity.gen);
|
isAlive = world.IsAlive(entity.id, entity.gen);
|
||||||
}
|
}
|
||||||
EntityField_Internal(position, label, entity.id == 0, isAlive ? EntityStatus.Alive : EntityStatus.NotAlive, entity.id, entity.gen, entity.world);
|
EntityField_Internal(position, label, entity.id == 0, isAlive ? EntityStatus.Alive : EntityStatus.NotAlive, entity.id, entity.gen, entity.worldID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,9 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
//_runtimeComponentReflectionCaches.Clear();
|
//_runtimeComponentReflectionCaches.Clear();
|
||||||
}
|
}
|
||||||
private const int RuntimeComponentsMaxDepth = 2;
|
private const int RuntimeComponentsMaxDepth = 2;
|
||||||
|
private const int RuntimeComponentsDepthRoot = -1;
|
||||||
private static RuntimeComponentsDrawer[] _drawers;
|
private static RuntimeComponentsDrawer[] _drawers;
|
||||||
private static int _runtimeComponentsDepth = 2;
|
private static int _runtimeComponentsDepth = RuntimeComponentsDepthRoot;
|
||||||
static RuntimeComponentsDrawer()
|
static RuntimeComponentsDrawer()
|
||||||
{
|
{
|
||||||
_drawers = new RuntimeComponentsDrawer[RuntimeComponentsMaxDepth + 1];
|
_drawers = new RuntimeComponentsDrawer[RuntimeComponentsMaxDepth + 1];
|
||||||
@ -65,6 +66,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
|
|
||||||
public readonly bool IsUnityObjectType;
|
public readonly bool IsUnityObjectType;
|
||||||
public readonly bool IsUnitySerializable;
|
public readonly bool IsUnitySerializable;
|
||||||
|
public readonly bool IsCompositeType;
|
||||||
public readonly bool IsUnmanaged;
|
public readonly bool IsUnmanaged;
|
||||||
|
|
||||||
public readonly FieldInfoData[] Fields;
|
public readonly FieldInfoData[] Fields;
|
||||||
@ -89,7 +91,12 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
//type.IsPrimitive ||
|
//type.IsPrimitive ||
|
||||||
//type == typeof(string) ||
|
//type == typeof(string) ||
|
||||||
//type.IsEnum ||
|
//type.IsEnum ||
|
||||||
(!type.IsGenericType && type.IsSerializable && type.HasAttribute<System.SerializableAttribute>());
|
(!type.IsGenericType && type.HasAttribute<System.SerializableAttribute>() && type.IsArray == false);
|
||||||
|
|
||||||
|
IsCompositeType =
|
||||||
|
type.IsPrimitive == false &&
|
||||||
|
type.IsArray == false &&
|
||||||
|
type != typeof(string);
|
||||||
|
|
||||||
if (type == typeof(void)) { return; }
|
if (type == typeof(void)) { return; }
|
||||||
|
|
||||||
@ -162,9 +169,9 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
#region draw world component
|
#region draw world component
|
||||||
public static void DrawWorldComponents(EcsWorld world)
|
public static void DrawWorldComponents(EcsWorld world)
|
||||||
{
|
{
|
||||||
if (_runtimeComponentsDepth == 0)
|
if (_runtimeComponentsDepth == RuntimeComponentsDepthRoot)
|
||||||
{
|
{
|
||||||
_drawers[_runtimeComponentsDepth].DrawWorldComponents_Internal(world);
|
_drawers[0].DrawWorldComponents_Internal(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void DrawWorldComponents_Internal(EcsWorld world)
|
private void DrawWorldComponents_Internal(EcsWorld world)
|
||||||
@ -242,16 +249,22 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
if (isRoot)
|
if (isRoot)
|
||||||
{
|
{
|
||||||
_runtimeComponentsDepth = 0;
|
_runtimeComponentsDepth = RuntimeComponentsDepthRoot;
|
||||||
}
|
}
|
||||||
else
|
_runtimeComponentsDepth++;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
_runtimeComponentsDepth++;
|
_drawers[_runtimeComponentsDepth].DrawRuntimeComponents(entityID, world, isWithFoldout);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_runtimeComponentsDepth--;
|
||||||
|
if (_runtimeComponentsDepth < RuntimeComponentsDepthRoot)
|
||||||
|
{
|
||||||
|
_runtimeComponentsDepth = RuntimeComponentsDepthRoot;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_drawers[_runtimeComponentsDepth].DrawRuntimeComponents(entityID, world, isWithFoldout);
|
|
||||||
|
|
||||||
_runtimeComponentsDepth--;
|
|
||||||
}
|
}
|
||||||
private void DrawRuntimeComponents(int entityID, EcsWorld world, bool isWithFoldout)
|
private void DrawRuntimeComponents(int entityID, EcsWorld world, bool isWithFoldout)
|
||||||
{
|
{
|
||||||
@ -372,9 +385,12 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
|
|
||||||
if (cache.IsUnitySerializable == false)
|
if (cache.IsUnitySerializable == false && cache.IsCompositeType)
|
||||||
{
|
{
|
||||||
isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(isExpanded, label, EditorStyles.foldout);
|
var foldoutStyle = EditorStyles.foldout;
|
||||||
|
Rect rect = GUILayoutUtility.GetRect(label, foldoutStyle);
|
||||||
|
rect.xMin += EcsGUI.Indent;
|
||||||
|
isExpanded = EditorGUI.BeginFoldoutHeaderGroup(rect, isExpanded, label, foldoutStyle, null, null);
|
||||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||||
|
|
||||||
if (isExpanded)
|
if (isExpanded)
|
||||||
@ -394,8 +410,8 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -430,22 +446,21 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth);
|
RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth);
|
||||||
|
|
||||||
wrapper.data = data;
|
wrapper.data = data;
|
||||||
wrapper.SO.Update();
|
|
||||||
|
|
||||||
wrapper.IsExpanded = isExpanded;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (fieldInfoData.IsPassToUnitySerialize)
|
if (cache.IsCompositeType && fieldInfoData.IsPassToUnitySerialize)
|
||||||
{
|
{
|
||||||
|
wrapper.SO.Update();
|
||||||
|
wrapper.IsExpanded = isExpanded;
|
||||||
EditorGUILayout.PropertyField(wrapper.Property, label, true);
|
EditorGUILayout.PropertyField(wrapper.Property, label, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EditorGUILayout.LabelField(label, " ");
|
//EcsGUI.
|
||||||
|
EditorGUILayout.LabelField(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
|
Loading…
Reference in New Issue
Block a user