mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2026-04-22 04:35:55 +08:00
Compare commits
No commits in common. "main" and "0.5.19" have entirely different histories.
11
README-RU.md
11
README-RU.md
@ -49,17 +49,18 @@
|
|||||||
- [Установка](#установка)
|
- [Установка](#установка)
|
||||||
- [Debug](#debug)
|
- [Debug](#debug)
|
||||||
- [Debug Сервис](#debug-сервис)
|
- [Debug Сервис](#debug-сервис)
|
||||||
|
- [Debug Модуль](#debug-модуль)
|
||||||
- [Визуальная отладка](#визуальная-отладка)
|
- [Визуальная отладка](#визуальная-отладка)
|
||||||
- [Шаблоны](#шаблоны)
|
- [Шаблоны](#шаблоны)
|
||||||
- [Связь с GameObject](#связь-с-gameobject)
|
- [Связь с GameObject](#связь-с-gameobject)
|
||||||
- [World Provider](#world-provider)
|
- [World Provider](#world-provider)
|
||||||
- [Шаблон Пайплайна](#шаблон-пайплайна)
|
- [Шаблон Пайплайна](#шаблон-пайплайна)
|
||||||
- [FixedUpdate и LateUpdate](#fixedupdate-и-lateupdate)
|
- [FixedUpdate LateUpdate](#fixedupdate-lateupdate)
|
||||||
- [Кастомизация инспектора](#Кастомизация-инспектора)
|
- [Кастомизация инспектора](#Кастомизация-инспектора)
|
||||||
- [Поддержка Jobs](#Поддержка-Jobs)
|
- [Поддержка Jobs](#Поддержка-Jobs)
|
||||||
- [Документация проекта](#документация-проекта)
|
- [Документация проекта](#документация-проекта)
|
||||||
- [Окно настроек](#окно-настроек)
|
- [Окно настроек](#окно-настроек)
|
||||||
- [Reference Repairer](#reference-repairer)
|
- [Reference Repairer](#Reference-Repairer)
|
||||||
- [FAQ](#faq)
|
- [FAQ](#faq)
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
@ -68,7 +69,7 @@
|
|||||||
Семантика версионирования - [Открыть](https://gist.github.com/DCFApixels/af79284955bf40e9476cdcac79d7b098#file-dcfapixels_versioning-md)
|
Семантика версионирования - [Открыть](https://gist.github.com/DCFApixels/af79284955bf40e9476cdcac79d7b098#file-dcfapixels_versioning-md)
|
||||||
## Окружение
|
## Окружение
|
||||||
Обязательные требования:
|
Обязательные требования:
|
||||||
+ Зависимость: [DragonECS](https://github.com/DCFApixels/DragonECS) `[1.0.0]`;
|
+ Зависимость: [DragonECS](https://github.com/DCFApixels/DragonECS)
|
||||||
+ Минимальная версия C# 8.0;
|
+ Минимальная версия C# 8.0;
|
||||||
+ Минимальная версия Unity 2021.2.0;
|
+ Минимальная версия Unity 2021.2.0;
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ _pipeline = EcsPipeline.New()
|
|||||||
Показывает состояние сущности мира, позволяет добавлять/изменять/удалять компоненты по время Play Mode. На каждую сущность в мире создается отдельный монитор. Все мониторы сущностей помещаются в монитор мира.
|
Показывает состояние сущности мира, позволяет добавлять/изменять/удалять компоненты по время Play Mode. На каждую сущность в мире создается отдельный монитор. Все мониторы сущностей помещаются в монитор мира.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://github.com/user-attachments/assets/fc7ac96d-a9a4-45bd-9695-e80f790495ef">
|
<img src="https://github.com/DCFApixels/DragonECS-Unity/assets/99481254/509ff472-05b5-4fd8-a0e6-739d7fa81ab1">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@ -598,7 +599,7 @@ private struct Job : IJobParallelFor
|
|||||||
В окне настроек доступно несколько опций, включая режимы отображения компонентов в инспекторе. Внизу находятся переключатели для define-переменных, используемых в фреймворке. Открыть окно настроек: `Tools > DragonECS > Settings`.
|
В окне настроек доступно несколько опций, включая режимы отображения компонентов в инспекторе. Внизу находятся переключатели для define-переменных, используемых в фреймворке. Открыть окно настроек: `Tools > DragonECS > Settings`.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://github.com/user-attachments/assets/905c03dd-d277-48b9-9963-455a09c4ceda">
|
<img src="https://github.com/DCFApixels/DragonECS-Unity/assets/99481254/c794be8d-6884-4415-b24a-0a1a28f577a6">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
|
|||||||
@ -48,6 +48,7 @@ This package integrates DragonECS with the Unity editor and runtime. It provides
|
|||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Debug](#debug)
|
- [Debug](#debug)
|
||||||
- [Debug service](#debug-service)
|
- [Debug service](#debug-service)
|
||||||
|
- [Debug module](#debug-module)
|
||||||
- [Visual debugging](#visual-debugging)
|
- [Visual debugging](#visual-debugging)
|
||||||
- [Templates](#templates)
|
- [Templates](#templates)
|
||||||
- [Binding to GameObjects](#binding-to-gameobjects)
|
- [Binding to GameObjects](#binding-to-gameobjects)
|
||||||
@ -68,7 +69,7 @@ Versioning semantics - [Open](https://gist.github.com/DCFApixels/af79284955bf40e
|
|||||||
|
|
||||||
## Environment
|
## Environment
|
||||||
Requirements:
|
Requirements:
|
||||||
- Dependency: [DragonECS](https://github.com/DCFApixels/DragonECS) `[1.0.0]`;
|
- Dependency: [DragonECS](https://github.com/DCFApixels/DragonECS)
|
||||||
- Minimum C# version: 8.0
|
- Minimum C# version: 8.0
|
||||||
- Minimum Unity version: 2021.2.0
|
- Minimum Unity version: 2021.2.0
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ Located together with `WorldMonitor`, shows a list of all Where queries that sys
|
|||||||
Displays entity state and allows adding, modifying or removing components at runtime (Play Mode). One monitor is created per entity; entity monitors are grouped under the corresponding world monitor.
|
Displays entity state and allows adding, modifying or removing components at runtime (Play Mode). One monitor is created per entity; entity monitors are grouped under the corresponding world monitor.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://github.com/user-attachments/assets/fc7ac96d-a9a4-45bd-9695-e80f790495ef">
|
<img src="https://github.com/DCFApixels/DragonECS-Unity/assets/99481254/509ff472-05b5-4fd8-a0e6-739d7fa81ab1">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@ -640,7 +641,7 @@ A documentation window based on meta-attributes is available via `Tools > Dragon
|
|||||||
The settings window exposes several options, including component display modes in the Inspector. At the bottom, toggles for framework define symbols are available. Open via `Tools > DragonECS > Settings`.
|
The settings window exposes several options, including component display modes in the Inspector. At the bottom, toggles for framework define symbols are available. Open via `Tools > DragonECS > Settings`.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://github.com/user-attachments/assets/905c03dd-d277-48b9-9963-455a09c4ceda">
|
<img src="https://github.com/DCFApixels/DragonECS-Unity/assets/99481254/c794be8d-6884-4415-b24a-0a1a28f577a6">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
"displayName": "DragonECS-Unity",
|
"displayName": "DragonECS-Unity",
|
||||||
"description": "Integration with Unity for DragonECS",
|
"description": "Integration with Unity for DragonECS",
|
||||||
"unity": "2021.2",
|
"unity": "2021.2",
|
||||||
"version": "0.6.0",
|
"version": "0.5.19",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/DCFApixels/DragonECS-Unity.git"
|
"url": "https://github.com/DCFApixels/DragonECS-Unity.git"
|
||||||
|
|||||||
@ -9,10 +9,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
[CanEditMultipleObjects]
|
[CanEditMultipleObjects]
|
||||||
internal class EcsEntityConnectEditor : ExtendedEditor<EcsEntityConnect>
|
internal class EcsEntityConnectEditor : ExtendedEditor<EcsEntityConnect>
|
||||||
{
|
{
|
||||||
public override bool RequiresConstantRepaint()
|
|
||||||
{
|
|
||||||
return UserSettingsPrefs.instance.RuntimeDrawMode == RuntimeDrawMode.Live ? true : base.RequiresConstantRepaint();
|
|
||||||
}
|
|
||||||
protected override void DrawCustom()
|
protected override void DrawCustom()
|
||||||
{
|
{
|
||||||
DrawEntityInfo();
|
DrawEntityInfo();
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
using (DragonGUI.SetBackgroundColor(labelBackColor))
|
using (DragonGUI.SetBackgroundColor(labelBackColor))
|
||||||
{
|
{
|
||||||
GUILayout.Box("Is Empty", UnityEditorUtility.GetWhiteStyleWithPadding(), GUILayout.ExpandWidth(true));
|
GUILayout.Box("Is Empty", UnityEditorUtility.GetWhiteStyle(), GUILayout.ExpandWidth(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
DragonGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw());
|
DragonGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw());
|
||||||
|
|||||||
@ -27,9 +27,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
{
|
{
|
||||||
var prefs = UserSettingsPrefs.instance;
|
var prefs = UserSettingsPrefs.instance;
|
||||||
|
float labelWidth = EditorGUIUtility.labelWidth;
|
||||||
|
EditorGUIUtility.labelWidth = 0f;
|
||||||
|
|
||||||
|
//float checkBoxWidth = 20f;
|
||||||
|
|
||||||
GUILayout.Space(20f);
|
GUILayout.Space(20f);
|
||||||
using (new DragonGUI.ColorScope(Color.white * 0.5f)) GUILayout.BeginVertical(EditorStyles.helpBox);
|
using (new DragonGUI.ColorScope(Color.white * 0.5f))
|
||||||
|
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||||
//using (new EcsGUI.ColorScope(Color.white * 1.2f))
|
//using (new EcsGUI.ColorScope(Color.white * 1.2f))
|
||||||
GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f));
|
GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f));
|
||||||
Rect rect = GUILayoutUtility.GetLastRect();
|
Rect rect = GUILayoutUtility.GetLastRect();
|
||||||
@ -52,10 +57,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsUseCustomNames)),
|
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsUseCustomNames)),
|
||||||
prefs.IsUseCustomNames);
|
prefs.IsUseCustomNames);
|
||||||
|
|
||||||
prefs.RuntimeDrawMode = (RuntimeDrawMode)EditorGUILayout.EnumPopup(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.RuntimeDrawMode)), prefs.RuntimeDrawMode);
|
prefs.ComponentColorMode = (ComponentColorMode)EditorGUILayout.EnumPopup(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.ComponentColorMode)), prefs.ComponentColorMode);
|
||||||
prefs.MetaBlockRectStyle = (MetaBlockRectStyle)EditorGUILayout.EnumPopup(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.MetaBlockRectStyle)), prefs.MetaBlockRectStyle);
|
|
||||||
prefs.MetaBlockColorMode = (MetaBlockColorMode)EditorGUILayout.EnumPopup(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.MetaBlockColorMode)), prefs.MetaBlockColorMode);
|
|
||||||
|
|
||||||
|
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
|
|
||||||
@ -85,6 +87,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
InitDefines();
|
InitDefines();
|
||||||
}
|
}
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
|
|
||||||
|
EditorGUIUtility.labelWidth = labelWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,18 +4,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS.Unity.Editors
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
{
|
{
|
||||||
internal enum RuntimeDrawMode
|
internal enum ComponentColorMode
|
||||||
{
|
|
||||||
Lazy = 0,
|
|
||||||
Live = 1,
|
|
||||||
}
|
|
||||||
internal enum MetaBlockRectStyle
|
|
||||||
{
|
|
||||||
Clean = 0,
|
|
||||||
Edge = 1,
|
|
||||||
Fill = 2,
|
|
||||||
}
|
|
||||||
internal enum MetaBlockColorMode
|
|
||||||
{
|
{
|
||||||
Generic = 0,
|
Generic = 0,
|
||||||
Auto = 1,
|
Auto = 1,
|
||||||
@ -110,45 +99,15 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private RuntimeDrawMode _runtimeDrawMode = RuntimeDrawMode.Live;
|
private ComponentColorMode _componentColorMode = ComponentColorMode.Auto;
|
||||||
public RuntimeDrawMode RuntimeDrawMode
|
public ComponentColorMode ComponentColorMode
|
||||||
{
|
{
|
||||||
get => _runtimeDrawMode;
|
get => _componentColorMode;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_runtimeDrawMode != value)
|
if (_componentColorMode != value)
|
||||||
{
|
{
|
||||||
_runtimeDrawMode = value;
|
_componentColorMode = value;
|
||||||
AutoSave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
private MetaBlockRectStyle _metaBlockRectStyle = MetaBlockRectStyle.Fill;
|
|
||||||
public MetaBlockRectStyle MetaBlockRectStyle
|
|
||||||
{
|
|
||||||
get => _metaBlockRectStyle;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_metaBlockRectStyle != value)
|
|
||||||
{
|
|
||||||
_metaBlockRectStyle = value;
|
|
||||||
AutoSave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[SerializeField]
|
|
||||||
private MetaBlockColorMode _metaBlockColorMode = MetaBlockColorMode.Auto;
|
|
||||||
public MetaBlockColorMode MetaBlockColorMode
|
|
||||||
{
|
|
||||||
get => _metaBlockColorMode;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_metaBlockColorMode != value)
|
|
||||||
{
|
|
||||||
_metaBlockColorMode = value;
|
|
||||||
AutoSave();
|
AutoSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,10 +8,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
[CustomEditor(typeof(EntityMonitor))]
|
[CustomEditor(typeof(EntityMonitor))]
|
||||||
internal class EntityMonitorEditor : ExtendedEditor<EntityMonitor>
|
internal class EntityMonitorEditor : ExtendedEditor<EntityMonitor>
|
||||||
{
|
{
|
||||||
public override bool RequiresConstantRepaint()
|
|
||||||
{
|
|
||||||
return UserSettingsPrefs.instance.RuntimeDrawMode == RuntimeDrawMode.Live ? true : base.RequiresConstantRepaint();
|
|
||||||
}
|
|
||||||
protected override void DrawCustom()
|
protected override void DrawCustom()
|
||||||
{
|
{
|
||||||
var entity = Target.Entity;
|
var entity = Target.Entity;
|
||||||
|
|||||||
@ -222,18 +222,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
public VerticalScope(GUILayoutOption[] options) { GUILayout.BeginVertical(options); }
|
public VerticalScope(GUILayoutOption[] options) { GUILayout.BeginVertical(options); }
|
||||||
public VerticalScope(GUIStyle style, GUILayoutOption[] options) { GUILayout.BeginVertical(style, options); }
|
public VerticalScope(GUIStyle style, GUILayoutOption[] options) { GUILayout.BeginVertical(style, options); }
|
||||||
public VerticalScope(GUIStyle style, Color backgroundColor, GUILayoutOption[] options)
|
|
||||||
{
|
|
||||||
using (SetColor(backgroundColor))
|
|
||||||
{
|
|
||||||
GUILayout.BeginVertical(style, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public VerticalScope(Color backgroundColor, GUILayoutOption[] options)
|
public VerticalScope(Color backgroundColor, GUILayoutOption[] options)
|
||||||
{
|
{
|
||||||
using (SetColor(backgroundColor))
|
using (SetColor(backgroundColor))
|
||||||
{
|
{
|
||||||
GUILayout.BeginVertical(UnityEditorUtility.GetWhiteStyleWithPadding(), options);
|
GUILayout.BeginVertical(UnityEditorUtility.GetWhiteStyle(), options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Dispose() { GUILayout.EndVertical(); }
|
public void Dispose() { GUILayout.EndVertical(); }
|
||||||
@ -246,7 +239,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
using (SetColor(backgroundColor))
|
using (SetColor(backgroundColor))
|
||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal(UnityEditorUtility.GetWhiteStyleWithPadding(), options);
|
GUILayout.BeginHorizontal(UnityEditorUtility.GetWhiteStyle(), options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Dispose() { GUILayout.EndHorizontal(); }
|
public void Dispose() { GUILayout.EndHorizontal(); }
|
||||||
@ -269,7 +262,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
public static VerticalScope BeginVertical(params GUILayoutOption[] options) => new VerticalScope(options);
|
public static VerticalScope BeginVertical(params GUILayoutOption[] options) => new VerticalScope(options);
|
||||||
public static VerticalScope BeginVertical(GUIStyle style, params GUILayoutOption[] options) => new VerticalScope(style, options);
|
public static VerticalScope BeginVertical(GUIStyle style, params GUILayoutOption[] options) => new VerticalScope(style, options);
|
||||||
public static VerticalScope BeginVertical(Color backgroundColor, params GUILayoutOption[] options) => new VerticalScope(backgroundColor, options);
|
public static VerticalScope BeginVertical(Color backgroundColor, params GUILayoutOption[] options) => new VerticalScope(backgroundColor, options);
|
||||||
public static VerticalScope BeginVertical(GUIStyle style, Color backgroundColor, params GUILayoutOption[] options) => new VerticalScope(style, backgroundColor, options);
|
|
||||||
}
|
}
|
||||||
public static CheckChangedScope CheckChanged() => CheckChangedScope.New();
|
public static CheckChangedScope CheckChanged() => CheckChangedScope.New();
|
||||||
public static CheckChangedScopeWithAutoApply CheckChanged(SerializedObject serializedObject) => new CheckChangedScopeWithAutoApply(serializedObject);
|
public static CheckChangedScopeWithAutoApply CheckChanged(SerializedObject serializedObject) => new CheckChangedScopeWithAutoApply(serializedObject);
|
||||||
@ -331,10 +323,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
get => EditorGUIUtility.standardVerticalSpacing;
|
get => EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
private static MetaBlockColorMode MetaBlockColorMode
|
private static ComponentColorMode AutoColorMode
|
||||||
{
|
{
|
||||||
get { return UserSettingsPrefs.instance.MetaBlockColorMode; }
|
get { return UserSettingsPrefs.instance.ComponentColorMode; }
|
||||||
set { UserSettingsPrefs.instance.MetaBlockColorMode = value; }
|
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
|
||||||
}
|
}
|
||||||
private static bool IsShowHidden
|
private static bool IsShowHidden
|
||||||
{
|
{
|
||||||
@ -792,7 +784,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
if (meta == null)
|
if (meta == null)
|
||||||
{
|
{
|
||||||
EditorGUI.DrawRect(rect, Color.black.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha));
|
EditorGUI.DrawRect(rect, Color.black.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA));
|
||||||
return (DrawTypeMetaBlockResultFlags.None, 0f);
|
return (DrawTypeMetaBlockResultFlags.None, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,34 +803,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Event.current.type == EventType.Repaint)
|
Color panelColor = SelectPanelColor(meta, positionIndex, total)
|
||||||
{
|
.Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE)
|
||||||
switch (UserSettingsPrefs.instance.MetaBlockRectStyle)
|
.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA);
|
||||||
{
|
|
||||||
default:
|
EditorGUI.DrawRect(rect, panelColor);
|
||||||
case MetaBlockRectStyle.Clean:
|
|
||||||
{
|
|
||||||
EditorGUI.DrawRect(rect, Color.white.SetAlpha(EscEditorConsts.MetaBlockCleanStyle_Alpha));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MetaBlockRectStyle.Edge:
|
|
||||||
{
|
|
||||||
EditorGUI.DrawRect(rect, Color.white.SetAlpha(EscEditorConsts.MetaBlockCleanStyle_Alpha));
|
|
||||||
Color panelColor = SelectPanelColor(meta, positionIndex, total)
|
|
||||||
.SetAlpha(EscEditorConsts.MetaBlockEdgeStyle_Alpha);
|
|
||||||
EditorGUI.DrawRect(rect.HorizontalGetLeft(4f), panelColor);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MetaBlockRectStyle.Fill:
|
|
||||||
{
|
|
||||||
Color panelColor = SelectPanelColor(meta, positionIndex, total)
|
|
||||||
.Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE)
|
|
||||||
.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha);
|
|
||||||
EditorGUI.DrawRect(rect, panelColor);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float optionsWidth = 0f;
|
float optionsWidth = 0f;
|
||||||
Rect optionRect = rect;
|
Rect optionRect = rect;
|
||||||
@ -904,11 +873,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
internal static bool IsNullManagedReference(this SerializedProperty property)
|
internal static bool IsNullManagedReference(this SerializedProperty property)
|
||||||
{
|
{
|
||||||
#if UNITY_2021_3_OR_NEWER
|
|
||||||
return property.managedReferenceId == ManagedReferenceUtility.RefIdNull;
|
return property.managedReferenceId == ManagedReferenceUtility.RefIdNull;
|
||||||
#else
|
|
||||||
return property.managedReferenceId == SerializationUtility.RefIdNull;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
internal static int GetChildPropertiesCount(this SerializedProperty property, Type type, out bool isEmpty)
|
internal static int GetChildPropertiesCount(this SerializedProperty property, Type type, out bool isEmpty)
|
||||||
{
|
{
|
||||||
@ -961,13 +926,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (MetaBlockColorMode)
|
switch (AutoColorMode)
|
||||||
{
|
{
|
||||||
case MetaBlockColorMode.Auto:
|
case ComponentColorMode.Auto:
|
||||||
{
|
{
|
||||||
return color.ToUnityColor().Desaturate(0.48f) / 1.18f; //.Desaturate(0.48f) / 1.18f;
|
return color.ToUnityColor().Desaturate(0.48f) / 1.18f; //.Desaturate(0.48f) / 1.18f;
|
||||||
}
|
}
|
||||||
case MetaBlockColorMode.Rainbow:
|
case ComponentColorMode.Rainbow:
|
||||||
{
|
{
|
||||||
int localTotal = Mathf.Max(total, EscEditorConsts.AUTO_COLOR_RAINBOW_MIN_RANGE);
|
int localTotal = Mathf.Max(total, EscEditorConsts.AUTO_COLOR_RAINBOW_MIN_RANGE);
|
||||||
Color hsv = Color.HSVToRGB(1f / localTotal * (index % localTotal), 1, 1);
|
Color hsv = Color.HSVToRGB(1f / localTotal * (index % localTotal), 1, 1);
|
||||||
|
|||||||
@ -4,16 +4,16 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS.Unity.Editors
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
{
|
{
|
||||||
internal class ExpandStack
|
internal class ExpandMatrix
|
||||||
{
|
{
|
||||||
private const bool TOP_DEFAULT = true;
|
private const bool TOP_DEFAULT = true;
|
||||||
private const bool DEFAULT = false;
|
private const bool DEFAULT = false;
|
||||||
private static Dictionary<Type, ExpandStack> _instances = new Dictionary<Type, ExpandStack>();
|
private static Dictionary<Type, ExpandMatrix> _instances = new Dictionary<Type, ExpandMatrix>();
|
||||||
public static ExpandStack Take(Type type)
|
public static ExpandMatrix Take(Type type)
|
||||||
{
|
{
|
||||||
if (_instances.TryGetValue(type, out ExpandStack result) == false)
|
if (_instances.TryGetValue(type, out ExpandMatrix result) == false)
|
||||||
{
|
{
|
||||||
result = new ExpandStack();
|
result = new ExpandMatrix();
|
||||||
_instances.Add(type, result);
|
_instances.Add(type, result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -47,10 +47,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
get { return UserSettingsPrefs.instance.IsShowRuntimeComponents; }
|
get { return UserSettingsPrefs.instance.IsShowRuntimeComponents; }
|
||||||
set { UserSettingsPrefs.instance.IsShowRuntimeComponents = value; }
|
set { UserSettingsPrefs.instance.IsShowRuntimeComponents = value; }
|
||||||
}
|
}
|
||||||
protected static MetaBlockColorMode ComponentColorMode
|
protected static ComponentColorMode ComponentColorMode
|
||||||
{
|
{
|
||||||
get { return UserSettingsPrefs.instance.MetaBlockColorMode; }
|
get { return UserSettingsPrefs.instance.ComponentColorMode; }
|
||||||
set { UserSettingsPrefs.instance.MetaBlockColorMode = value; }
|
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool IsMultipleTargets => targets.Length > 1;
|
protected bool IsMultipleTargets => targets.Length > 1;
|
||||||
@ -210,10 +210,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
get { return UserSettingsPrefs.instance.IsShowRuntimeComponents; }
|
get { return UserSettingsPrefs.instance.IsShowRuntimeComponents; }
|
||||||
set { UserSettingsPrefs.instance.IsShowRuntimeComponents = value; }
|
set { UserSettingsPrefs.instance.IsShowRuntimeComponents = value; }
|
||||||
}
|
}
|
||||||
protected static MetaBlockColorMode ComponentColorMode
|
protected static ComponentColorMode ComponentColorMode
|
||||||
{
|
{
|
||||||
get { return UserSettingsPrefs.instance.MetaBlockColorMode; }
|
get { return UserSettingsPrefs.instance.ComponentColorMode; }
|
||||||
set { UserSettingsPrefs.instance.MetaBlockColorMode = value; }
|
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
|
||||||
}
|
}
|
||||||
protected virtual bool IsStaticInit { get { return _isStaticInit; } }
|
protected virtual bool IsStaticInit { get { return _isStaticInit; } }
|
||||||
protected virtual bool IsInit { get { return _isInit; } }
|
protected virtual bool IsInit { get { return _isInit; } }
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using DCFApixels.DragonECS.Core;
|
|
||||||
using DCFApixels.DragonECS.Unity.Internal;
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -45,10 +44,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
|
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
private static RuntimeDrawMode RuntimeDrawMode
|
private static ComponentColorMode AutoColorMode
|
||||||
{
|
{
|
||||||
get { return UserSettingsPrefs.instance.RuntimeDrawMode; }
|
get { return UserSettingsPrefs.instance.ComponentColorMode; }
|
||||||
set { UserSettingsPrefs.instance.RuntimeDrawMode = value; }
|
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
|
||||||
}
|
}
|
||||||
private static bool IsShowHidden
|
private static bool IsShowHidden
|
||||||
{
|
{
|
||||||
@ -66,7 +65,6 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
internal class RuntimeComponentReflectionCache
|
internal class RuntimeComponentReflectionCache
|
||||||
{
|
{
|
||||||
public readonly Type Type;
|
public readonly Type Type;
|
||||||
public readonly bool IsValueType;
|
|
||||||
public readonly bool IsUnmanaged;
|
public readonly bool IsUnmanaged;
|
||||||
public readonly DrawerType DrawerType;
|
public readonly DrawerType DrawerType;
|
||||||
public readonly FieldInfoData[] Fields;
|
public readonly FieldInfoData[] Fields;
|
||||||
@ -76,12 +74,12 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
return _wrappers[depth];
|
return _wrappers[depth];
|
||||||
}
|
}
|
||||||
|
|
||||||
public RuntimeComponentReflectionCache(Type type)
|
public RuntimeComponentReflectionCache(Type type)
|
||||||
{
|
{
|
||||||
Type = type;
|
Type = type;
|
||||||
ResetWrappers();
|
ResetWrappers();
|
||||||
IsUnmanaged = UnsafeUtility.IsUnmanaged(type);
|
IsUnmanaged = UnsafeUtility.IsUnmanaged(type);
|
||||||
IsValueType = type.IsValueType;
|
|
||||||
|
|
||||||
bool isVoideType = type == typeof(void);
|
bool isVoideType = type == typeof(void);
|
||||||
bool isUnityObjectType = typeof(UnityObject).IsAssignableFrom(type);
|
bool isUnityObjectType = typeof(UnityObject).IsAssignableFrom(type);
|
||||||
@ -268,7 +266,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
|
|
||||||
object data = cmp.GetRaw(worldID);
|
object data = cmp.GetRaw(worldID);
|
||||||
|
|
||||||
ExpandStack expandStack = ExpandStack.Take(componentType);
|
ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType);
|
||||||
|
|
||||||
float padding = EditorGUIUtility.standardVerticalSpacing;
|
float padding = EditorGUIUtility.standardVerticalSpacing;
|
||||||
Rect optionButton = GUILayoutUtility.GetLastRect();
|
Rect optionButton = GUILayoutUtility.GetLastRect();
|
||||||
@ -279,14 +277,15 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
//Canceling isExpanded
|
//Canceling isExpanded
|
||||||
if (DragonGUI.ClickTest(optionButton))
|
if (DragonGUI.ClickTest(optionButton))
|
||||||
{
|
{
|
||||||
ref bool isExpanded = ref expandStack.Down();
|
ref bool isExpanded = ref expandMatrix.Down();
|
||||||
isExpanded = !isExpanded;
|
isExpanded = !isExpanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color panelColor = DragonGUI.SelectPanelColor(meta, index, total);
|
Color panelColor = DragonGUI.SelectPanelColor(meta, index, total);
|
||||||
|
using (DragonGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA)))
|
||||||
using (DragonGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha)))
|
|
||||||
{
|
{
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
//Edit script button
|
//Edit script button
|
||||||
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
|
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
|
||||||
{
|
{
|
||||||
@ -301,7 +300,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
}
|
}
|
||||||
|
|
||||||
RuntimeComponentReflectionCache.FieldInfoData componentInfoData = new RuntimeComponentReflectionCache.FieldInfoData(null, componentType, meta.Name);
|
RuntimeComponentReflectionCache.FieldInfoData componentInfoData = new RuntimeComponentReflectionCache.FieldInfoData(null, componentType, meta.Name);
|
||||||
if (DrawRuntimeData(ref componentInfoData, UnityEditorUtility.GetLabel(meta.Name), expandStack, data, out object resultData, 0))
|
if (DrawRuntimeData(ref componentInfoData, UnityEditorUtility.GetLabel(meta.Name), expandMatrix, data, out object resultData, 0))
|
||||||
{
|
{
|
||||||
cmp.SetRaw(worldID, resultData);
|
cmp.SetRaw(worldID, resultData);
|
||||||
}
|
}
|
||||||
@ -356,171 +355,31 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
RuntimeComponentsUtility.GetAddComponentGenericMenu(world).Open(dropDownRect, entityID);
|
RuntimeComponentsUtility.GetAddComponentGenericMenu(world).Open(dropDownRect, entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (DragonGUI.Layout.BeginVertical(Color.white.SetAlpha(0.066f)))
|
using (DragonGUI.SetBackgroundColor(GUI.color.SetAlpha(0.16f)))
|
||||||
{
|
{
|
||||||
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden);
|
GUILayout.Box("", UnityEditorUtility.GetWhiteStyle(), GUILayout.ExpandWidth(true));
|
||||||
RuntimeDrawMode = (RuntimeDrawMode)EditorGUILayout.EnumPopup("Draw Mode", selected: RuntimeDrawMode);
|
|
||||||
}
|
}
|
||||||
|
IsShowHidden = EditorGUI.Toggle(GUILayoutUtility.GetLastRect(), "Show Hidden", IsShowHidden);
|
||||||
|
|
||||||
|
|
||||||
world.GetComponentPoolsFor(entityID, _componentPoolsBuffer);
|
world.GetComponentPoolsFor(entityID, _componentPoolsBuffer);
|
||||||
for (int i = 0; i < _componentPoolsBuffer.Count; i++)
|
for (int i = 0; i < _componentPoolsBuffer.Count; i++)
|
||||||
{
|
{
|
||||||
var pool = _componentPoolsBuffer[i];
|
DrawRuntimeComponent(entityID, _componentPoolsBuffer[i], 9, i);
|
||||||
if (pool.ComponentType.IsValueType)
|
|
||||||
{
|
|
||||||
DrawRuntimeValueComponent(entityID, pool, 9, i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DrawRuntimeClassComponent(entityID, pool, 9, i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private struct DrawRuntimeCompoentnsCahce : IEcsWorldComponent<DrawRuntimeCompoentnsCahce>
|
private void DrawRuntimeComponent(int entityID, IEcsPool pool, int total, int index)
|
||||||
{
|
{
|
||||||
public EcsWorld World;
|
var meta = pool.ComponentType.GetMeta();
|
||||||
public Record[] Records;
|
|
||||||
|
|
||||||
void IEcsWorldComponent<DrawRuntimeCompoentnsCahce>.Init(ref DrawRuntimeCompoentnsCahce component, EcsWorld world)
|
|
||||||
{
|
|
||||||
component.World = world;
|
|
||||||
component.Records = new Record[world.Count];
|
|
||||||
}
|
|
||||||
void IEcsWorldComponent<DrawRuntimeCompoentnsCahce>.OnDestroy(ref DrawRuntimeCompoentnsCahce component, EcsWorld world) { }
|
|
||||||
|
|
||||||
public ref Record GetFor(int componentTypeID)
|
|
||||||
{
|
|
||||||
if(componentTypeID >= Records.Length)
|
|
||||||
{
|
|
||||||
var newSize = DragonArrayUtility.NextPow2(componentTypeID + 1);
|
|
||||||
Array.Resize(ref Records, newSize);
|
|
||||||
}
|
|
||||||
ref var result = ref Records[componentTypeID];
|
|
||||||
if(result.IsInit == false && World.TryFindPoolInstance(componentTypeID, out var pool))
|
|
||||||
{
|
|
||||||
var componentType = pool.ComponentType;
|
|
||||||
result.Meta = componentType.GetMeta();
|
|
||||||
result.ExpandStack = ExpandStack.Take(componentType);
|
|
||||||
result.FieldInfoData = new RuntimeComponentReflectionCache.FieldInfoData(null, componentType, result.Meta.Name);
|
|
||||||
if (ScriptsCache.TryGetScriptAsset(result.Meta, out result.ScriptReference) == false)
|
|
||||||
{
|
|
||||||
result.ScriptReference = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.IsInit = true;
|
|
||||||
}
|
|
||||||
return ref result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct Record
|
|
||||||
{
|
|
||||||
public bool IsInit;
|
|
||||||
public TypeMeta Meta;
|
|
||||||
public ExpandStack ExpandStack;
|
|
||||||
public RuntimeComponentReflectionCache.FieldInfoData FieldInfoData;
|
|
||||||
public MonoScript ScriptReference;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawRuntimeValueComponent(int entityID, IEcsPool pool, int total, int index)
|
|
||||||
{
|
|
||||||
ref var cache = ref pool.World.Get<DrawRuntimeCompoentnsCahce>().GetFor(pool.ComponentTypeID);
|
|
||||||
|
|
||||||
var meta = cache.Meta;
|
|
||||||
if (meta.IsHidden == false || IsShowHidden)
|
if (meta.IsHidden == false || IsShowHidden)
|
||||||
{
|
{
|
||||||
float padding = EditorGUIUtility.standardVerticalSpacing;
|
Type componentType = pool.ComponentType;
|
||||||
Rect optionButton = GUILayoutUtility.GetLastRect();
|
|
||||||
optionButton.yMin = optionButton.yMax;
|
|
||||||
optionButton.yMax += DragonGUI.HeadIconsRect.height;
|
|
||||||
optionButton.xMin = optionButton.xMax - 64;
|
|
||||||
optionButton.center += Vector2.up * padding * 2f;
|
|
||||||
|
|
||||||
Color fillColor = Color.clear;
|
object data = pool.GetRaw(entityID);
|
||||||
Color backColor = Color.clear;
|
|
||||||
if (Event.current.type == EventType.Repaint)
|
|
||||||
{
|
|
||||||
switch (UserSettingsPrefs.instance.MetaBlockRectStyle)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case MetaBlockRectStyle.Clean:
|
|
||||||
{
|
|
||||||
backColor = Color.white.SetAlpha(EscEditorConsts.MetaBlockCleanStyle_Alpha);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MetaBlockRectStyle.Edge:
|
|
||||||
{
|
|
||||||
backColor = Color.white.SetAlpha(EscEditorConsts.MetaBlockCleanStyle_Alpha);
|
|
||||||
fillColor = DragonGUI.SelectPanelColor(meta, index, total)
|
|
||||||
.SetAlpha(EscEditorConsts.MetaBlockEdgeStyle_Alpha);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MetaBlockRectStyle.Fill:
|
|
||||||
{
|
|
||||||
backColor = DragonGUI.SelectPanelColor(meta, index, total)
|
|
||||||
.Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE)
|
|
||||||
.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetWhiteStyle(), backColor))
|
ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType);
|
||||||
{
|
|
||||||
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetWhiteEdge4Style(), fillColor))
|
|
||||||
{
|
|
||||||
//Close button
|
|
||||||
optionButton.xMin = optionButton.xMax - DragonGUI.HeadIconsRect.width;
|
|
||||||
if (DragonGUI.CloseButton(optionButton))
|
|
||||||
{
|
|
||||||
pool.Del(entityID);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//Edit script button
|
|
||||||
if (cache.ScriptReference != null)
|
|
||||||
{
|
|
||||||
optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
|
||||||
DragonGUI.ScriptAssetButton(optionButton, cache.ScriptReference);
|
|
||||||
}
|
|
||||||
//Description icon
|
|
||||||
if (string.IsNullOrEmpty(meta.Description.Text) == false)
|
|
||||||
{
|
|
||||||
optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
|
||||||
DragonGUI.DescriptionIcon(optionButton, meta.Description.Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ref bool peakExpand = ref cache.ExpandStack.Peek();
|
|
||||||
var label = UnityEditorUtility.GetLabel(meta.Name);
|
|
||||||
if (peakExpand)
|
|
||||||
{
|
|
||||||
object data = pool.GetRaw(entityID);
|
|
||||||
if (DrawRuntimeData(ref cache.FieldInfoData, label, cache.ExpandStack, data, out object resultData, 0))
|
|
||||||
{
|
|
||||||
pool.SetRaw(entityID, resultData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var foldoutStyle = EditorStyles.foldout;
|
|
||||||
Rect rect = GUILayoutUtility.GetRect(label, foldoutStyle);
|
|
||||||
peakExpand = EditorGUI.BeginFoldoutHeaderGroup(rect, false, label, foldoutStyle, null, null);
|
|
||||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void DrawRuntimeClassComponent(int entityID, IEcsPool pool, int total, int index)
|
|
||||||
{
|
|
||||||
object data = pool.GetRaw(entityID);
|
|
||||||
Type componentType = data.GetType();
|
|
||||||
var meta = componentType.GetMeta();
|
|
||||||
if (meta.IsHidden == false || IsShowHidden)
|
|
||||||
{
|
|
||||||
ExpandStack expandStack = ExpandStack.Take(componentType);
|
|
||||||
|
|
||||||
float padding = EditorGUIUtility.standardVerticalSpacing;
|
float padding = EditorGUIUtility.standardVerticalSpacing;
|
||||||
Rect optionButton = GUILayoutUtility.GetLastRect();
|
Rect optionButton = GUILayoutUtility.GetLastRect();
|
||||||
@ -528,67 +387,44 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
optionButton.yMax += DragonGUI.HeadIconsRect.height;
|
optionButton.yMax += DragonGUI.HeadIconsRect.height;
|
||||||
optionButton.xMin = optionButton.xMax - 64;
|
optionButton.xMin = optionButton.xMax - 64;
|
||||||
optionButton.center += Vector2.up * padding * 2f;
|
optionButton.center += Vector2.up * padding * 2f;
|
||||||
|
//Canceling isExpanded
|
||||||
Color fillColor = Color.clear;
|
if (DragonGUI.ClickTest(optionButton))
|
||||||
Color backColor = Color.clear;
|
|
||||||
if (Event.current.type == EventType.Repaint)
|
|
||||||
{
|
{
|
||||||
switch (UserSettingsPrefs.instance.MetaBlockRectStyle)
|
ref bool isExpanded = ref expandMatrix.Down();
|
||||||
{
|
isExpanded = !isExpanded;
|
||||||
default:
|
|
||||||
case MetaBlockRectStyle.Clean:
|
|
||||||
{
|
|
||||||
backColor = Color.white.SetAlpha(EscEditorConsts.MetaBlockCleanStyle_Alpha);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MetaBlockRectStyle.Edge:
|
|
||||||
{
|
|
||||||
backColor = Color.white.SetAlpha(EscEditorConsts.MetaBlockCleanStyle_Alpha);
|
|
||||||
fillColor = DragonGUI.SelectPanelColor(meta, index, total)
|
|
||||||
.SetAlpha(EscEditorConsts.MetaBlockEdgeStyle_Alpha);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MetaBlockRectStyle.Fill:
|
|
||||||
{
|
|
||||||
backColor = DragonGUI.SelectPanelColor(meta, index, total)
|
|
||||||
.Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE)
|
|
||||||
.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color panelColor = DragonGUI.SelectPanelColor(meta, index, total);
|
||||||
|
|
||||||
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetWhiteStyle(), backColor))
|
using (DragonGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA)))
|
||||||
{
|
{
|
||||||
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetWhiteEdge4Style(), fillColor))
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
|
//Close button
|
||||||
|
optionButton.xMin = optionButton.xMax - DragonGUI.HeadIconsRect.width;
|
||||||
|
if (DragonGUI.CloseButton(optionButton))
|
||||||
{
|
{
|
||||||
//Close button
|
pool.Del(entityID);
|
||||||
optionButton.xMin = optionButton.xMax - DragonGUI.HeadIconsRect.width;
|
return;
|
||||||
if (DragonGUI.CloseButton(optionButton))
|
}
|
||||||
{
|
//Edit script button
|
||||||
pool.Del(entityID);
|
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
|
||||||
return;
|
{
|
||||||
}
|
optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
||||||
//Edit script button
|
DragonGUI.ScriptAssetButton(optionButton, script);
|
||||||
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
|
}
|
||||||
{
|
//Description icon
|
||||||
optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
if (string.IsNullOrEmpty(meta.Description.Text) == false)
|
||||||
DragonGUI.ScriptAssetButton(optionButton, script);
|
{
|
||||||
}
|
optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
||||||
//Description icon
|
DragonGUI.DescriptionIcon(optionButton, meta.Description.Text);
|
||||||
if (string.IsNullOrEmpty(meta.Description.Text) == false)
|
}
|
||||||
{
|
|
||||||
optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
|
||||||
DragonGUI.DescriptionIcon(optionButton, meta.Description.Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
RuntimeComponentReflectionCache.FieldInfoData componentInfoData = new RuntimeComponentReflectionCache.FieldInfoData(null, componentType, meta.Name);
|
RuntimeComponentReflectionCache.FieldInfoData componentInfoData = new RuntimeComponentReflectionCache.FieldInfoData(null, componentType, meta.Name);
|
||||||
|
|
||||||
if (DrawRuntimeData(ref componentInfoData, UnityEditorUtility.GetLabel(meta.Name), expandStack, data, out object resultData, 0))
|
if (DrawRuntimeData(ref componentInfoData, UnityEditorUtility.GetLabel(meta.Name), expandMatrix, data, out object resultData, 0))
|
||||||
{
|
{
|
||||||
pool.SetRaw(entityID, resultData);
|
pool.SetRaw(entityID, resultData);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -598,12 +434,13 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
|
|
||||||
|
|
||||||
#region draw data
|
#region draw data
|
||||||
private bool DrawRuntimeData(ref RuntimeComponentReflectionCache.FieldInfoData fieldInfoData, GUIContent label, ExpandStack expandStack, object data, out object outData, int depth)
|
private bool DrawRuntimeData(ref RuntimeComponentReflectionCache.FieldInfoData fieldInfoData, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData, int depth)
|
||||||
{
|
{
|
||||||
const int DEPTH_MAX = 24;
|
const int DEPTH_MAX = 24;
|
||||||
|
|
||||||
using (DragonGUI.CheckChanged())
|
using (DragonGUI.CheckChanged())
|
||||||
{
|
{
|
||||||
|
|
||||||
outData = data;
|
outData = data;
|
||||||
object newData = data;
|
object newData = data;
|
||||||
Type type = data == null ? typeof(void) : data.GetType();
|
Type type = data == null ? typeof(void) : data.GetType();
|
||||||
@ -614,19 +451,19 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var reflectionCache = fieldInfoData.GetReflectionCache(type);
|
RuntimeComponentReflectionCache cache = fieldInfoData.GetReflectionCache(type);
|
||||||
if (depth >= DEPTH_MAX || reflectionCache == null)
|
if (depth >= DEPTH_MAX || cache == null)
|
||||||
{
|
{
|
||||||
EditorGUILayout.TextField(label, "error");
|
EditorGUILayout.TextField(label, "error");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ref bool isExpanded = ref expandStack.Down();
|
ref bool isExpanded = ref expandMatrix.Down();
|
||||||
bool childElementChanged = false;
|
bool childElementChanged = false;
|
||||||
var eventType = Event.current.type;
|
var eventType = Event.current.type;
|
||||||
|
|
||||||
var label2 = "-";
|
var label2 = "-";
|
||||||
var drawerType = reflectionCache.DrawerType;
|
var drawerType = cache.DrawerType;
|
||||||
|
|
||||||
if (isUnityObjectField)
|
if (isUnityObjectField)
|
||||||
{
|
{
|
||||||
@ -635,260 +472,230 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
switch (drawerType)
|
switch (drawerType)
|
||||||
{
|
{
|
||||||
case DrawerType.UNDEFINED:
|
case DrawerType.UNDEFINED:
|
||||||
{
|
EditorGUILayout.LabelField(label, label2);
|
||||||
EditorGUILayout.LabelField(label, label2);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case DrawerType.Ignored:
|
case DrawerType.Ignored:
|
||||||
{
|
EditorGUILayout.LabelField(label, label2);
|
||||||
EditorGUILayout.LabelField(label, label2);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case DrawerType.UnitySerializableComposite:
|
case DrawerType.UnitySerializableComposite:
|
||||||
{
|
|
||||||
using (DragonGUI.CheckChanged())
|
|
||||||
{
|
|
||||||
RefEditorWrapper wrapper = reflectionCache.GetWrapper(_runtimeComponentsDepth);
|
|
||||||
wrapper.data = data;
|
|
||||||
wrapper.SO.Update();
|
|
||||||
wrapper.IsExpanded = isExpanded;
|
|
||||||
EditorGUILayout.PropertyField(wrapper.Property, label, true);
|
|
||||||
|
|
||||||
if (DragonGUI.Changed)
|
using (DragonGUI.CheckChanged())
|
||||||
{
|
{
|
||||||
wrapper.SO.ApplyModifiedProperties();
|
RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth);
|
||||||
newData = wrapper.Data;
|
wrapper.data = data;
|
||||||
childElementChanged = true;
|
wrapper.SO.Update();
|
||||||
}
|
wrapper.IsExpanded = isExpanded;
|
||||||
isExpanded = wrapper.IsExpanded;
|
EditorGUILayout.PropertyField(wrapper.Property, label, true);
|
||||||
|
|
||||||
|
if (DragonGUI.Changed)
|
||||||
|
{
|
||||||
|
wrapper.SO.ApplyModifiedProperties();
|
||||||
|
newData = wrapper.Data;
|
||||||
|
childElementChanged = true;
|
||||||
}
|
}
|
||||||
|
isExpanded = wrapper.IsExpanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DrawerType.UnityNotSerializableComposite:
|
case DrawerType.UnityNotSerializableComposite:
|
||||||
{
|
|
||||||
GUILayout.Space(DragonGUI.Spacing);
|
|
||||||
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();
|
|
||||||
|
|
||||||
if (isExpanded)
|
GUILayout.Space(DragonGUI.Spacing);
|
||||||
|
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();
|
||||||
|
|
||||||
|
if (isExpanded)
|
||||||
|
{
|
||||||
|
using (DragonGUI.UpIndentLevel())
|
||||||
{
|
{
|
||||||
using (DragonGUI.UpIndentLevel())
|
for (int j = 0, jMax = cache.Fields.Length; j < jMax; j++)
|
||||||
{
|
{
|
||||||
for (int j = 0, jMax = reflectionCache.Fields.Length; j < jMax; j++)
|
var field = cache.Fields[j];
|
||||||
|
if (DrawRuntimeData(ref field, UnityEditorUtility.GetLabel(field.UnityFormatName), expandMatrix, field.FieldInfo.GetValue(data), out object fieldData, depth + 1))
|
||||||
{
|
{
|
||||||
var field = reflectionCache.Fields[j];
|
field.FieldInfo.SetValue(data, fieldData);
|
||||||
if (DrawRuntimeData(ref field, UnityEditorUtility.GetLabel(field.UnityFormatName), expandStack, field.FieldInfo.GetValue(data), out object fieldData, depth + 1))
|
newData = data;
|
||||||
{
|
childElementChanged = true;
|
||||||
field.FieldInfo.SetValue(data, fieldData);
|
|
||||||
newData = data;
|
|
||||||
childElementChanged = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DrawerType.UnityObject:
|
case DrawerType.UnityObject:
|
||||||
{
|
|
||||||
using (DragonGUI.CheckChanged())
|
|
||||||
{
|
|
||||||
var uobj = UnsafeUtility.As<object, UnityObject>(ref data);
|
|
||||||
bool isComponent = typeof(UnityComponent).IsAssignableFrom(fieldInfoData.FieldType);
|
|
||||||
var newuobj = EditorGUILayout.ObjectField(label, uobj, fieldInfoData.FieldType, true);
|
|
||||||
|
|
||||||
if (uobj != newuobj)
|
using (DragonGUI.CheckChanged())
|
||||||
|
{
|
||||||
|
var uobj = UnsafeUtility.As<object, UnityObject>(ref data);
|
||||||
|
bool isComponent = typeof(UnityComponent).IsAssignableFrom(fieldInfoData.FieldType);
|
||||||
|
var newuobj = EditorGUILayout.ObjectField(label, uobj, fieldInfoData.FieldType, true);
|
||||||
|
|
||||||
|
if (uobj != newuobj)
|
||||||
|
{
|
||||||
|
if (isComponent && newuobj is GameObject go)
|
||||||
{
|
{
|
||||||
if (isComponent && newuobj is GameObject go)
|
newuobj = go.GetComponent(fieldInfoData.FieldType);
|
||||||
{
|
|
||||||
newuobj = go.GetComponent(fieldInfoData.FieldType);
|
|
||||||
}
|
|
||||||
newData = newuobj;
|
|
||||||
childElementChanged = true;
|
|
||||||
}
|
}
|
||||||
|
newData = newuobj;
|
||||||
|
childElementChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DrawerType.Enum:
|
case DrawerType.Enum:
|
||||||
|
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
var enumData = UnsafeUtility.As<object, Enum>(ref data);
|
||||||
{
|
newData = EditorGUILayout.EnumPopup(label, enumData);
|
||||||
var enumData = UnsafeUtility.As<object, Enum>(ref data);
|
|
||||||
newData = EditorGUILayout.EnumPopup(label, enumData);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EditorGUILayout.EnumPopup(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EditorGUILayout.EnumPopup(label, default);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DrawerType.EnumFlags:
|
case DrawerType.EnumFlags:
|
||||||
|
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
var enumData = UnsafeUtility.As<object, Enum>(ref data);
|
||||||
{
|
newData = EditorGUILayout.EnumFlagsField(label, enumData);
|
||||||
var enumData = UnsafeUtility.As<object, Enum>(ref data);
|
|
||||||
newData = EditorGUILayout.EnumFlagsField(label, enumData);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EditorGUILayout.EnumFlagsField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EditorGUILayout.EnumFlagsField(label, default);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DrawerType.Bool:
|
case DrawerType.Bool:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = EditorGUILayout.Toggle(label, (bool)data);
|
||||||
{
|
}
|
||||||
newData = EditorGUILayout.Toggle(label, (bool)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.Toggle(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.Toggle(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.String:
|
case DrawerType.String:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = EditorGUILayout.TextField(label, (string)data);
|
||||||
{
|
}
|
||||||
newData = EditorGUILayout.TextField(label, (string)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.TextField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.TextField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.Float:
|
case DrawerType.Float:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = EditorGUILayout.FloatField(label, (float)data);
|
||||||
{
|
}
|
||||||
newData = EditorGUILayout.FloatField(label, (float)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.FloatField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.FloatField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.Double:
|
case DrawerType.Double:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = EditorGUILayout.DoubleField(label, (double)data);
|
||||||
{
|
}
|
||||||
newData = EditorGUILayout.DoubleField(label, (double)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.DoubleField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.DoubleField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.Byte:
|
case DrawerType.Byte:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = (byte)EditorGUILayout.IntField(label, (byte)data);
|
||||||
{
|
}
|
||||||
newData = (byte)EditorGUILayout.IntField(label, (byte)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.IntField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.IntField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.SByte:
|
case DrawerType.SByte:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = (sbyte)EditorGUILayout.IntField(label, (sbyte)data);
|
||||||
{
|
}
|
||||||
newData = (sbyte)EditorGUILayout.IntField(label, (sbyte)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.IntField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.IntField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.Short:
|
case DrawerType.Short:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = (short)EditorGUILayout.IntField(label, (short)data);
|
||||||
{
|
}
|
||||||
newData = (short)EditorGUILayout.IntField(label, (short)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.IntField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.IntField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.UShort:
|
case DrawerType.UShort:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = (ushort)EditorGUILayout.IntField(label, (ushort)data);
|
||||||
{
|
}
|
||||||
newData = (ushort)EditorGUILayout.IntField(label, (ushort)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.IntField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.IntField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.Int:
|
case DrawerType.Int:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = (int)EditorGUILayout.IntField(label, (int)data);
|
||||||
{
|
}
|
||||||
newData = (int)EditorGUILayout.IntField(label, (int)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.IntField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.IntField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.UInt:
|
case DrawerType.UInt:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = (uint)EditorGUILayout.IntField(label, (int)(uint)data);
|
||||||
{
|
}
|
||||||
newData = (uint)EditorGUILayout.IntField(label, (int)(uint)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.IntField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.IntField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.Long:
|
case DrawerType.Long:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = EditorGUILayout.LongField(label, (long)data);
|
||||||
{
|
}
|
||||||
newData = EditorGUILayout.LongField(label, (long)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.LongField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.LongField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.ULong:
|
case DrawerType.ULong:
|
||||||
|
if (eventType != EventType.Layout)
|
||||||
{
|
{
|
||||||
if (eventType != EventType.Layout)
|
newData = (ulong)EditorGUILayout.LongField(label, (long)(ulong)data);
|
||||||
{
|
}
|
||||||
newData = (ulong)EditorGUILayout.LongField(label, (long)(ulong)data);
|
else
|
||||||
}
|
{
|
||||||
else
|
EditorGUILayout.LongField(label, default);
|
||||||
{
|
|
||||||
EditorGUILayout.LongField(label, default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
EditorGUILayout.LabelField(label, label2);
|
||||||
EditorGUILayout.LabelField(label, label2);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
expandStack.Up();
|
expandMatrix.Up();
|
||||||
if (childElementChanged || DragonGUI.Changed)
|
if (childElementChanged || DragonGUI.Changed)
|
||||||
{
|
{
|
||||||
outData = newData;
|
outData = newData;
|
||||||
@ -898,6 +705,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public enum DrawerType
|
public enum DrawerType
|
||||||
{
|
{
|
||||||
@ -923,7 +731,6 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
Long,
|
Long,
|
||||||
ULong,
|
ULong,
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -120,10 +120,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
//var targetTypes = assembly.GetTypes().Where(type =>
|
if (AssemblyFilter.IsExcludedAssembly(assembly)) { continue; }
|
||||||
// (type.IsGenericType || type.IsAbstract || type.IsInterface) == false &&
|
|
||||||
// type.IsSubclassOf(typeof(UnityObject)) == false &&
|
|
||||||
// type.GetCustomAttribute<SerializableAttribute>() != null);
|
|
||||||
|
|
||||||
foreach (var type in assembly.GetTypes())
|
foreach (var type in assembly.GetTypes())
|
||||||
{
|
{
|
||||||
@ -457,11 +454,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
#region GetDefaultStyle
|
#region GetDefaultStyle
|
||||||
private static Texture2D _whiteTexture;
|
private static Texture2D _whiteTexture;
|
||||||
|
|
||||||
private static GUIStyle _whiteStyleWithPadding;
|
|
||||||
private static GUIStyle _whiteStyle;
|
private static GUIStyle _whiteStyle;
|
||||||
private static GUIStyle _whiteEdgeStyle;
|
|
||||||
|
|
||||||
private static GUIStyle _transperentBlackBackgrounStyle;
|
private static GUIStyle _transperentBlackBackgrounStyle;
|
||||||
private static GUIStyle _clearBackgrounStyle;
|
private static GUIStyle _clearBackgrounStyle;
|
||||||
public static Texture2D GetWhiteTexture()
|
public static Texture2D GetWhiteTexture()
|
||||||
@ -474,34 +467,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
private static bool IsNotInitializedStyle(GUIStyle style)
|
private static bool IsNotInitializedStyle(GUIStyle style)
|
||||||
{
|
{
|
||||||
//return style == null || style.normal.background == null;
|
|
||||||
return style == null || style.normal.background == null;
|
return style == null || style.normal.background == null;
|
||||||
}
|
}
|
||||||
public static GUIStyle GetWhiteStyleWithPadding()
|
|
||||||
{
|
|
||||||
if (IsNotInitializedStyle(_whiteStyleWithPadding))
|
|
||||||
{
|
|
||||||
_whiteStyleWithPadding = CreateStyle(GetWhiteTexture());
|
|
||||||
}
|
|
||||||
return _whiteStyleWithPadding;
|
|
||||||
}
|
|
||||||
public static GUIStyle GetWhiteStyle()
|
public static GUIStyle GetWhiteStyle()
|
||||||
{
|
{
|
||||||
if (IsNotInitializedStyle(_whiteStyle))
|
if (IsNotInitializedStyle(_whiteStyle))
|
||||||
{
|
{
|
||||||
_whiteStyle = CreateStyle(GetWhiteTexture());
|
_whiteStyle = CreateStyle(GetWhiteTexture(), GUI.skin.label);
|
||||||
_whiteStyle.padding = new RectOffset(0,0,0,0);
|
|
||||||
}
|
}
|
||||||
return _whiteStyle;
|
return _whiteStyle;
|
||||||
}
|
}
|
||||||
public static GUIStyle GetWhiteEdge4Style()
|
|
||||||
{
|
|
||||||
if (IsNotInitializedStyle(_whiteEdgeStyle))
|
|
||||||
{
|
|
||||||
_whiteEdgeStyle = CreateEdge4Style();
|
|
||||||
}
|
|
||||||
return _whiteEdgeStyle;
|
|
||||||
}
|
|
||||||
public static GUIStyle GetTransperentBlackBackgrounStyle()
|
public static GUIStyle GetTransperentBlackBackgrounStyle()
|
||||||
{
|
{
|
||||||
if (IsNotInitializedStyle(_transperentBlackBackgrounStyle))
|
if (IsNotInitializedStyle(_transperentBlackBackgrounStyle))
|
||||||
@ -527,7 +502,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
referenceStyle = GUI.skin.box;
|
referenceStyle = GUI.skin.box;
|
||||||
}
|
}
|
||||||
GUIStyle result = new GUIStyle(referenceStyle);
|
GUIStyle result = new GUIStyle(GUI.skin.box);
|
||||||
Texture2D texture2D = texture;
|
Texture2D texture2D = texture;
|
||||||
result.hover.background = texture2D;
|
result.hover.background = texture2D;
|
||||||
result.hover.scaledBackgrounds = Array.Empty<Texture2D>();
|
result.hover.scaledBackgrounds = Array.Empty<Texture2D>();
|
||||||
@ -539,57 +514,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
result.normal.scaledBackgrounds = Array.Empty<Texture2D>();
|
result.normal.scaledBackgrounds = Array.Empty<Texture2D>();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private static GUIStyle CreateEdge4Style(GUIStyle referenceStyle = null)
|
|
||||||
{
|
|
||||||
const int Size = 8;
|
|
||||||
const int EdgeSize = 4;
|
|
||||||
|
|
||||||
var pixels = new Color[Size * Size];
|
|
||||||
for (var i = 0; i < pixels.Length; ++i)
|
|
||||||
{
|
|
||||||
pixels[i] = Color.clear;
|
|
||||||
}
|
|
||||||
for (int y = 0; y < Size; y++)
|
|
||||||
{
|
|
||||||
for (int x = 0; x < EdgeSize; x++)
|
|
||||||
{
|
|
||||||
pixels[y * Size + x] = Color.white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var texture = new Texture2D(Size, Size)
|
|
||||||
{
|
|
||||||
filterMode = FilterMode.Point
|
|
||||||
};
|
|
||||||
texture.SetPixels(pixels);
|
|
||||||
texture.Apply();
|
|
||||||
|
|
||||||
if (referenceStyle == null)
|
|
||||||
{
|
|
||||||
referenceStyle = GUI.skin.box;
|
|
||||||
}
|
|
||||||
GUIStyle result = new GUIStyle(referenceStyle);
|
|
||||||
Texture2D texture2D = texture;
|
|
||||||
result.hover.background = texture2D;
|
|
||||||
result.hover.scaledBackgrounds = Array.Empty<Texture2D>();
|
|
||||||
result.focused.background = texture2D;
|
|
||||||
result.focused.scaledBackgrounds = Array.Empty<Texture2D>();
|
|
||||||
result.active.background = texture2D;
|
|
||||||
result.active.scaledBackgrounds = Array.Empty<Texture2D>();
|
|
||||||
result.normal.background = texture2D;
|
|
||||||
result.normal.scaledBackgrounds = Array.Empty<Texture2D>();
|
|
||||||
|
|
||||||
result.margin = new RectOffset(0, 0, 0, 0);
|
|
||||||
result.overflow = new RectOffset(0, 0, 0, 0);
|
|
||||||
result.border = new RectOffset(EdgeSize, 0, 0, 0);
|
|
||||||
result.contentOffset = Vector2.zero;
|
|
||||||
result.fixedHeight = 0;
|
|
||||||
result.fixedWidth = 0;
|
|
||||||
result.richText = false;
|
|
||||||
|
|
||||||
var l = GUI.skin.box.padding.left;
|
|
||||||
result.padding = new RectOffset(l + 4, l, l, l);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
private static Texture2D CreateTexture(int width, int height, Color color)
|
private static Texture2D CreateTexture(int width, int height, Color color)
|
||||||
{
|
{
|
||||||
var pixels = new Color[width * height];
|
var pixels = new Color[width * height];
|
||||||
@ -662,5 +586,51 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
public void OnWorldResize(int newSize) { }
|
public void OnWorldResize(int newSize) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class AssemblyFilter
|
||||||
|
{
|
||||||
|
private static readonly HashSet<string> ExcludedPrefixes = new HashSet<string>
|
||||||
|
{
|
||||||
|
"Unity.",
|
||||||
|
"UnityEngine.",
|
||||||
|
"UnityEditor.",
|
||||||
|
"System.",
|
||||||
|
"mscorlib",
|
||||||
|
"netstandard",
|
||||||
|
"Mono.",
|
||||||
|
"Microsoft.",
|
||||||
|
"Mono.Security"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly HashSet<string> ExactedExcludedNames = new HashSet<string>
|
||||||
|
{
|
||||||
|
"System",
|
||||||
|
"System.Core",
|
||||||
|
"System.Xml",
|
||||||
|
"System.Runtime",
|
||||||
|
"System.Collections",
|
||||||
|
"System.Linq",
|
||||||
|
"System.Text.RegularExpressions",
|
||||||
|
"UnityEngine",
|
||||||
|
"UnityEditor",
|
||||||
|
};
|
||||||
|
|
||||||
|
public static bool IsExcludedAssembly(Assembly assembly)
|
||||||
|
{
|
||||||
|
string assemblyName = assembly.GetName().Name;
|
||||||
|
if (ExactedExcludedNames.Contains(assemblyName))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
foreach (var prefix in ExcludedPrefixes)
|
||||||
|
{
|
||||||
|
if (assemblyName.StartsWith(prefix, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2,9 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal static class EscEditorConsts
|
internal static class EscEditorConsts
|
||||||
{
|
{
|
||||||
public const float MetaBlockFillStyle_Alpha = 0.26f;
|
public const float COMPONENT_DRAWER_ALPHA = 0.26f;
|
||||||
public const float MetaBlockEdgeStyle_Alpha = 0.74f;
|
|
||||||
public const float MetaBlockCleanStyle_Alpha = 0.05f;
|
|
||||||
public const float COMPONENT_DRAWER_DESATURATE = 0.86f;
|
public const float COMPONENT_DRAWER_DESATURATE = 0.86f;
|
||||||
public const int AUTO_COLOR_RAINBOW_MIN_RANGE = 7;
|
public const int AUTO_COLOR_RAINBOW_MIN_RANGE = 7;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -351,7 +351,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(item.scriptPath) == false)
|
if (string.IsNullOrEmpty(item.scriptPath) == false)
|
||||||
{
|
{
|
||||||
_metaIDScriptPathPairs[item.metaID] = item.scriptPath;
|
_metaIDScriptPathPairs.Add(item.metaID, item.scriptPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,12 +28,6 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
|||||||
r.xMin += with;
|
r.xMin += with;
|
||||||
return (l, r);
|
return (l, r);
|
||||||
}
|
}
|
||||||
public static Rect HorizontalGetLeft(in this Rect rect, float with)
|
|
||||||
{
|
|
||||||
Rect l = rect;
|
|
||||||
l.xMax = l.xMin + with;
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
public static (Rect, Rect) HorizontalSliceRight(in this Rect rect, float with)
|
public static (Rect, Rect) HorizontalSliceRight(in this Rect rect, float with)
|
||||||
{
|
{
|
||||||
Rect l = rect;
|
Rect l = rect;
|
||||||
|
|||||||
@ -10,19 +10,6 @@ using System.Reflection;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS.Unity
|
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true, AllowMultiple = false)]
|
|
||||||
public sealed class DragonMemberWrapperAttribute : Attribute
|
|
||||||
{
|
|
||||||
public string WrappedFieldName;
|
|
||||||
public DragonMemberWrapperAttribute(string wrappedFieldName)
|
|
||||||
{
|
|
||||||
WrappedFieldName = wrappedFieldName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -187,7 +174,6 @@ namespace DCFApixels.DragonECS
|
|||||||
public sealed override void SetRaw(object raw) { component = (T)raw; }
|
public sealed override void SetRaw(object raw) { component = (T)raw; }
|
||||||
protected virtual T CloneComponent(T component)
|
protected virtual T CloneComponent(T component)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
|
||||||
switch (_defaultValueCloneMethod)
|
switch (_defaultValueCloneMethod)
|
||||||
{
|
{
|
||||||
case CloneMethod.Set:
|
case CloneMethod.Set:
|
||||||
@ -197,7 +183,6 @@ namespace DCFApixels.DragonECS
|
|||||||
case CloneMethod.ICloneable:
|
case CloneMethod.ICloneable:
|
||||||
return (T)_defaultValueCloneable.Clone();
|
return (T)_defaultValueCloneable.Clone();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
object ICloneable.Clone()
|
object ICloneable.Clone()
|
||||||
|
|||||||
@ -269,7 +269,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
|
|||||||
{
|
{
|
||||||
Color panelColor = DragonGUI.SelectPanelColor(meta.Color.ToMetaColor(), meta.IsCustomColor, index, total).Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
|
Color panelColor = DragonGUI.SelectPanelColor(meta.Color.ToMetaColor(), meta.IsCustomColor, index, total).Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
|
||||||
Color alphaPanelColor = panelColor;
|
Color alphaPanelColor = panelColor;
|
||||||
alphaPanelColor.a = EscEditorConsts.MetaBlockFillStyle_Alpha;
|
alphaPanelColor.a = EscEditorConsts.COMPONENT_DRAWER_ALPHA;
|
||||||
|
|
||||||
using (DragonGUI.Layout.BeginVertical(alphaPanelColor))
|
using (DragonGUI.Layout.BeginVertical(alphaPanelColor))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,6 +7,16 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS.Unity
|
namespace DCFApixels.DragonECS.Unity
|
||||||
{
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true, AllowMultiple = false)]
|
||||||
|
public sealed class DragonMemberWrapperAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string WrappedFieldName;
|
||||||
|
public DragonMemberWrapperAttribute(string wrappedFieldName)
|
||||||
|
{
|
||||||
|
WrappedFieldName = wrappedFieldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
|
||||||
public sealed class ReferenceDropDownAttribute : PropertyAttribute
|
public sealed class ReferenceDropDownAttribute : PropertyAttribute
|
||||||
{
|
{
|
||||||
public readonly Type[] AllowTypes;
|
public readonly Type[] AllowTypes;
|
||||||
@ -20,6 +30,7 @@ namespace DCFApixels.DragonECS.Unity
|
|||||||
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
|
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
|
||||||
public sealed class ReferenceDropDownWithoutAttribute : Attribute
|
public sealed class ReferenceDropDownWithoutAttribute : Attribute
|
||||||
{
|
{
|
||||||
public readonly Type[] PredicateTypes;
|
public readonly Type[] PredicateTypes;
|
||||||
@ -31,6 +42,7 @@ namespace DCFApixels.DragonECS.Unity
|
|||||||
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
|
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
|
||||||
public sealed class DragonMetaBlockAttribute : PropertyAttribute { }
|
public sealed class DragonMetaBlockAttribute : PropertyAttribute { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user