mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2026-04-22 04:35:55 +08:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e38cecf19 | ||
|
|
da16b02fe9 | ||
|
|
1efdce2c70 | ||
|
|
dd1748efaa | ||
|
|
7e0343f8d1 | ||
|
|
951213e339 | ||
|
|
3509552c89 | ||
|
|
c21cce34b1 | ||
|
|
8ea93f4405 | ||
|
|
1d2e2b4a3f | ||
|
|
43b2e0e43a | ||
|
|
de198b5b83 | ||
|
|
fee2623cd5 | ||
|
|
374324325c | ||
|
|
e863fdc8e6 | ||
|
|
a21811ffc5 | ||
|
|
d281b50d74 |
11
README-RU.md
11
README-RU.md
@ -49,18 +49,17 @@
|
|||||||
- [Установка](#установка)
|
- [Установка](#установка)
|
||||||
- [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>
|
||||||
@ -69,7 +68,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)
|
+ Зависимость: [DragonECS](https://github.com/DCFApixels/DragonECS) `[1.0.0]`;
|
||||||
+ Минимальная версия C# 8.0;
|
+ Минимальная версия C# 8.0;
|
||||||
+ Минимальная версия Unity 2021.2.0;
|
+ Минимальная версия Unity 2021.2.0;
|
||||||
|
|
||||||
@ -167,7 +166,7 @@ _pipeline = EcsPipeline.New()
|
|||||||
Показывает состояние сущности мира, позволяет добавлять/изменять/удалять компоненты по время Play Mode. На каждую сущность в мире создается отдельный монитор. Все мониторы сущностей помещаются в монитор мира.
|
Показывает состояние сущности мира, позволяет добавлять/изменять/удалять компоненты по время Play Mode. На каждую сущность в мире создается отдельный монитор. Все мониторы сущностей помещаются в монитор мира.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://github.com/DCFApixels/DragonECS-Unity/assets/99481254/509ff472-05b5-4fd8-a0e6-739d7fa81ab1">
|
<img src="https://github.com/user-attachments/assets/fc7ac96d-a9a4-45bd-9695-e80f790495ef">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@ -599,7 +598,7 @@ private struct Job : IJobParallelFor
|
|||||||
В окне настроек доступно несколько опций, включая режимы отображения компонентов в инспекторе. Внизу находятся переключатели для define-переменных, используемых в фреймворке. Открыть окно настроек: `Tools > DragonECS > Settings`.
|
В окне настроек доступно несколько опций, включая режимы отображения компонентов в инспекторе. Внизу находятся переключатели для define-переменных, используемых в фреймворке. Открыть окно настроек: `Tools > DragonECS > Settings`.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://github.com/DCFApixels/DragonECS-Unity/assets/99481254/c794be8d-6884-4415-b24a-0a1a28f577a6">
|
<img src="https://github.com/user-attachments/assets/905c03dd-d277-48b9-9963-455a09c4ceda">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
|
|||||||
@ -48,7 +48,6 @@ 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)
|
||||||
@ -69,7 +68,7 @@ Versioning semantics - [Open](https://gist.github.com/DCFApixels/af79284955bf40e
|
|||||||
|
|
||||||
## Environment
|
## Environment
|
||||||
Requirements:
|
Requirements:
|
||||||
- Dependency: [DragonECS](https://github.com/DCFApixels/DragonECS)
|
- Dependency: [DragonECS](https://github.com/DCFApixels/DragonECS) `[1.0.0]`;
|
||||||
- Minimum C# version: 8.0
|
- Minimum C# version: 8.0
|
||||||
- Minimum Unity version: 2021.2.0
|
- Minimum Unity version: 2021.2.0
|
||||||
|
|
||||||
@ -167,7 +166,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/DCFApixels/DragonECS-Unity/assets/99481254/509ff472-05b5-4fd8-a0e6-739d7fa81ab1">
|
<img src="https://github.com/user-attachments/assets/fc7ac96d-a9a4-45bd-9695-e80f790495ef">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@ -641,7 +640,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/DCFApixels/DragonECS-Unity/assets/99481254/c794be8d-6884-4415-b24a-0a1a28f577a6">
|
<img src="https://github.com/user-attachments/assets/905c03dd-d277-48b9-9963-455a09c4ceda">
|
||||||
</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.5.19",
|
"version": "0.6.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/DCFApixels/DragonECS-Unity.git"
|
"url": "https://github.com/DCFApixels/DragonECS-Unity.git"
|
||||||
|
|||||||
@ -9,6 +9,10 @@ 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.GetWhiteStyle(), GUILayout.ExpandWidth(true));
|
GUILayout.Box("Is Empty", UnityEditorUtility.GetWhiteStyleWithPadding(), GUILayout.ExpandWidth(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
DragonGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw());
|
DragonGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw());
|
||||||
|
|||||||
@ -27,14 +27,9 @@ 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))
|
using (new DragonGUI.ColorScope(Color.white * 0.5f)) GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||||
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();
|
||||||
@ -57,7 +52,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsUseCustomNames)),
|
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsUseCustomNames)),
|
||||||
prefs.IsUseCustomNames);
|
prefs.IsUseCustomNames);
|
||||||
|
|
||||||
prefs.ComponentColorMode = (ComponentColorMode)EditorGUILayout.EnumPopup(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.ComponentColorMode)), prefs.ComponentColorMode);
|
prefs.RuntimeDrawMode = (RuntimeDrawMode)EditorGUILayout.EnumPopup(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.RuntimeDrawMode)), prefs.RuntimeDrawMode);
|
||||||
|
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();
|
||||||
|
|
||||||
@ -87,8 +85,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
InitDefines();
|
InitDefines();
|
||||||
}
|
}
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
|
|
||||||
EditorGUIUtility.labelWidth = labelWidth;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,18 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS.Unity.Editors
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
{
|
{
|
||||||
internal enum ComponentColorMode
|
internal enum RuntimeDrawMode
|
||||||
|
{
|
||||||
|
Lazy = 0,
|
||||||
|
Live = 1,
|
||||||
|
}
|
||||||
|
internal enum MetaBlockRectStyle
|
||||||
|
{
|
||||||
|
Clean = 0,
|
||||||
|
Edge = 1,
|
||||||
|
Fill = 2,
|
||||||
|
}
|
||||||
|
internal enum MetaBlockColorMode
|
||||||
{
|
{
|
||||||
Generic = 0,
|
Generic = 0,
|
||||||
Auto = 1,
|
Auto = 1,
|
||||||
@ -99,15 +110,45 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private ComponentColorMode _componentColorMode = ComponentColorMode.Auto;
|
private RuntimeDrawMode _runtimeDrawMode = RuntimeDrawMode.Live;
|
||||||
public ComponentColorMode ComponentColorMode
|
public RuntimeDrawMode RuntimeDrawMode
|
||||||
{
|
{
|
||||||
get => _componentColorMode;
|
get => _runtimeDrawMode;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_componentColorMode != value)
|
if (_runtimeDrawMode != value)
|
||||||
{
|
{
|
||||||
_componentColorMode = value;
|
_runtimeDrawMode = 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,6 +8,10 @@ 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,11 +222,18 @@ 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.GetWhiteStyle(), options);
|
GUILayout.BeginVertical(UnityEditorUtility.GetWhiteStyleWithPadding(), options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Dispose() { GUILayout.EndVertical(); }
|
public void Dispose() { GUILayout.EndVertical(); }
|
||||||
@ -239,7 +246,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
using (SetColor(backgroundColor))
|
using (SetColor(backgroundColor))
|
||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal(UnityEditorUtility.GetWhiteStyle(), options);
|
GUILayout.BeginHorizontal(UnityEditorUtility.GetWhiteStyleWithPadding(), options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Dispose() { GUILayout.EndHorizontal(); }
|
public void Dispose() { GUILayout.EndHorizontal(); }
|
||||||
@ -262,6 +269,7 @@ 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);
|
||||||
@ -323,10 +331,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
get => EditorGUIUtility.standardVerticalSpacing;
|
get => EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
private static ComponentColorMode AutoColorMode
|
private static MetaBlockColorMode MetaBlockColorMode
|
||||||
{
|
{
|
||||||
get { return UserSettingsPrefs.instance.ComponentColorMode; }
|
get { return UserSettingsPrefs.instance.MetaBlockColorMode; }
|
||||||
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
|
set { UserSettingsPrefs.instance.MetaBlockColorMode = value; }
|
||||||
}
|
}
|
||||||
private static bool IsShowHidden
|
private static bool IsShowHidden
|
||||||
{
|
{
|
||||||
@ -784,7 +792,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
if (meta == null)
|
if (meta == null)
|
||||||
{
|
{
|
||||||
EditorGUI.DrawRect(rect, Color.black.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA));
|
EditorGUI.DrawRect(rect, Color.black.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha));
|
||||||
return (DrawTypeMetaBlockResultFlags.None, 0f);
|
return (DrawTypeMetaBlockResultFlags.None, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -803,11 +811,34 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Event.current.type == EventType.Repaint)
|
||||||
|
{
|
||||||
|
switch (UserSettingsPrefs.instance.MetaBlockRectStyle)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
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)
|
Color panelColor = SelectPanelColor(meta, positionIndex, total)
|
||||||
.Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE)
|
.Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE)
|
||||||
.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA);
|
.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha);
|
||||||
|
|
||||||
EditorGUI.DrawRect(rect, panelColor);
|
EditorGUI.DrawRect(rect, panelColor);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float optionsWidth = 0f;
|
float optionsWidth = 0f;
|
||||||
Rect optionRect = rect;
|
Rect optionRect = rect;
|
||||||
@ -873,7 +904,11 @@ 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)
|
||||||
{
|
{
|
||||||
@ -926,13 +961,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (AutoColorMode)
|
switch (MetaBlockColorMode)
|
||||||
{
|
{
|
||||||
case ComponentColorMode.Auto:
|
case MetaBlockColorMode.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 ComponentColorMode.Rainbow:
|
case MetaBlockColorMode.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 ExpandMatrix
|
internal class ExpandStack
|
||||||
{
|
{
|
||||||
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, ExpandMatrix> _instances = new Dictionary<Type, ExpandMatrix>();
|
private static Dictionary<Type, ExpandStack> _instances = new Dictionary<Type, ExpandStack>();
|
||||||
public static ExpandMatrix Take(Type type)
|
public static ExpandStack Take(Type type)
|
||||||
{
|
{
|
||||||
if (_instances.TryGetValue(type, out ExpandMatrix result) == false)
|
if (_instances.TryGetValue(type, out ExpandStack result) == false)
|
||||||
{
|
{
|
||||||
result = new ExpandMatrix();
|
result = new ExpandStack();
|
||||||
_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 ComponentColorMode ComponentColorMode
|
protected static MetaBlockColorMode ComponentColorMode
|
||||||
{
|
{
|
||||||
get { return UserSettingsPrefs.instance.ComponentColorMode; }
|
get { return UserSettingsPrefs.instance.MetaBlockColorMode; }
|
||||||
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
|
set { UserSettingsPrefs.instance.MetaBlockColorMode = 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 ComponentColorMode ComponentColorMode
|
protected static MetaBlockColorMode ComponentColorMode
|
||||||
{
|
{
|
||||||
get { return UserSettingsPrefs.instance.ComponentColorMode; }
|
get { return UserSettingsPrefs.instance.MetaBlockColorMode; }
|
||||||
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
|
set { UserSettingsPrefs.instance.MetaBlockColorMode = 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,4 +1,5 @@
|
|||||||
#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;
|
||||||
@ -44,10 +45,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
|
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
private static ComponentColorMode AutoColorMode
|
private static RuntimeDrawMode RuntimeDrawMode
|
||||||
{
|
{
|
||||||
get { return UserSettingsPrefs.instance.ComponentColorMode; }
|
get { return UserSettingsPrefs.instance.RuntimeDrawMode; }
|
||||||
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
|
set { UserSettingsPrefs.instance.RuntimeDrawMode = value; }
|
||||||
}
|
}
|
||||||
private static bool IsShowHidden
|
private static bool IsShowHidden
|
||||||
{
|
{
|
||||||
@ -65,6 +66,7 @@ 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;
|
||||||
@ -74,12 +76,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);
|
||||||
@ -266,7 +268,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
|
|
||||||
object data = cmp.GetRaw(worldID);
|
object data = cmp.GetRaw(worldID);
|
||||||
|
|
||||||
ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType);
|
ExpandStack expandStack = ExpandStack.Take(componentType);
|
||||||
|
|
||||||
float padding = EditorGUIUtility.standardVerticalSpacing;
|
float padding = EditorGUIUtility.standardVerticalSpacing;
|
||||||
Rect optionButton = GUILayoutUtility.GetLastRect();
|
Rect optionButton = GUILayoutUtility.GetLastRect();
|
||||||
@ -277,15 +279,14 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
//Canceling isExpanded
|
//Canceling isExpanded
|
||||||
if (DragonGUI.ClickTest(optionButton))
|
if (DragonGUI.ClickTest(optionButton))
|
||||||
{
|
{
|
||||||
ref bool isExpanded = ref expandMatrix.Down();
|
ref bool isExpanded = ref expandStack.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)))
|
|
||||||
{
|
|
||||||
EditorGUI.BeginChangeCheck();
|
|
||||||
|
|
||||||
|
using (DragonGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha)))
|
||||||
|
{
|
||||||
//Edit script button
|
//Edit script button
|
||||||
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
|
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
|
||||||
{
|
{
|
||||||
@ -300,7 +301,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), expandMatrix, data, out object resultData, 0))
|
if (DrawRuntimeData(ref componentInfoData, UnityEditorUtility.GetLabel(meta.Name), expandStack, data, out object resultData, 0))
|
||||||
{
|
{
|
||||||
cmp.SetRaw(worldID, resultData);
|
cmp.SetRaw(worldID, resultData);
|
||||||
}
|
}
|
||||||
@ -355,31 +356,171 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
RuntimeComponentsUtility.GetAddComponentGenericMenu(world).Open(dropDownRect, entityID);
|
RuntimeComponentsUtility.GetAddComponentGenericMenu(world).Open(dropDownRect, entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (DragonGUI.SetBackgroundColor(GUI.color.SetAlpha(0.16f)))
|
using (DragonGUI.Layout.BeginVertical(Color.white.SetAlpha(0.066f)))
|
||||||
{
|
{
|
||||||
GUILayout.Box("", UnityEditorUtility.GetWhiteStyle(), GUILayout.ExpandWidth(true));
|
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden);
|
||||||
|
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++)
|
||||||
{
|
{
|
||||||
DrawRuntimeComponent(entityID, _componentPoolsBuffer[i], 9, i);
|
var pool = _componentPoolsBuffer[i];
|
||||||
}
|
if (pool.ComponentType.IsValueType)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void DrawRuntimeComponent(int entityID, IEcsPool pool, int total, int index)
|
|
||||||
{
|
{
|
||||||
var meta = pool.ComponentType.GetMeta();
|
DrawRuntimeValueComponent(entityID, pool, 9, i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DrawRuntimeClassComponent(entityID, pool, 9, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private struct DrawRuntimeCompoentnsCahce : IEcsWorldComponent<DrawRuntimeCompoentnsCahce>
|
||||||
|
{
|
||||||
|
public EcsWorld World;
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
Type componentType = pool.ComponentType;
|
float padding = EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
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;
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
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);
|
object data = pool.GetRaw(entityID);
|
||||||
|
if (DrawRuntimeData(ref cache.FieldInfoData, label, cache.ExpandStack, data, out object resultData, 0))
|
||||||
ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType);
|
{
|
||||||
|
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();
|
||||||
@ -387,19 +528,41 @@ 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
|
|
||||||
if (DragonGUI.ClickTest(optionButton))
|
Color fillColor = Color.clear;
|
||||||
|
Color backColor = Color.clear;
|
||||||
|
if (Event.current.type == EventType.Repaint)
|
||||||
{
|
{
|
||||||
ref bool isExpanded = ref expandMatrix.Down();
|
switch (UserSettingsPrefs.instance.MetaBlockRectStyle)
|
||||||
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(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA)))
|
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetWhiteStyle(), backColor))
|
||||||
|
{
|
||||||
|
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetWhiteEdge4Style(), fillColor))
|
||||||
{
|
{
|
||||||
EditorGUI.BeginChangeCheck();
|
|
||||||
|
|
||||||
//Close button
|
//Close button
|
||||||
optionButton.xMin = optionButton.xMax - DragonGUI.HeadIconsRect.width;
|
optionButton.xMin = optionButton.xMax - DragonGUI.HeadIconsRect.width;
|
||||||
if (DragonGUI.CloseButton(optionButton))
|
if (DragonGUI.CloseButton(optionButton))
|
||||||
@ -422,25 +585,25 @@ 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), expandMatrix, data, out object resultData, 0))
|
if (DrawRuntimeData(ref componentInfoData, UnityEditorUtility.GetLabel(meta.Name), expandStack, data, out object resultData, 0))
|
||||||
{
|
{
|
||||||
pool.SetRaw(entityID, resultData);
|
pool.SetRaw(entityID, resultData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region draw data
|
#region draw data
|
||||||
private bool DrawRuntimeData(ref RuntimeComponentReflectionCache.FieldInfoData fieldInfoData, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData, int depth)
|
private bool DrawRuntimeData(ref RuntimeComponentReflectionCache.FieldInfoData fieldInfoData, GUIContent label, ExpandStack expandStack, 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();
|
||||||
@ -451,19 +614,19 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeComponentReflectionCache cache = fieldInfoData.GetReflectionCache(type);
|
var reflectionCache = fieldInfoData.GetReflectionCache(type);
|
||||||
if (depth >= DEPTH_MAX || cache == null)
|
if (depth >= DEPTH_MAX || reflectionCache == null)
|
||||||
{
|
{
|
||||||
EditorGUILayout.TextField(label, "error");
|
EditorGUILayout.TextField(label, "error");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ref bool isExpanded = ref expandMatrix.Down();
|
ref bool isExpanded = ref expandStack.Down();
|
||||||
bool childElementChanged = false;
|
bool childElementChanged = false;
|
||||||
var eventType = Event.current.type;
|
var eventType = Event.current.type;
|
||||||
|
|
||||||
var label2 = "-";
|
var label2 = "-";
|
||||||
var drawerType = cache.DrawerType;
|
var drawerType = reflectionCache.DrawerType;
|
||||||
|
|
||||||
if (isUnityObjectField)
|
if (isUnityObjectField)
|
||||||
{
|
{
|
||||||
@ -472,16 +635,20 @@ 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())
|
using (DragonGUI.CheckChanged())
|
||||||
{
|
{
|
||||||
RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth);
|
RefEditorWrapper wrapper = reflectionCache.GetWrapper(_runtimeComponentsDepth);
|
||||||
wrapper.data = data;
|
wrapper.data = data;
|
||||||
wrapper.SO.Update();
|
wrapper.SO.Update();
|
||||||
wrapper.IsExpanded = isExpanded;
|
wrapper.IsExpanded = isExpanded;
|
||||||
@ -495,10 +662,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
}
|
}
|
||||||
isExpanded = wrapper.IsExpanded;
|
isExpanded = wrapper.IsExpanded;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.UnityNotSerializableComposite:
|
case DrawerType.UnityNotSerializableComposite:
|
||||||
|
{
|
||||||
GUILayout.Space(DragonGUI.Spacing);
|
GUILayout.Space(DragonGUI.Spacing);
|
||||||
var foldoutStyle = EditorStyles.foldout;
|
var foldoutStyle = EditorStyles.foldout;
|
||||||
Rect rect = GUILayoutUtility.GetRect(label, foldoutStyle);
|
Rect rect = GUILayoutUtility.GetRect(label, foldoutStyle);
|
||||||
@ -510,10 +677,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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];
|
var field = reflectionCache.Fields[j];
|
||||||
if (DrawRuntimeData(ref field, UnityEditorUtility.GetLabel(field.UnityFormatName), expandMatrix, field.FieldInfo.GetValue(data), out object fieldData, depth + 1))
|
if (DrawRuntimeData(ref field, UnityEditorUtility.GetLabel(field.UnityFormatName), expandStack, field.FieldInfo.GetValue(data), out object fieldData, depth + 1))
|
||||||
{
|
{
|
||||||
field.FieldInfo.SetValue(data, fieldData);
|
field.FieldInfo.SetValue(data, fieldData);
|
||||||
newData = data;
|
newData = data;
|
||||||
@ -522,10 +689,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DrawerType.UnityObject:
|
case DrawerType.UnityObject:
|
||||||
|
{
|
||||||
using (DragonGUI.CheckChanged())
|
using (DragonGUI.CheckChanged())
|
||||||
{
|
{
|
||||||
var uobj = UnsafeUtility.As<object, UnityObject>(ref data);
|
var uobj = UnsafeUtility.As<object, UnityObject>(ref data);
|
||||||
@ -542,10 +709,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
childElementChanged = true;
|
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);
|
var enumData = UnsafeUtility.As<object, Enum>(ref data);
|
||||||
@ -555,10 +722,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
EditorGUILayout.EnumPopup(label, default);
|
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);
|
var enumData = UnsafeUtility.As<object, Enum>(ref data);
|
||||||
@ -568,9 +735,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
EditorGUILayout.EnumFlagsField(label, default);
|
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);
|
||||||
@ -579,8 +747,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -589,8 +759,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -599,8 +771,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -609,8 +783,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -619,8 +795,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -629,8 +807,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -639,8 +819,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -649,8 +831,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -659,8 +843,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -669,8 +855,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -679,8 +867,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@ -689,13 +879,16 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
{
|
{
|
||||||
EditorGUILayout.LongField(label, default);
|
EditorGUILayout.LongField(label, default);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
EditorGUILayout.LabelField(label, label2);
|
EditorGUILayout.LabelField(label, label2);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
expandMatrix.Up();
|
expandStack.Up();
|
||||||
if (childElementChanged || DragonGUI.Changed)
|
if (childElementChanged || DragonGUI.Changed)
|
||||||
{
|
{
|
||||||
outData = newData;
|
outData = newData;
|
||||||
@ -705,7 +898,6 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
public enum DrawerType
|
public enum DrawerType
|
||||||
{
|
{
|
||||||
@ -731,6 +923,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
|
|||||||
Long,
|
Long,
|
||||||
ULong,
|
ULong,
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -120,7 +120,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
if (AssemblyFilter.IsExcludedAssembly(assembly)) { continue; }
|
//var targetTypes = assembly.GetTypes().Where(type =>
|
||||||
|
// (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())
|
||||||
{
|
{
|
||||||
@ -454,7 +457,11 @@ 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()
|
||||||
@ -467,16 +474,34 @@ 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(), GUI.skin.label);
|
_whiteStyle = CreateStyle(GetWhiteTexture());
|
||||||
|
_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))
|
||||||
@ -502,7 +527,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
referenceStyle = GUI.skin.box;
|
referenceStyle = GUI.skin.box;
|
||||||
}
|
}
|
||||||
GUIStyle result = new GUIStyle(GUI.skin.box);
|
GUIStyle result = new GUIStyle(referenceStyle);
|
||||||
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>();
|
||||||
@ -514,6 +539,57 @@ 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];
|
||||||
@ -586,51 +662,5 @@ 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,7 +2,9 @@
|
|||||||
{
|
{
|
||||||
internal static class EscEditorConsts
|
internal static class EscEditorConsts
|
||||||
{
|
{
|
||||||
public const float COMPONENT_DRAWER_ALPHA = 0.26f;
|
public const float MetaBlockFillStyle_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.Add(item.metaID, item.scriptPath);
|
_metaIDScriptPathPairs[item.metaID] = item.scriptPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,12 @@ 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,6 +10,19 @@ 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
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -174,6 +187,7 @@ 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:
|
||||||
@ -183,6 +197,7 @@ 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.COMPONENT_DRAWER_ALPHA;
|
alphaPanelColor.a = EscEditorConsts.MetaBlockFillStyle_Alpha;
|
||||||
|
|
||||||
using (DragonGUI.Layout.BeginVertical(alphaPanelColor))
|
using (DragonGUI.Layout.BeginVertical(alphaPanelColor))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,16 +7,6 @@ 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;
|
||||||
@ -30,7 +20,6 @@ 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;
|
||||||
@ -42,7 +31,6 @@ 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