Compare commits

..

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

4 changed files with 28 additions and 46 deletions

View File

@ -1,5 +1,4 @@
#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;
@ -51,7 +50,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.worldID, out EcsWorld world); EcsWorld.TryGetWorld(entity.world, out EcsWorld world);
if (drawFoldout && isExpanded) if (drawFoldout && isExpanded)
{ {

View File

@ -1,5 +1,4 @@
#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;

View File

@ -1,6 +1,5 @@
#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;
@ -593,11 +592,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.worldID, out EcsWorld world)) if (EcsWorld.TryGetWorld(entity.world, 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.worldID); EntityField_Internal(position, label, entity.id == 0, isAlive ? EntityStatus.Alive : EntityStatus.NotAlive, entity.id, entity.gen, entity.world);
} }
public static void EntityField(Rect position, SerializedProperty property) public static void EntityField(Rect position, SerializedProperty property)
{ {
@ -614,11 +613,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
else else
{ {
bool isAlive = false; bool isAlive = false;
if (EcsWorld.TryGetWorld(entity.worldID, out EcsWorld world)) if (EcsWorld.TryGetWorld(entity.world, 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.worldID); EntityField_Internal(position, label, entity.id == 0, isAlive ? EntityStatus.Alive : EntityStatus.NotAlive, entity.id, entity.gen, entity.world);
} }
} }

View File

@ -27,9 +27,8 @@ 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 = RuntimeComponentsDepthRoot; private static int _runtimeComponentsDepth = 2;
static RuntimeComponentsDrawer() static RuntimeComponentsDrawer()
{ {
_drawers = new RuntimeComponentsDrawer[RuntimeComponentsMaxDepth + 1]; _drawers = new RuntimeComponentsDrawer[RuntimeComponentsMaxDepth + 1];
@ -66,7 +65,6 @@ 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;
@ -91,12 +89,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
//type.IsPrimitive || //type.IsPrimitive ||
//type == typeof(string) || //type == typeof(string) ||
//type.IsEnum || //type.IsEnum ||
(!type.IsGenericType && type.HasAttribute<System.SerializableAttribute>() && type.IsArray == false); (!type.IsGenericType && type.IsSerializable && type.HasAttribute<System.SerializableAttribute>());
IsCompositeType =
type.IsPrimitive == false &&
type.IsArray == false &&
type != typeof(string);
if (type == typeof(void)) { return; } if (type == typeof(void)) { return; }
@ -169,9 +162,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 == RuntimeComponentsDepthRoot) if (_runtimeComponentsDepth == 0)
{ {
_drawers[0].DrawWorldComponents_Internal(world); _drawers[_runtimeComponentsDepth].DrawWorldComponents_Internal(world);
} }
} }
private void DrawWorldComponents_Internal(EcsWorld world) private void DrawWorldComponents_Internal(EcsWorld world)
@ -249,22 +242,16 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
{ {
if (isRoot) if (isRoot)
{ {
_runtimeComponentsDepth = RuntimeComponentsDepthRoot; _runtimeComponentsDepth = 0;
}
else
{
_runtimeComponentsDepth++;
} }
_runtimeComponentsDepth++;
try _drawers[_runtimeComponentsDepth].DrawRuntimeComponents(entityID, world, isWithFoldout);
{
_drawers[_runtimeComponentsDepth].DrawRuntimeComponents(entityID, world, isWithFoldout); _runtimeComponentsDepth--;
}
finally
{
_runtimeComponentsDepth--;
if (_runtimeComponentsDepth < RuntimeComponentsDepthRoot)
{
_runtimeComponentsDepth = RuntimeComponentsDepthRoot;
}
}
} }
private void DrawRuntimeComponents(int entityID, EcsWorld world, bool isWithFoldout) private void DrawRuntimeComponents(int entityID, EcsWorld world, bool isWithFoldout)
{ {
@ -385,12 +372,9 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
bool changed = false; bool changed = false;
if (cache.IsUnitySerializable == false && cache.IsCompositeType) if (cache.IsUnitySerializable == false)
{ {
var foldoutStyle = EditorStyles.foldout; isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(isExpanded, label, 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)
@ -410,8 +394,8 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
} }
} }
} }
}
}
} }
} }
else else
@ -446,21 +430,22 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
else else
{ {
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth);
wrapper.data = data;
RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth);
wrapper.data = data;
wrapper.SO.Update();
wrapper.IsExpanded = isExpanded;
try try
{ {
if (cache.IsCompositeType && fieldInfoData.IsPassToUnitySerialize) if (fieldInfoData.IsPassToUnitySerialize)
{ {
wrapper.SO.Update();
wrapper.IsExpanded = isExpanded;
EditorGUILayout.PropertyField(wrapper.Property, label, true); EditorGUILayout.PropertyField(wrapper.Property, label, true);
} }
else else
{ {
//EcsGUI. EditorGUILayout.LabelField(label, " ");
EditorGUILayout.LabelField(label);
} }
} }
catch (ArgumentException) catch (ArgumentException)