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
using DCFApixels.DragonECS.Core.Unchecked;
using DCFApixels.DragonECS.Unity.Internal;
using System.Reflection;
using UnityEditor;
@ -51,7 +50,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
SerializedProperty fulleProperty = property.FindPropertyRelative("_full");
EntitySlotInfo entity = new EntitySlotInfo(fulleProperty.longValue);
EcsWorld.TryGetWorld(entity.worldID, out EcsWorld world);
EcsWorld.TryGetWorld(entity.world, out EcsWorld world);
if (drawFoldout && isExpanded)
{

View File

@ -1,5 +1,4 @@
#if UNITY_EDITOR
using DCFApixels.DragonECS.Core.Unchecked;
using DCFApixels.DragonECS.Unity.Editors.X;
using DCFApixels.DragonECS.Unity.Internal;
using System.Collections.Generic;

View File

@ -1,6 +1,5 @@
#if UNITY_EDITOR
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Unchecked;
using DCFApixels.DragonECS.Unity.Internal;
using System;
using System.Collections.Generic;
@ -593,11 +592,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
public static void EntityField(Rect position, DragonGUIContent label, EntitySlotInfo entity)
{
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);
}
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)
{
@ -614,11 +613,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
else
{
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);
}
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();
}
private const int RuntimeComponentsMaxDepth = 2;
private const int RuntimeComponentsDepthRoot = -1;
private static RuntimeComponentsDrawer[] _drawers;
private static int _runtimeComponentsDepth = RuntimeComponentsDepthRoot;
private static int _runtimeComponentsDepth = 2;
static RuntimeComponentsDrawer()
{
_drawers = new RuntimeComponentsDrawer[RuntimeComponentsMaxDepth + 1];
@ -66,7 +65,6 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
public readonly bool IsUnityObjectType;
public readonly bool IsUnitySerializable;
public readonly bool IsCompositeType;
public readonly bool IsUnmanaged;
public readonly FieldInfoData[] Fields;
@ -91,12 +89,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
//type.IsPrimitive ||
//type == typeof(string) ||
//type.IsEnum ||
(!type.IsGenericType && type.HasAttribute<System.SerializableAttribute>() && type.IsArray == false);
IsCompositeType =
type.IsPrimitive == false &&
type.IsArray == false &&
type != typeof(string);
(!type.IsGenericType && type.IsSerializable && type.HasAttribute<System.SerializableAttribute>());
if (type == typeof(void)) { return; }
@ -169,9 +162,9 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
#region draw world component
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)
@ -249,22 +242,16 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
{
if (isRoot)
{
_runtimeComponentsDepth = RuntimeComponentsDepthRoot;
_runtimeComponentsDepth = 0;
}
else
{
_runtimeComponentsDepth++;
}
_runtimeComponentsDepth++;
try
{
_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)
{
@ -385,12 +372,9 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
bool changed = false;
if (cache.IsUnitySerializable == false && cache.IsCompositeType)
if (cache.IsUnitySerializable == false)
{
var foldoutStyle = EditorStyles.foldout;
Rect rect = GUILayoutUtility.GetRect(label, foldoutStyle);
rect.xMin += EcsGUI.Indent;
isExpanded = EditorGUI.BeginFoldoutHeaderGroup(rect, isExpanded, label, foldoutStyle, null, null);
isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(isExpanded, label, EditorStyles.foldout);
EditorGUILayout.EndFoldoutHeaderGroup();
if (isExpanded)
@ -410,8 +394,8 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
}
}
}
}
}
}
}
else
@ -446,21 +430,22 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
else
{
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
{
if (cache.IsCompositeType && fieldInfoData.IsPassToUnitySerialize)
if (fieldInfoData.IsPassToUnitySerialize)
{
wrapper.SO.Update();
wrapper.IsExpanded = isExpanded;
EditorGUILayout.PropertyField(wrapper.Property, label, true);
}
else
{
//EcsGUI.
EditorGUILayout.LabelField(label);
EditorGUILayout.LabelField(label, " ");
}
}
catch (ArgumentException)