Compare commits

..

No commits in common. "main" and "0.5.18" have entirely different histories.
main ... 0.5.18

77 changed files with 1304 additions and 3065 deletions

View File

@ -49,17 +49,16 @@
- [Установка](#установка)
- [Debug](#debug)
- [Debug Сервис](#debug-сервис)
- [Debug Модуль](#debug-модуль)
- [Визуальная отладка](#визуальная-отладка)
- [Шаблоны](#шаблоны)
- [Связь с GameObject](#связь-с-gameobject)
- [World Provider](#world-provider)
- [Шаблон Пайплайна](#шаблон-пайплайна)
- [FixedUpdate и LateUpdate](#fixedupdate-и-lateupdate)
- [Кастомизация инспектора](#Кастомизация-инспектора)
- [Поддержка Jobs](#Поддержка-Jobs)
- [FixedUpdate LateUpdate](#fixedupdate-lateupdate)
- [Документация проекта](#документация-проекта)
- [Окно настроек](#окно-настроек)
- [Reference Repairer](#reference-repairer)
- [Reference Repairer](#Reference-Repairer)
- [FAQ](#faq)
</br>
@ -68,7 +67,7 @@
Семантика версионирования - [Открыть](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;
+ Минимальная версия Unity 2021.2.0;
@ -148,16 +147,7 @@ _pipeline = EcsPipeline.New()
Показывает состояние `EcsWorld`. На каждый мир, переданный в `AddUnityDebug(...)`, создается отдельный монитор.
<p align="center">
<img src="https://github.com/user-attachments/assets/83905e7a-a5d1-4470-883a-c3b318cb4726">
</p>
-----
* ### `WorldQueriesMonitor`
Расположен вместе с `WorldMonitor`, показывает список всех Where запросов которые выполняли системы. Вверху есть поле для поиска запросов по именам компонентам. Поисковую строку можно разделять символом `/` для одновременного поиска нескольких компонентов. Рядом с каждым Where запросом есть кнопка `Snapshot`, по нажатию откроется окно со списоком всех сущностей которые на данный момент удовлетворяют маске запроса.
<p align="center">
<img width="400px" src="https://github.com/user-attachments/assets/e6edf718-5c73-437e-abeb-c192ace9f927" />
<img src="https://github.com/DCFApixels/DragonECS-Unity/assets/99481254/7b6455fc-9211-425c-b0b8-288077e61543">
</p>
-----
@ -166,7 +156,7 @@ _pipeline = EcsPipeline.New()
Показывает состояние сущности мира, позволяет добавлять/изменять/удалять компоненты по время Play Mode. На каждую сущность в мире создается отдельный монитор. Все мониторы сущностей помещаются в монитор мира.
<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>
-----
@ -279,9 +269,48 @@ class SomeComponentTemplate : IComponentTemplate
```
</details>
</br>
### Кастомизация отображения типов
В раскрывающемся при нажатии `Add Component` меню выбора компонента поддерживается иерархическое группирование. Производится группирование на основе мета-атрибута `[MetaGroup]`.
> В разделе [Кастомизация инспектора](#Кастомизация-инспектора) описана кастомизация отображения компонентов и использование вне шаблонов сущьностей.
Компоненты в инспекторе по умолчанию отображаются со случайным цветом, зависящим от его имени, выбрать другой режим окраски можно в [окне настроек](#окно-настроек) фреймворка. Задать конкретный цвет можно при помощи мета-атрибута `[MetaColor]`.
Если интеграции удается найти соответствующий скрипт (по совпадению имени типа и файла, либо при наличии `[MetaID]`), рядом с крестиком удаления появляется иконка файла — клик выделяет скрипт в проекте, двойной клик открывает его.
При наличии атрибута `[MetaDescription]` показывается иконка подсказки с текстом из него.
</br>
### Применение шаблонов компонентов вне стандартных шаблонов сущностей
Шаблоны компонентов можно использовать не только внутри стандартных `MonoEntityTemplate` и `ScriptableEntityTemplate`, но и в любых пользовательских классах. Для этого предусмотрены два способа:
Атрибут `[ComponentTemplateField]`:
```c#
// Отображение поля как компонента, настраиваемая мета атрибутами.
// Аналогично компонентам в MonoEntityTemplate или ScriptableEntityTemplate.
[SerializeField, ComponentTemplateField]
private SomeComponent _someComponent1;
```
```c#
// Для SerializeReference добавляет кнопку выбора доступной реализации ITemplateNode
[SerializeReference, ComponentTemplateField]
private ITemplateNode _someComponent1;
```
Обертка `ComponentTemplateProperty`:
```c#
// Обертка над ITemplateNode, аналогично примеру с атрибутом ComponentTemplateField.
private ComponentTemplateProperty _someComponent2;
```
Оба подхода работают и для массивов:
```c#
[SerializeReference, ComponentTemplateField]
private IComponentTemplate[] _components;
// или
private ComponentTemplateProperty[] _components;
```
</br>
@ -467,124 +496,6 @@ public class EcsRoot : MonoBehaviour
</br>
# Кастомизация инспектора
## Атрибуты инспектора
+ **[ReferenceDropDown]** -
Применяется к полю с `[SerializeReference]`. Добавляет кнопку выбора типа из списка. Можно ограничить набор доступных типов, передав список в конструктор.
+ **[ReferenceDropDownWithout]** -
Используется вместе с `[ReferenceDropDown]`, чтобы исключить указанные типы (и их наследников) из списка выбора.
+ **[DragonMetaBlock]** -
Отображает значение в инспекторе так же, как компоненты в шаблонах сущности. Учитывает meta-атрибуты (`MetaGroup`, `MetaColor`, `MetaDescription`, `MetaID` и др.).
## Поведение Meta-атрибутов
+ Иерархическая группировка элементов в меню `Add Component` или `[ReferenceDropDown]` задаётся через `[MetaGroup]`.
+ Цвет компонента в инспекторе по умолчанию определяется именем типа. Режим окраски можно изменить в окне настроек. Явный цвет задаётся через `[MetaColor]`.
+ При совпадении имени типа и файла (или при наличии `[MetaID]`) рядом с кнопкой удаления появляется иконка файла: один клик — выделение скрипта в проекте, двойной клик — открытие.
+ Если указан `[MetaDescription]`, рядом отображается иконка подсказки с текстом описания.
+ При восстановлении **Missing Reference** с помощью [**Reference Repairer**](#Reference-Repairer), инструмент ищет соответствие старого и нового имени типа по атрибуту `[MetaID(id)]`.
## Примеры:
Атрибут `DragonMetaBlock`:
```c#
// Отображение поля настраиваемое мета-атрибутами.
// Аналогично компонентам в MonoEntityTemplate или ScriptableEntityTemplate.
[DragonMetaBlock]
public SomeComponent Component;
// Можно применять к любому полю любого типа.
[DragonMetaBlock]
public Foo Foo;
```
`ReferenceDropDown` и `ReferenceDropDownWithout`:
```c#
// Добавляет кнопку выбора реализации ITemplateNode из выпадающего списка.
[SerializeReference]
[ReferenceDropDown]
public ITemplateNode Template;
```
```c#
// Так же можно применять к любому полю любого типа.
// В списке будут только тип Foo и его наследники, исключая FooExc и его наследников.
[SerializeReference]
[ReferenceDropDown(typeof(Foo))]
[ReferenceDropDownWithout(typeof(FooExc))]
public object Template;
```
Комбинирование и другие варианты использования:
```c#
// Атрибуты можно комбинировать.
[DragonMetaBlock]
[ReferenceDropDown]
public ITemplateNode Template;
// Обертка над ITemplateNode, аналогично примеру выше.
public ComponentTemplateProperty Template;
// Атрибуты корректно работают с массивами и листами.
[DragonMetaBlock]
[ReferenceDropDown]
public ITemplateNode[] Template;
```
</br>
# Поддержка Jobs
DragonECS по умолчанию совместим с Job системой Unity. Пример:
```c#
EcsWorld _world;
class Aspect : EcsAspect
{
// Пул для unmanaged компонентов.
public EcsValuePool<Cmp> Cmps = Inc;
}
public void Run()
{
var job = new Job()
{
// Идентично Where, но возвращает unmanaged список сущностей.
Entities = _world.WhereUnsafe(out Aspect a),
// Конвертация пула в unmanaged версию
Cmps = a.Cmps.AsNative(),
X = 10f,
};
JobHandle jobHandle = job.Schedule(job.Entities.Count, 64);
jobHandle.Complete();
}
```
```c#
// Unmanaged компонент.
public struct Cmp : IEcsValueComponent
{
public float A;
}
private struct Job : IJobParallelFor
{
public EcsUnsafeSpan Entities;
public NativeEcsValuePool<Cmp> Cmps;
public float X;
public Job(EcsUnsafeSpan entities, float x)
{
Entities = entities;
X = x;
}
public void Execute(int index)
{
var e = Entities[index];
Cmps[e].A += X;
}
}
```
</br>
# Документация проекта
В интеграции также есть окно документации проекта на основе мета-атрибутов. Открыть документацию: `Tools > DragonECS > Documentation`. Документация формируется при первом открытии окна и при нажатии кнопки `Update`.
@ -598,7 +509,7 @@ private struct Job : IJobParallelFor
В окне настроек доступно несколько опций, включая режимы отображения компонентов в инспекторе. Внизу находятся переключатели для define-переменных, используемых в фреймворке. Открыть окно настроек: `Tools > DragonECS > Settings`.
<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>
</br>

159
README.md
View File

@ -48,17 +48,16 @@ This package integrates DragonECS with the Unity editor and runtime. It provides
- [Installation](#installation)
- [Debug](#debug)
- [Debug service](#debug-service)
- [Visual debugging](#visual-debugging)
- [Templates](#templates)
- [Binding to GameObjects](#binding-to-gameobjects)
- [Debug module](#debug-module)
- [Visual debugging](#Visual-debugging)
- [Templates](#Templates)
- [Binding to GameObjects](#Binding-to-GameObjects)
- [World Provider](#world-provider)
- [Pipeline template](#pipeline-template)
- [FixedUpdate and LateUpdate](#fixedupdate-and-lateupdate)
- [Inspector Customization](#inspector-customization)
- [Jobs Support](#jobs-support)
- [Project documentation](#project-documentation)
- [Settings window](#settings-window)
- [Reference Repairer](#reference-repairer)
- [Pipeline template](#Pipeline-template)
- [FixedUpdate LateUpdate](#fixedupdate-lateupdate)
- [Project documentation](#Project-documentation)
- [Settings window](#Settings-window)
- [Reference Repairer](#Reference-Repairer)
- [FAQ](#faq)
</br>
@ -68,7 +67,7 @@ Versioning semantics - [Open](https://gist.github.com/DCFApixels/af79284955bf40e
## Environment
Requirements:
- Dependency: [DragonECS](https://github.com/DCFApixels/DragonECS) `[1.0.0]`;
- Dependency: [DragonECS](https://github.com/DCFApixels/DragonECS)
- Minimum C# version: 8.0
- Minimum Unity version: 2021.2.0
@ -148,16 +147,7 @@ Displays processes and systems in a matrix layout. Systems are shown in executio
Displays `EcsWorld` state. A separate monitor is created for each world passed to `AddUnityDebug(...)`.
<p align="center">
<img src="https://github.com/user-attachments/assets/83905e7a-a5d1-4470-883a-c3b318cb4726">
</p>
-----
* ### `WorldQueriesMonitor`
Located together with `WorldMonitor`, shows a list of all Where queries that systems have executed. At the top there is a search field for filtering queries by component names. The search string can be split with a `/` character to search for multiple components at once. Next to each Where query there is a `Snapshot` button; clicking it opens a window showing a list of all entities that currently match the query mask.
<p align="center">
<img width="400px" src="https://github.com/user-attachments/assets/e6edf718-5c73-437e-abeb-c192ace9f927" />
<img src="https://github.com/DCFApixels/DragonECS-Unity/assets/99481254/7b6455fc-9211-425c-b0b8-288077e61543">
</p>
-----
@ -166,7 +156,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.
<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>
-----
@ -254,8 +244,6 @@ public struct Health : IEcsComponent, ITemplateNode
}
```
> The section [Inspector Customization](#Inspector-Customization) describes customization of component display and usage outside of entity templates.
#### Custom template implementation
If built-in `ComponentTemplate<T>` or `TagComponentTemplate<T>` do not fit the requirements, implement a custom template by implementing `IComponentTemplate`. This can be useful for custom pools. In most cases the built-in templates are sufficient.
@ -447,7 +435,7 @@ public class EcsMyWorldSingletonProvider : EcsWorldProvider<EcsMyWorld>
</br>
# Pipeline template
# Pipeline templates
Pipelines and entities can be assembled from templates. Pipeline templates are modules implementing the `IEcsModule` interface.
The package provides two pipeline template types by default: `ScriptablePipelineTemplate` and `MonoPipelineTemplate`.
@ -508,125 +496,6 @@ public class EcsRoot : MonoBehaviour
</br>
# Inspector Customization
## Inspector Attributes
+ **[ReferenceDropDown]** -
Applied to a field with `[SerializeReference]`. Adds a type selection button from a list. The set of available types can be restricted by passing a list to the constructor.
+ **[ReferenceDropDownWithout]** -
Used together with `[ReferenceDropDown]` to exclude the specified types (and their descendants) from the selection list.
+ **[DragonMetaBlock]** -
Displays the value in the inspector similarly to how components are displayed in entity templates. Takes meta-attributes into account (`MetaGroup`, `MetaColor`, `MetaDescription`, `MetaID`, etc.).
## Behavior of MetaAttributes
+ Hierarchical grouping of items in the `Add Component` menu or `[ReferenceDropDown]` is defined via `[MetaGroup]`.
+ The component color in the inspector is determined by the type name by default. The coloring mode can be changed in the settings window. An explicit color is set via `[MetaColor]`.
+ When the type name matches the file name (or when `[MetaID]` is present), a file icon appears next to the delete button: a single click selects the script in the project, a double click opens it.
+ If `[MetaDescription]` is specified, a tooltip icon with the description text is displayed next to it.
+ When restoring a Missing Reference using Reference Repairer, the tool searches for a match between the old and new type names by the `[MetaID(id)]` attribute.
## Examples:
`DragonMetaBlock` attribute:
```c#
// Display of the field customizable via meta-attributes.
// Similar to components in MonoEntityTemplate or ScriptableEntityTemplate.
[DragonMetaBlock]
public SomeComponent Component;
// Can be applied to any field of any type.
[DragonMetaBlock]
public Foo Foo;
```
`ReferenceDropDown` and `ReferenceDropDownWithout`:
```c#
// Adds a button to select an implementation of ITemplateNode from a drop-down list.
[SerializeReference]
[ReferenceDropDown]
public ITemplateNode Template;
```
```c#
// Also applicable to any field of any type.
// The list will contain only type Foo and its descendants, excluding FooExc and its descendants.
[SerializeReference]
[ReferenceDropDown(typeof(Foo))]
[ReferenceDropDownWithout(typeof(FooExc))]
public object Template;
```
Combination and other use cases:
```c#
// Attributes can be combined.
[DragonMetaBlock]
[ReferenceDropDown]
public ITemplateNode Template;
// A wrapper over ITemplateNode, similar to the example above.
public ComponentTemplateProperty Template;
// Attributes work correctly with arrays and lists.
[DragonMetaBlock]
[ReferenceDropDown]
public ITemplateNode[] Template;
```
</br>
# Jobs Support
DragonECS is compatible with Unity's Job system by default. Example:
```c#
EcsWorld _world;
class Aspect : EcsAspect
{
// Pool for unmanaged components.
public EcsValuePool<Cmp> Cmps = Inc;
}
public void Run()
{
var job = new Job()
{
// Same as Where, but returns an unmanaged entity list.
Entities = _world.WhereUnsafe(out Aspect a),
// Convert the pool to its unmanaged version
Cmps = a.Cmps.AsNative(),
X = 10f,
};
JobHandle jobHandle = job.Schedule(job.Entities.Count, 64);
jobHandle.Complete();
}
```
```c#
// Unmanaged component.
public struct Cmp : IEcsValueComponent
{
public float A;
}
private struct Job : IJobParallelFor
{
public EcsUnsafeSpan Entities;
public NativeEcsValuePool<Cmp> Cmps;
public float X;
public Job(EcsUnsafeSpan entities, float x)
{
Entities = entities;
X = x;
}
public void Execute(int index)
{
var e = Entities[index];
Cmps[e].A += X;
}
}
```
</br>
# Project documentation
A documentation window based on meta-attributes is available via `Tools > DragonECS > Documentation`. Documentation is generated on first open and when the `Update` button is pressed.
@ -640,7 +509,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`.
<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>
</br>

View File

@ -8,7 +8,7 @@
"displayName": "DragonECS-Unity",
"description": "Integration with Unity for DragonECS",
"unity": "2021.2",
"version": "0.6.0",
"version": "0.5.18",
"repository": {
"type": "git",
"url": "https://github.com/DCFApixels/DragonECS-Unity.git"

View File

@ -83,7 +83,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawTemplates()
{
using (DragonGUI.CheckChanged())
using (EcsGUI.CheckChanged())
{
var iterator = serializedObject.GetIterator();
iterator.NextVisible(true);
@ -92,7 +92,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
EditorGUILayout.PropertyField(iterator, true);
}
if (DragonGUI.Changed)
if (EcsGUI.Changed)
{
serializedObject.ApplyModifiedProperties();
}
@ -102,12 +102,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawControlButtons()
{
float height = DragonGUI.EntityBarHeight;
float height = EcsGUI.EntityBarHeight;
Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height);
EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f));
rect = rect.AddPadding(2f, 0f);
var (_, buttonRect) = rect.HorizontalSliceRight(height);
if (DragonGUI.ValidateButton(buttonRect))
if (EcsGUI.ValidateButton(buttonRect))
{
foreach (var target in Targets)
{
@ -115,7 +115,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
buttonRect = RectUtility.Move(buttonRect, -height, 0);
if (DragonGUI.AutosetButton(buttonRect))
if (EcsGUI.AutosetButton(buttonRect))
{
foreach (var target in Targets)
{

View File

@ -15,7 +15,6 @@ namespace DCFApixels.DragonECS
[MetaDescription(AUTHOR, "Component-reference to Unity object for EcsPool.")]
[MetaID("DragonECS_734F667C9201B80F1913388C2A8BB689")]
[MetaTags(MetaTags.ENGINE_MEMBER)]
[MetaProxy(typeof(UnityComponent<>.MetaProxy))]
public struct UnityComponent<T> : IEcsComponent, IEnumerable<T>//IntelliSense hack
where T : Component
{
@ -35,16 +34,6 @@ namespace DCFApixels.DragonECS
{
return $"UnityComponent<{typeof(T).GetMeta().TypeName}>";
}
private class MetaProxy : MetaProxyBase
{
protected TypeMeta Meta = typeof(T).GetMeta();
public override string Name { get { return Meta?.Name; } }
public override MetaColor? Color { get { return Meta != null && Meta.IsCustomColor ? Meta.Color : null; } }
public override MetaGroup Group { get { return Meta?.Group; } }
public override MetaDescription Description { get { return Meta?.Description; } }
public override IEnumerable<string> Tags { get { return Meta?.Tags; } }
public MetaProxy(Type type) : base(type) { }
}
}
internal static class UnityComponentConsts
@ -56,9 +45,16 @@ namespace DCFApixels.DragonECS
[MetaGroup(EcsUnityConsts.PACK_GROUP, OTHER_GROUP)]
[MetaDescription(AUTHOR, "Template for UnityComponent<T>")]
[MetaID("DragonECS_13DAACF9910155DD27F822442987E0AE")]
[MetaProxy(typeof(UnityComponentTemplate<>.UnityComponentMetaProxy))]
public abstract class UnityComponentTemplate<T> : ComponentTemplateBase<UnityComponent<T>> where T : Component
{
public override string Name
{
get { return typeof(T).Name; }
}
public override MetaGroup Group
{
get { return UnityComponentConsts.BaseGroup; }
}
public sealed override void Apply(short worldID, int entityID)
{
EcsWorld.GetPoolInstance<EcsPool<UnityComponent<T>>>(worldID).TryAddOrGet(entityID) = component;
@ -73,13 +69,5 @@ namespace DCFApixels.DragonECS
}
}
}
protected class UnityComponentMetaProxy : ComponentTemplateMetaProxy
{
public override string Name { get { return typeof(T).GetMeta().Name; } }
public override MetaGroup Group { get { return UnityComponentConsts.BaseGroup; } }
public override MetaColor? Color { get { return MetaColor.DragonCyan; } }
public override MetaDescription Description { get { return new MetaDescription(AUTHOR, $"Template for IEcsComponent component. Holds a reference to a Unity {Name} component."); } }
public UnityComponentMetaProxy(Type type) : base(type) { }
}
}
}

View File

@ -1,4 +1,4 @@
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.RunnersCore;
using DCFApixels.DragonECS.Unity;
using DCFApixels.DragonECS.Unity.Internal;
@ -52,6 +52,7 @@ namespace DCFApixels.DragonECS.Unity.Internal
{
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.PROCESSES_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "...")]
[MetaTags(MetaTags.HIDDEN)]
[MetaID("DragonECS_2DD8BC809201633E2761D5AEF65B7090")]
public class EcsLateGizmosRunner : EcsRunner<IEcsGizmos>, IEcsGizmos
@ -69,6 +70,7 @@ namespace DCFApixels.DragonECS.Unity.Internal
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.PROCESSES_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "...")]
[MetaTags(MetaTags.HIDDEN)]
[MetaID("DragonECS_EDE8BC809201603B47C3A9D1EFD4EE95")]
public class EcsLateRunRunner : EcsRunner<IEcsLateRun>, IEcsLateRun
@ -86,6 +88,7 @@ namespace DCFApixels.DragonECS.Unity.Internal
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.PROCESSES_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "...")]
[MetaTags(MetaTags.HIDDEN)]
[MetaID("DragonECS_45F7BC809201866AA05F6DC096A47F01")]
public class EcsFixedRunRunner : EcsRunner<IEcsFixedRun>, IEcsFixedRun

View File

@ -137,7 +137,7 @@ namespace DCFApixels.DragonECS
_entity = entity;
_world = world;
#if UNITY_EDITOR
world.Get<DragonGUI.EntityLinksComponent>().SetConnectLink(entity.GetIDUnchecked(), this);
world.Get<EcsGUI.EntityLinksComponent>().SetConnectLink(entity.GetIDUnchecked(), this);
#endif
_connectedEntities.Add(GetInstanceID(), this);
var goConnects = world.GetPool<GameObjectConnect>();

View File

@ -17,7 +17,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
EditorGUILayout.PropertyField(iterator, true);
}
if (DragonGUI.Changed)
if (EcsGUI.Changed)
{
serializedObject.ApplyModifiedProperties();
}
@ -27,7 +27,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawControlButtons()
{
float height = DragonGUI.EntityBarHeight;
float height = EcsGUI.EntityBarHeight;
Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height);
EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f));
rect = rect.AddPadding(2f, 0f);
@ -36,7 +36,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
//var (left, autosetCascadeRect) = rect.HorizontalSliceRight(height);
//var (_, autosetRect) = rect.HorizontalSliceRight(height);
if (DragonGUI.AutosetCascadeButton(buttonRect))
if (EcsGUI.AutosetCascadeButton(buttonRect))
{
foreach (AutoEntityCreator target in targets)
{
@ -44,17 +44,17 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
buttonRect = buttonRect.Move(-height, 0);
if (DragonGUI.AutosetButton(buttonRect))
if (EcsGUI.AutosetButton(buttonRect))
{
foreach (AutoEntityCreator target in targets)
{
target.Autoset_Editor();
}
}
using (DragonGUI.SetEnable(Application.isPlaying))
using (EcsGUI.SetEnable(Application.isPlaying))
{
buttonRect = buttonRect.Move(-height, 0);
if (DragonGUI.NewEntityButton(buttonRect))
if (EcsGUI.NewEntityButton(buttonRect))
{
foreach (AutoEntityCreator target in targets)
{

View File

@ -9,10 +9,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
[CanEditMultipleObjects]
internal class EcsEntityConnectEditor : ExtendedEditor<EcsEntityConnect>
{
public override bool RequiresConstantRepaint()
{
return UserSettingsPrefs.instance.RuntimeDrawMode == RuntimeDrawMode.Live ? true : base.RequiresConstantRepaint();
}
protected override void DrawCustom()
{
DrawEntityInfo();
@ -28,12 +24,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
//bool isConnected = Target.Entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world);
//EcsGUI.EntityStatus status = IsMultipleTargets ? EcsGUI.EntityStatus.Undefined : isConnected ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive;
//EcsGUI.Layout.EntityField(status, id, gen, worldID);
DragonGUI.Layout.EntityField(Target.Entity);
EcsGUI.Layout.EntityField(Target.Entity);
}
private void DrawTemplates()
{
using (DragonGUI.CheckChanged())
using (EcsGUI.CheckChanged())
{
var iterator = serializedObject.GetIterator();
iterator.NextVisible(true);
@ -42,7 +38,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
EditorGUILayout.PropertyField(iterator, true);
}
if (DragonGUI.Changed)
if (EcsGUI.Changed)
{
serializedObject.ApplyModifiedProperties();
}
@ -51,12 +47,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawControlButtons()
{
float height = DragonGUI.EntityBarHeight;
float height = EcsGUI.EntityBarHeight;
Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height);
EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f));
rect = rect.AddPadding(2f, 0f);
var (_, buttonRect) = rect.HorizontalSliceRight(height);
if (DragonGUI.AutosetCascadeButton(buttonRect))
if (EcsGUI.AutosetCascadeButton(buttonRect))
{
foreach (var target in Targets)
{
@ -64,17 +60,17 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
buttonRect = RectUtility.Move(buttonRect, -height, 0);
if (DragonGUI.AutosetButton(buttonRect))
if (EcsGUI.AutosetButton(buttonRect))
{
foreach (var target in Targets)
{
target.Autoset_Editor();
}
}
using (DragonGUI.SetEnable(Application.isPlaying))
using (EcsGUI.SetEnable(Application.isPlaying))
{
buttonRect = buttonRect.Move(-height, 0);
if (DragonGUI.DelEntityButton(buttonRect))
if (EcsGUI.DelEntityButton(buttonRect))
{
foreach (var target in Targets)
{
@ -82,7 +78,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
buttonRect = buttonRect.Move(-height, 0);
if (DragonGUI.UnlinkButton(buttonRect))
if (EcsGUI.UnlinkButton(buttonRect))
{
foreach (var target in Targets)
{
@ -109,7 +105,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
if (world.IsNullOrDetroyed() == false)
{
DragonGUI.Layout.DrawRuntimeComponents(entityID, world, true, true);
EcsGUI.Layout.DrawRuntimeComponents(entityID, world, true, true);
}
}
}

View File

@ -40,12 +40,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
using (DragonGUI.SetBackgroundColor(labelBackColor))
using (EcsGUI.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());
EcsGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw());
base.OnInspectorGUI();
@ -67,7 +67,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
EditorGUI.DrawRect(r, c);
GUILayout.Space(10);
DragonGUI.Layout.DrawWorldComponents(Target.GetCurrentWorldRaw());
EcsGUI.Layout.DrawWorldComponents(Target.GetCurrentWorldRaw());
}
}
}

View File

@ -55,11 +55,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
if (drawFoldout && isExpanded)
{
using (DragonGUI.UpIndentLevel())
using (EcsGUI.UpIndentLevel())
{
if (world != null && world.IsAlive(entity.id, entity.gen))
{
DragonGUI.Layout.DrawRuntimeComponents(entity.id, world, false, false);
EcsGUI.Layout.DrawRuntimeComponents(entity.id, world, false, false);
if (Event.current.type == EventType.Layout)
{
heightCache = GUILayoutUtility.GetLastRect().height;
@ -67,10 +67,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
}
DragonGUI.EntityField(position, property);
using (DragonGUI.SetEnable(world != null))
EcsGUI.EntityField(position, property);
using (EcsGUI.SetEnable(world != null))
{
DragonGUI.EntityHyperlinkButton(hyperlinkButtonRect, world, entity.id);
EcsGUI.EntityHyperlinkButton(hyperlinkButtonRect, world, entity.id);
}
@ -146,7 +146,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
DragonGUI.Changed = true;
EcsGUI.Changed = true;
DragAndDrop.AcceptDrag();
DragAndDrop.activeControlID = 0;
}
@ -186,7 +186,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
return false;
}
protected override float GetCustomHeight(SerializedProperty property, GUIContent label)
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
const float UNITY_HEIGHT_CONSTANT = 18f;
if (property.hasMultipleDifferentValues)

View File

@ -27,40 +27,49 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void OnGUI()
{
var prefs = UserSettingsPrefs.instance;
float labelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 0f;
//float checkBoxWidth = 20f;
GUILayout.Space(20f);
using (new DragonGUI.ColorScope(Color.white * 0.5f)) GUILayout.BeginVertical(EditorStyles.helpBox);
using (new EcsGUI.ColorScope(Color.white * 0.5f))
GUILayout.BeginVertical(EditorStyles.helpBox);
//using (new EcsGUI.ColorScope(Color.white * 1.2f))
GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f));
Rect rect = GUILayoutUtility.GetLastRect();
rect.xMin += 9f;
GUI.Label(rect, "User Settings", EditorStyles.whiteLargeLabel);
prefs.IsShowHidden = EditorGUILayout.ToggleLeft(
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowHidden)),
prefs.IsShowHidden);
//using (prefs.DisableAutoSave())
{
prefs.IsShowHidden = EditorGUILayout.ToggleLeft(
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowHidden)),
prefs.IsShowHidden);
prefs.IsShowInterfaces = EditorGUILayout.ToggleLeft(
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowInterfaces)),
prefs.IsShowInterfaces);
prefs.IsShowInterfaces = EditorGUILayout.ToggleLeft(
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowInterfaces)),
prefs.IsShowInterfaces);
prefs.IsShowRuntimeComponents = EditorGUILayout.ToggleLeft(
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowRuntimeComponents)),
prefs.IsShowRuntimeComponents);
prefs.IsShowRuntimeComponents = EditorGUILayout.ToggleLeft(
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowRuntimeComponents)),
prefs.IsShowRuntimeComponents);
prefs.IsUseCustomNames = EditorGUILayout.ToggleLeft(
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsUseCustomNames)),
prefs.IsUseCustomNames);
prefs.IsUseCustomNames = EditorGUILayout.ToggleLeft(
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsUseCustomNames)),
prefs.IsUseCustomNames);
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);
//prefs.IsFastModeRuntimeComponents = EditorGUILayout.ToggleLeft(
// UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsFastModeRuntimeComponents)),
// prefs.IsFastModeRuntimeComponents);
prefs.ComponentColorMode = (ComponentColorMode)EditorGUILayout.EnumPopup(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.ComponentColorMode)), prefs.ComponentColorMode);
}
GUILayout.EndVertical();
GUILayout.Space(20f);
using (DragonGUI.SetColor(Color.white * 0.5f))
using (EcsGUI.SetColor(Color.white * 0.5f))
{
GUILayout.BeginVertical(EditorStyles.helpBox);
}
@ -85,6 +94,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
InitDefines();
}
GUILayout.EndVertical();
EditorGUIUtility.labelWidth = labelWidth;
}
}
}

View File

@ -4,18 +4,7 @@ using UnityEngine;
namespace DCFApixels.DragonECS.Unity.Editors
{
internal enum RuntimeDrawMode
{
Lazy = 0,
Live = 1,
}
internal enum MetaBlockRectStyle
{
Clean = 0,
Edge = 1,
Fill = 2,
}
internal enum MetaBlockColorMode
internal enum ComponentColorMode
{
Generic = 0,
Auto = 1,
@ -94,61 +83,31 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
}
[SerializeField]
private bool _isPauseOnSnapshot = true;
public bool IsPauseOnSnapshot
{
get => _isPauseOnSnapshot;
set
{
if (_isPauseOnSnapshot != value)
{
_isPauseOnSnapshot = value;
AutoSave();
}
}
}
//[SerializeField]
//private bool _isFastModeRuntimeComponents = false;
//public bool IsFastModeRuntimeComponents
//{
// get => _isFastModeRuntimeComponents;
// set
// {
// if (_isFastModeRuntimeComponents != value)
// {
// _isFastModeRuntimeComponents = value;
// AutoSave();
// }
// }
//}
[SerializeField]
private RuntimeDrawMode _runtimeDrawMode = RuntimeDrawMode.Live;
public RuntimeDrawMode RuntimeDrawMode
private ComponentColorMode _componentColorMode = ComponentColorMode.Auto;
public ComponentColorMode ComponentColorMode
{
get => _runtimeDrawMode;
get => _componentColorMode;
set
{
if (_runtimeDrawMode != value)
if (_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;
_componentColorMode = value;
AutoSave();
}
}

View File

@ -8,15 +8,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
[CustomEditor(typeof(EntityMonitor))]
internal class EntityMonitorEditor : ExtendedEditor<EntityMonitor>
{
public override bool RequiresConstantRepaint()
{
return UserSettingsPrefs.instance.RuntimeDrawMode == RuntimeDrawMode.Live ? true : base.RequiresConstantRepaint();
}
protected override void DrawCustom()
{
var entity = Target.Entity;
bool isAlive = entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world);
using (DragonGUI.SetEnable(isAlive))
using (EcsGUI.SetEnable(isAlive))
{
if (GUILayout.Button("Delete Entity", GUILayout.Height(36f)))
{
@ -24,18 +20,18 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
//EcsGUI.Layout.EntityBarForAlive(isAlive ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive, id, gen, worldID);
DragonGUI.Layout.EntityField(entity);
EcsGUI.Layout.EntityField(entity);
var drawers = UnityEditorUtility._entityEditorBlockDrawers;
if (drawers.Length > 0)
{
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{
bool isExpand = false;
using (DragonGUI.CheckChanged())
using (EcsGUI.CheckChanged())
{
isExpand = EditorGUILayout.Foldout(UserSettingsPrefs.instance.IsShowEntityOtherData, "Other data");
if (DragonGUI.Changed)
if (EcsGUI.Changed)
{
UserSettingsPrefs.instance.IsShowEntityOtherData = isExpand;
}
@ -52,7 +48,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
DragonGUI.Layout.DrawRuntimeComponents(entity, false);
EcsGUI.Layout.DrawRuntimeComponents(entity, false);
}
}
}

View File

@ -1,5 +1,5 @@
#if UNITY_EDITOR
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.RunnersCore;
using DCFApixels.DragonECS.Unity.Internal;
using System;
using System.Linq;
@ -41,7 +41,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
else
{
color = DragonGUI.SelectPanelColor(meta, i, -1).ToMetaColor();
color = EcsGUI.SelectPanelColor(meta, i, -1).ToMetaColor();
}
name = $"{meta.Name}{SEPARATOR}{meta.TypeName}{SEPARATOR}{meta.MetaID}{SEPARATOR}{color.colorCode:X8}";
}
@ -71,7 +71,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
_headerStyle.fontSize = 28;
}
using (DragonGUI.Layout.BeginHorizontal())
using (EcsGUI.Layout.BeginHorizontal())
{
GUILayout.Label("[Systems]", _headerStyle, GUILayout.ExpandWidth(true));
if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
@ -83,7 +83,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
IsShowInterfaces = EditorGUILayout.Toggle("Show Interfaces", IsShowInterfaces);
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden);
using (DragonGUI.Layout.BeginVertical())
using (EcsGUI.Layout.BeginVertical())
{
int i = 0;
foreach (var item in Target.Pipeline.AllSystems)
@ -95,7 +95,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
GUILayout.Label("[Runners]", _headerStyle);
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{
int i = 0;
foreach (var item in Target.Pipeline.AllRunners)
@ -114,13 +114,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
GUILayout.EndVertical();
GUILayout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle());
using (DragonGUI.Layout.BeginHorizontal()) using (var scope = DragonGUI.SetAlignment(GUI.skin.label))
using (EcsGUI.Layout.BeginHorizontal()) using (var scope = EcsGUI.SetAlignment(GUI.skin.label))
{
scope.Target.alignment = TextAnchor.UpperLeft;
GUILayout.Label("<", GUILayout.ExpandWidth(true));
scope.Target.alignment = TextAnchor.UpperRight;
using (DragonGUI.SetAlpha(0.64f))
using (EcsGUI.SetAlpha(0.64f))
{
GUILayout.Label($"{markerSystem.layerNameSpace}", GUILayout.ExpandWidth(false));
}
@ -128,7 +128,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * -4f);
scope.Target.alignment = TextAnchor.UpperLeft;
using (DragonGUI.SetFontStyle(scope.Target, FontStyle.Bold))
using (EcsGUI.SetFontStyle(scope.Target, FontStyle.Bold))
{
GUILayout.Label($"{markerSystem.layerName}", GUILayout.ExpandWidth(false));
}
@ -147,10 +147,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
string name = meta.Name;
Color color = DragonGUI.SelectPanelColor(meta, index, -1);
Color color = EcsGUI.SelectPanelColor(meta, index, -1);
using (DragonGUI.Layout.BeginVertical(color.SetAlpha(0.2f)))
using (EcsGUI.Layout.BeginVertical(color.SetAlpha(0.2f)))
{
if (IsShowInterfaces)
{
@ -168,9 +168,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
return;
}
Color color = DragonGUI.SelectPanelColor(meta, index, -1);
Color color = EcsGUI.SelectPanelColor(meta, index, -1);
using (DragonGUI.Layout.BeginVertical(color.SetAlpha(0.2f)))
using (EcsGUI.Layout.BeginVertical(color.SetAlpha(0.2f)))
{
GUILayout.Label(meta.Name, EditorStyles.boldLabel);
GUILayout.Label(string.Join(", ", runner.ProcessRaw.Cast<object>().Select(o => o.GetType().Name)), systemsListStyle);

View File

@ -61,10 +61,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
protected override void DrawCustom()
{
using (DragonGUI.CheckChanged())
using (EcsGUI.CheckChanged())
{
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden);
if (DragonGUI.Changed)
if (EcsGUI.Changed)
{
Init();
}
@ -104,7 +104,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
color = NormalizeGridColor(i, color);
EditorGUI.DrawRect(lineRect, color);
if (DragonGUI.HitTest(lineRect))
if (EcsGUI.HitTest(lineRect))
{
GUI.Button(lineRect, "", EditorStyles.selectionRect);
_selectedPointMeta.process = meta;
@ -135,7 +135,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
color = NormalizeGridColor(i, color);
EditorGUI.DrawRect(lineRect, color);
if (DragonGUI.HitTest(lineRect))
if (EcsGUI.HitTest(lineRect))
{
GUI.Button(lineRect, "", EditorStyles.selectionRect);
_selectedPointMeta.system = meta;

View File

@ -1,234 +0,0 @@
#if UNITY_EDITOR
using DCFApixels.DragonECS.Core.Unchecked;
using DCFApixels.DragonECS.Unity.Internal;
using UnityEditor;
using UnityEngine;
using static DCFApixels.DragonECS.Unity.Editors.DragonGUI;
namespace DCFApixels.DragonECS.Unity.Editors
{
internal class QuerySnapshotWindow : EditorWindow
{
private EcsWorld _world;
private StructList<entlong> _list;
private readonly Color _selectionColor = new Color(0.12f, 0.5f, 1f, 0.40f);
private readonly Color _isAliveColor = new Color(0.2f, 0.6f, 1f);
private readonly Color _hoverColor = new Color(1f, 1f, 1f, 0.12f);
public static void ShowNew(EcsSpan entites)
{
var newWin = CreateWindow<QuerySnapshotWindow>("Query Snapshot");
newWin.Setup(entites);
newWin.ShowUtility();
if (UserSettingsPrefs.instance.IsPauseOnSnapshot)
{
Debug.Break();
}
}
private void Setup(EcsSpan entites)
{
_world = entites.World;
_list = new StructList<entlong>(entites.Count);
_list._count = entites.Longs.ToArray(ref _list._items);
}
private Vector2 _scrollState;
private void OnGUI()
{
if (_world.IsDestroyed) { _world = null; }
if (_world == null)
{
Close();
return;
}
int selectedEntity = -1;
var selectedGO = Selection.activeGameObject;
if (selectedGO != null &&
selectedGO.TryGetComponent<EntityMonitor>(out var selectedMonitor) &&
selectedMonitor.Entity.TryUnpack(_world, out selectedEntity) == false)
{
selectedEntity = -1;
}
SelectEvent selectEvent = default;
var line = EditorGUIUtility.singleLineHeight;
var space = EditorGUIUtility.standardVerticalSpacing;
var step = line + space;
Event current = Event.current;
if (hasFocus && current.type == EventType.KeyUp && current.isKey)
{
if (current.keyCode == KeyCode.DownArrow)
{
selectEvent.Type = SelectEventType.Down;
}
if (current.keyCode == KeyCode.UpArrow)
{
selectEvent.Type = SelectEventType.Up;
}
}
var rect = position;
rect.x = 0;
rect.y = 0;
Rect hyperlinkButtonRect;
Rect topLineRect;
(topLineRect, rect) = rect.VerticalSliceTop(line + space);
topLineRect = topLineRect.AddPadding(0, 0, 0, space);
(topLineRect, hyperlinkButtonRect) = topLineRect.HorizontalSliceRight(18f);
EditorGUI.IntField(topLineRect, "World: ", _world.ID);
using (DragonGUI.SetEnable(_world != null))
{
DragonGUI.WorldHyperlinkButton(hyperlinkButtonRect, _world);
}
(topLineRect, rect) = rect.VerticalSliceTop(line + space);
UserSettingsPrefs.instance.IsPauseOnSnapshot = EditorGUI.ToggleLeft(topLineRect, "Pause On Snapshot", UserSettingsPrefs.instance.IsPauseOnSnapshot);
var viewRect = rect;
viewRect.x = 0;
viewRect.y = 0;
viewRect.height = (line + space) * _list.Count;
viewRect.xMax -= GUI.skin.verticalScrollbar.fixedWidth;
var lineRect = viewRect;
lineRect.height = line;
Rect statusR;
(statusR, lineRect) = lineRect.HorizontalSliceLeft(3f);
_scrollState = GUI.BeginScrollView(rect, _scrollState, viewRect, false, true);
var checkRect = rect;
checkRect.position = Vector2.zero;
bool foundSelected = false;
for (int i = 0; i < _list.Count; i++)
{
EntitySlotInfo entity = (EntitySlotInfo)_list[i];
bool isAlive = _world.IsAlive(entity.id, entity.gen);
bool selected = selectedEntity == entity.id && isAlive;
foundSelected |= selected;
bool isClick = false;
bool visible = lineRect.Overlaps(checkRect.AddOffset(_scrollState));
if (visible)
{
using (DragonGUI.SetAlpha(0)) { GUI.Label(lineRect, string.Empty, GUI.skin.button); }
if (DragonGUI.HitTest(lineRect))
{
EditorGUI.DrawRect(lineRect, _hoverColor);
if (current.type == EventType.MouseUp)
{
isClick = true;
}
}
if (selected)
{
DragonGUI.DrawRect(lineRect, _selectionColor);
}
if (isAlive)
{
DragonGUI.DrawRect(statusR, _isAliveColor);
}
var (labelR, infoR) = lineRect.HorizontalSliceLeft(45f);
infoR.width = Mathf.Min(infoR.width, 200f);
var (lR, rR) = infoR.HorizontalSliceLerp(0.5f);
GUI.Label(labelR, "Entity", GUI.skin.label);
EditorGUI.IntField(lR, entity.id, GUI.skin.label);
EditorGUI.IntField(rR, entity.gen, GUI.skin.label);
if (isClick && isAlive)
{
selectEvent.Type = SelectEventType.Click;
selectEvent.EntityID = entity.id;
selectEvent.Index = i;
}
}
if (isAlive)
{
switch (selectEvent.Type)
{
case SelectEventType.Up:
{
if (foundSelected == false)
{
selectEvent.EntityID = entity.id;
selectEvent.Index = i;
}
}
break;
case SelectEventType.Down:
{
if (foundSelected && selected == false && selectEvent.EntityID == 0)
{
selectEvent.EntityID = entity.id;
selectEvent.Index = i;
}
}
break;
}
}
lineRect.y += step;
statusR.y += step;
}
GUI.EndScrollView();
if (selectEvent.IsSelected && selectedEntity != selectEvent.EntityID)
{
float top = selectEvent.Index * step;
float bottom = top + step;
if (top < _scrollState.y)
{
_scrollState.y = top;
}
else if (bottom > _scrollState.y + checkRect.height)
{
_scrollState.y = bottom - checkRect.height;
}
GUIUtility.keyboardControl = 0;
SelectEntity(selectEvent.EntityID);
}
if (selectEvent.IsSelected)
{
Repaint();
return;
}
}
private void SelectEntity(int entityID)
{
var monitor = _world.Get<EntityLinksComponent>().GetMonitorLink(entityID);
EditorGUIUtility.PingObject(monitor);
Selection.activeObject = monitor;
}
private void OnDestroy() { }
private struct SelectEvent
{
public SelectEventType Type;
public int EntityID;
public int Index;
public bool IsSelected { get { return Type != SelectEventType.None && EntityID != 0; } }
}
private enum SelectEventType
{
None,
Click,
Up,
Down,
}
}
}
#endif

View File

@ -1,5 +1,5 @@
#if UNITY_EDITOR
using DCFApixels.DragonECS.Core.Unchecked;
using DCFApixels.DragonECS.UncheckedCore;
using DCFApixels.DragonECS.Unity.Internal;
using System.Text;
using UnityEditor;
@ -107,7 +107,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
_headerStyle.fontSize = 28;
}
using (DragonGUI.Layout.BeginHorizontal())
using (EcsGUI.Layout.BeginHorizontal())
{
GUILayout.Label("[World]", _headerStyle, GUILayout.ExpandWidth(true));
if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
@ -117,9 +117,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
DragonGUI.Layout.DrawWorldBaseInfo(Target.World);
EcsGUI.Layout.DrawWorldBaseInfo(Target.World);
DragonGUI.Layout.DrawWorldComponents(Target.World);
EcsGUI.Layout.DrawWorldComponents(Target.World);
}
}
}

View File

@ -12,73 +12,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
internal class WorldQueriesMonitorEditor : ExtendedEditor<WorldQueriesMonitor>
{
private GUIStyle _headerStyle;
private const char _searchPatternSeparator = '/';
public readonly struct SearchPattern
{
private readonly string _pattern;
private readonly char _separator;
public SearchPattern(string pattern, char separator)
{
_pattern = pattern ?? throw new ArgumentNullException(nameof(pattern));
_separator = separator;
}
public Enumerator GetEnumerator() { return new Enumerator(_pattern, _separator); }
public ref struct Enumerator
{
private readonly string _pattern;
private readonly char _separator;
private int _start;
private int _currentStart;
private int _currentLength;
public Enumerator(string pattern, char separator)
{
_pattern = pattern;
_separator = separator;
_start = 0;
_currentStart = -1;
_currentLength = 0;
}
public ReadOnlySpan<char> Current
{
get { return _pattern.AsSpan(_currentStart, _currentLength); }
}
public bool MoveNext()
{
if (_pattern == null || _start > _pattern.Length)
{
return false;
}
int len = _pattern.Length;
while (_start <= len)
{
int i = _start;
while (i < len && _pattern[i] != _separator)
{
i++;
}
int subLen = i - _start;
if (subLen > 0) // возвращаем только непустые подстроки
{
_currentStart = _start;
_currentLength = subLen;
_start = i + 1;
return true;
}
// пустая подстрока — пропускаем разделитель и продолжаем
_start = i + 1;
}
return false;
}
}
}
private void CopyToClipboard()
{
@ -142,10 +75,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
var incs = query.Mask.Incs;
var excs = query.Mask.Excs;
var anys = query.Mask.Anys;
var incsI = 0;
var excsI = 0;
var anysI = 0;
for (int j = 0; j < allpools.Length; j++)
{
var pool = allpools[j];
@ -166,13 +97,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
excsI++;
continue;
}
if (anysI < anys.Length && anys[anysI] == j)
{
sb.Append($"~");
anysI++;
continue;
}
}
}
sb.Append("\r\n");
@ -193,7 +117,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
var executors = Target.MaskQueryExecutors;
using (DragonGUI.Layout.BeginHorizontal())
using (EcsGUI.Layout.BeginHorizontal())
{
GUILayout.Label("[Queries]", _headerStyle, GUILayout.ExpandWidth(true));
if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
@ -202,9 +126,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
GUILayout.Space(10f);
EditorGUILayout.IntField("Count: ", executors.Count);
EditorGUILayout.IntField("Total Count: ", executors.Count);
HasSearchPattern = true;
if (string.IsNullOrEmpty(Target.SearchPattern))
@ -212,57 +135,34 @@ namespace DCFApixels.DragonECS.Unity.Editors
Target.SearchPattern = string.Empty;
HasSearchPattern = false;
}
GUILayout.Space(10f);
Target.SearchPattern = EditorGUILayout.TextField(Target.SearchPattern, EditorStyles.toolbarSearchField);
Target.SearchPattern = EditorGUILayout.TextField("Search: ", Target.SearchPattern);
string searchPattern = Target.SearchPattern;
var r = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 3f);
DragonGUI.DrawRect(r, Color.white.SetAlpha(0.5f));
GUILayout.Space(10f);
GUILayout.Space(20);
//using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f)))
{
int i = 0;
foreach (var executor in executors)
{
bool cheack(ReadOnlySpan<Type> types, ReadOnlySpan<char> searchPatternRaw)
bool cheack(ReadOnlySpan<Type> types, string searchPattern)
{
foreach (var type in types)
{
if(type.Name.AsSpan().Contains(searchPatternRaw, StringComparison.OrdinalIgnoreCase))
if(type.Name.Contains(searchPattern, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
bool isDraw = false;
if (HasSearchPattern)
{
int subPuttornsCount = 0;
int checkPassesCount = 0;
foreach (var subPattern in new SearchPattern(searchPattern, _searchPatternSeparator))
{
subPuttornsCount++;
if (cheack(executor.Mask.GetIncTypes_Debug(), subPattern) ||
cheack(executor.Mask.GetExcTypes_Debug(), subPattern) ||
cheack(executor.Mask.GetAnyTypes_Debug(), subPattern))
{
checkPassesCount++;
}
}
isDraw = subPuttornsCount <= checkPassesCount;
}
else
{
isDraw = true;
}
if(isDraw)
if (!HasSearchPattern ||
cheack(executor.Mask.GetIncTypes_Debug(), searchPattern) ||
cheack(executor.Mask.GetExcTypes_Debug(), searchPattern) ||
cheack(executor.Mask.GetAnyTypes_Debug(), searchPattern))
{
DrawQueryInfo(executor, i++);
}
@ -279,20 +179,15 @@ namespace DCFApixels.DragonECS.Unity.Editors
//using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(GetGenericPanelColor(index))))
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{
var mask = executor.Mask;
DrawConstraint("+", mask.Incs);
DrawConstraint("-", mask.Excs);
DrawConstraint("~", mask.Anys);
}
EditorGUILayout.LongField("Version: ", executor.Version);
EditorGUILayout.IntField("Entites Count: ", executor.LastCachedCount);
if (GUILayout.Button("Snapshot"))
{
QuerySnapshotWindow.ShowNew(executor.Snapshot());
}
//var rect = GUILayoutUtility.GetLastRect();
//
@ -310,24 +205,24 @@ namespace DCFApixels.DragonECS.Unity.Editors
return;
}
using (DragonGUI.Layout.BeginHorizontal())
using (EcsGUI.Layout.BeginHorizontal())
{
using (DragonGUI.SetAlignment(value: TextAnchor.MiddleCenter))
using (DragonGUI.SetFontStyle(value: FontStyle.Bold))
using (DragonGUI.SetFontSize(value: 18))
using (DragonGUI.SetColor(Color.white, 0.3f))
using (EcsGUI.SetAlignment(value: TextAnchor.MiddleCenter))
using (EcsGUI.SetFontStyle(value: FontStyle.Bold))
using (EcsGUI.SetFontSize(value: 18))
using (EcsGUI.SetColor(Color.white, 0.3f))
GUILayout.Label(title, GUILayout.Width(12));
using (DragonGUI.Layout.BeginVertical())
using (EcsGUI.Layout.BeginVertical())
{
foreach (var inc in ids)
{
Type type = Target.World.GetComponentType(inc);
TypeMeta meta = type.GetMeta();
Color color = DragonGUI.SelectPanelColor(meta, i, 9);
Color color = EcsGUI.SelectPanelColor(meta, i, 9);
using (DragonGUI.Layout.BeginVertical(color.SetAlpha(0.2f)))
using (EcsGUI.Layout.BeginVertical(color.SetAlpha(0.2f)))
{
GUILayout.Label(meta.TypeName);
}

View File

@ -20,7 +20,7 @@ namespace DCFApixels.DragonECS.Unity.Internal
_entity = entity;
#if UNITY_EDITOR
var world = entity.GetWorldUnchecked();
world.Get<DragonGUI.EntityLinksComponent>().SetMonitorLink(entity.GetIDUnchecked(), this);
world.Get<EcsGUI.EntityLinksComponent>().SetMonitorLink(entity.GetIDUnchecked(), this);
#endif
}
}

View File

@ -19,9 +19,6 @@ namespace DCFApixels.DragonECS.Unity.Internal
public void Set(EcsWorld world)
{
_world = world;
#if UNITY_EDITOR
world.Get<DragonGUI.EntityLinksComponent>().SetWorldMonitor(this);
#endif
}
}
@ -133,7 +130,5 @@ namespace DCFApixels.DragonECS.Unity.Internal
_entityMonitorRef.Set(_world.GetEntityLong(entityID));
}
}
public void OnMigrateEntity(int entityID) { }
}
}

View File

@ -29,7 +29,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ (byte)AddParamsFlags.NoImport | 7, "NoImport, Layer, Order, IsUnique" },
{ byte.MaxValue, "NoImport, Layer, Order, IsUnique" },
};
protected override float GetCustomHeight(SerializedProperty property, GUIContent label)
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
//return !property.isExpanded ?
// EditorGUIUtility.singleLineHeight + Spacing :
@ -51,11 +52,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
(foldoutRect, labelField) = foldoutRect.HorizontalSliceLeft(EditorGUIUtility.labelWidth);
using (DragonGUI.CheckChanged())
using (EcsGUI.CheckChanged())
{
property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label);
using (DragonGUI.SetAlignment(EditorStyles.miniLabel, TextAnchor.MiddleRight))
using (EcsGUI.SetAlignment(EditorStyles.miniLabel, TextAnchor.MiddleRight))
{
if (_labelCache.TryGetValue((byte)(flags.Normalize()), out string str) == false)
{
@ -70,7 +71,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
//property.isExpanded = true;
using (DragonGUI.UpIndentLevel())
using (EcsGUI.UpIndentLevel())
{
checkboxRects = checkboxRects.Move(EditorGUIUtility.standardVerticalSpacing, 0);
@ -81,11 +82,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
//LayerName
property.Next(true);
using (DragonGUI.SetIndentLevel(0))
using (EcsGUI.SetIndentLevel(0))
{
flags = flags.SetOverwriteLayerName(EditorGUI.Toggle(checkboxRect, flags.IsOverwriteLayerName()));
}
using (DragonGUI.SetEnable(flags.IsOverwriteLayerName()))
using (EcsGUI.SetEnable(flags.IsOverwriteLayerName()))
{
EditorGUI.PropertyField(fieldRect, property, UnityEditorUtility.GetLabel(property.displayName), true);
}
@ -95,11 +96,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
//SortOrder
property.Next(false);
using (DragonGUI.SetIndentLevel(0))
using (EcsGUI.SetIndentLevel(0))
{
flags = flags.SetOverwriteSortOrder(EditorGUI.Toggle(checkboxRect, flags.IsOverwriteSortOrder()));
}
using (DragonGUI.SetEnable(flags.IsOverwriteSortOrder()))
using (EcsGUI.SetEnable(flags.IsOverwriteSortOrder()))
{
EditorGUI.PropertyField(fieldRect, property, UnityEditorUtility.GetLabel(property.displayName), true);
}
@ -109,16 +110,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
//IsUnique
property.Next(false);
using (DragonGUI.SetIndentLevel(0))
using (EcsGUI.SetIndentLevel(0))
{
flags = flags.SetOverwriteIsUnique(EditorGUI.Toggle(checkboxRect, flags.IsOverwriteIsUnique()));
}
using (DragonGUI.SetEnable(flags.IsOverwriteIsUnique()))
using (EcsGUI.SetEnable(flags.IsOverwriteIsUnique()))
{
EditorGUI.PropertyField(fieldRect, property, UnityEditorUtility.GetLabel(property.displayName), true);
}
if (DragonGUI.Changed)
if (EcsGUI.Changed)
{
flagsProp.enumValueFlag = (int)flags;
}
@ -133,7 +134,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
exti:;
//EcsGUI.Changed = Event.current.type == EventType.MouseUp;
if (DragonGUI.Changed)
if (EcsGUI.Changed)
{
property.serializedObject.ApplyModifiedProperties();
}

View File

@ -18,10 +18,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
[CustomPropertyDrawer(typeof(CustomToggleAttribute))]
internal class LeftToggleAttributeDrawer : ExtendedPropertyDrawer<CustomToggleAttribute>
{
protected override float GetCustomHeight(SerializedProperty property, GUIContent label)
{
return OneLineHeight + Spacing;
}
protected override void DrawCustom(Rect position, SerializedProperty property, GUIContent label)
{
if (property.propertyType != SerializedPropertyType.Boolean)

View File

@ -10,7 +10,7 @@ using UnityObject = UnityEngine.Object;
namespace DCFApixels.DragonECS.Unity.Editors
{
internal static partial class DragonGUI
internal static partial class EcsGUI
{
public static partial class Layout
{
@ -38,7 +38,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
public static void ScriptAssetButton(MonoScript script, params GUILayoutOption[] options)
{
DragonGUI.ScriptAssetButton(GUILayoutUtility.GetRect(UnityEditorUtility.GetLabelTemp(), EditorStyles.miniButton, options), script);
EcsGUI.ScriptAssetButton(GUILayoutUtility.GetRect(UnityEditorUtility.GetLabelTemp(), EditorStyles.miniButton, options), script);
}
@ -85,11 +85,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
public static void DrawEmptyComponentProperty(SerializedProperty property, string name, bool isDisplayEmpty)
{
DragonGUI.DrawEmptyComponentProperty(GUILayoutUtility.GetRect(UnityEditorUtility.GetLabel(name), EditorStyles.label), property, name, isDisplayEmpty);
EcsGUI.DrawEmptyComponentProperty(GUILayoutUtility.GetRect(UnityEditorUtility.GetLabel(name), EditorStyles.label), property, name, isDisplayEmpty);
}
public static void DrawEmptyComponentProperty(SerializedProperty property, GUIContent label, bool isDisplayEmpty)
{
DragonGUI.DrawEmptyComponentProperty(GUILayoutUtility.GetRect(label, EditorStyles.label), property, label, isDisplayEmpty);
EcsGUI.DrawEmptyComponentProperty(GUILayoutUtility.GetRect(label, EditorStyles.label), property, label, isDisplayEmpty);
}
public static void DrawWorldBaseInfo(EcsWorld world)
{
@ -121,11 +121,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
EntityField(UnityEditorUtility.GetLabel(label), entity);
}
public static void EntityField(GUIContent label, entlong entity)
public static unsafe void EntityField(GUIContent label, entlong entity)
{
float width = EditorGUIUtility.currentViewWidth;
float height = EntityBarHeight;
DragonGUI.EntityField(GUILayoutUtility.GetRect(width, height), label, entity);
EcsGUI.EntityField(GUILayoutUtility.GetRect(width, height), label, entity);
}
public static void EntityField(EntitySlotInfo entity)
{
@ -139,7 +139,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
float width = EditorGUIUtility.currentViewWidth;
float height = EntityBarHeight;
DragonGUI.EntityField(GUILayoutUtility.GetRect(width, height), label, entity);
EcsGUI.EntityField(GUILayoutUtility.GetRect(width, height), label, entity);
}
public static void EntityField(SerializedProperty property)
{
@ -153,21 +153,21 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
float width = EditorGUIUtility.currentViewWidth;
float height = EntityBarHeight;
DragonGUI.EntityField(GUILayoutUtility.GetRect(width, height), property, label);
EcsGUI.EntityField(GUILayoutUtility.GetRect(width, height), property, label);
}
#endregion
public static bool AddComponentButtons(out Rect dropDownRect)
{
return DragonGUI.AddComponentButton(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect);
return EcsGUI.AddComponentButton(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect);
}
public static AddClearButton AddClearComponentButtons(out Rect dropDownRect)
{
return DragonGUI.AddClearComponentButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect);
return EcsGUI.AddClearComponentButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect);
}
public static AddClearButton AddClearSystemButtons(out Rect dropDownRect)
{
return DragonGUI.AddClearSystemButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect);
return EcsGUI.AddClearSystemButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect);
}
public static void DrawRuntimeComponents(entlong entity, bool isWithFoldout, bool isRoot = true)
{

View File

@ -8,12 +8,11 @@ using System.Reflection;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using UnityEngine.Serialization;
using Color = UnityEngine.Color;
namespace DCFApixels.DragonECS.Unity.Editors
{
internal static partial class DragonGUI
internal static partial class EcsGUI
{
#region Scores
private static int _changedCounter = 0;
@ -73,20 +72,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
}
public static SerializedProperty CurrentTrackedArrayProperty;
public readonly struct TrackArrayPropertyScope : IDisposable
{
private readonly SerializedProperty _sp;
public TrackArrayPropertyScope(SerializedProperty sp)
{
_sp = sp;
CurrentTrackedArrayProperty = null;
}
public void Dispose()
{
CurrentTrackedArrayProperty = _sp;
}
}
public readonly struct CheckChangedScopeWithAutoApply : IDisposable
{
private readonly CheckChangedScope _scope;
@ -222,18 +207,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
public VerticalScope(GUILayoutOption[] options) { GUILayout.BeginVertical(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)
{
using (SetColor(backgroundColor))
{
GUILayout.BeginVertical(UnityEditorUtility.GetWhiteStyleWithPadding(), options);
GUILayout.BeginVertical(UnityEditorUtility.GetWhiteStyle(), options);
}
}
public void Dispose() { GUILayout.EndVertical(); }
@ -246,7 +224,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
using (SetColor(backgroundColor))
{
GUILayout.BeginHorizontal(UnityEditorUtility.GetWhiteStyleWithPadding(), options);
GUILayout.BeginHorizontal(UnityEditorUtility.GetWhiteStyle(), options);
}
}
public void Dispose() { GUILayout.EndHorizontal(); }
@ -269,7 +247,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
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(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 CheckChangedScopeWithAutoApply CheckChanged(SerializedObject serializedObject) => new CheckChangedScopeWithAutoApply(serializedObject);
@ -331,10 +308,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
get => EditorGUIUtility.standardVerticalSpacing;
}
private static MetaBlockColorMode MetaBlockColorMode
private static ComponentColorMode AutoColorMode
{
get { return UserSettingsPrefs.instance.MetaBlockColorMode; }
set { UserSettingsPrefs.instance.MetaBlockColorMode = value; }
get { return UserSettingsPrefs.instance.ComponentColorMode; }
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
}
private static bool IsShowHidden
{
@ -398,33 +375,35 @@ namespace DCFApixels.DragonECS.Unity.Editors
#endregion
#region small elems
public static void DrawTextureSoftColor(Rect position, Texture texture)
{
if (Event.current.type == EventType.Repaint)
{
Graphics.DrawTexture(position, texture, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color * 0.5f, null);
}
}
public static void DrawTexture(Rect position, Texture texture)
{
DrawTex(position, texture, GUI.color);
if (Event.current.type == EventType.Repaint)
{
Graphics.DrawTexture(position, texture, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color, null);
}
}
public static void DrawRectSoftColor(Rect position, Color color)
{
if (Event.current.type == EventType.Repaint)
{
Texture texture = UnityEditorUtility.GetWhiteTexture();
Graphics.DrawTexture(position, texture, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color * color * 0.5f, null);
}
}
public static void DrawRect(Rect position, Color color)
{
Texture texture = UnityEditorUtility.GetWhiteTexture();
DrawTex(position, texture, GUI.color * color);
}
private static void DrawTex(Rect position, Texture texture, Color color)
{
//GUI.DrawTexture(position, texture, ScaleMode.StretchToFill, true, 0, color, 0, 0);
using (SetColor(color))
if (Event.current.type == EventType.Repaint)
{
GUI.DrawTexture(position, texture, ScaleMode.StretchToFill);
Texture texture = UnityEditorUtility.GetWhiteTexture();
Graphics.DrawTexture(position, texture, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color * color, null);
}
//if (Event.current.type == EventType.Repaint)
//{
// Graphics.DrawTexture(position, texture, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color * color, null);
//}
//var x = GUIClip.visibleRect;
//Rect visibleRect = new Rect(0, 0, scrollViewWidth, scrollViewHeight); // свой прямоугольник обрезки
//GUI.BeginClip(visibleRect);
//Graphics.DrawTexture(new Rect(position.x - visibleRect.x, position.y - visibleRect.y, position.width, position.height), texture);
//GUI.EndClip();
}
public static void DrawIcon(Rect position, Texture icon, float iconPadding, string tooltip)
{
@ -439,7 +418,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
using (SetColor(GUI.enabled ? GUI.color : GUI.color * new Color(1f, 1f, 1f, 0.4f)))
{
GUI.Label(position, UnityEditorUtility.GetLabel(string.Empty, tooltip));
DrawTexture(RectUtility.AddPadding(position, iconPadding), icon);
DrawTextureSoftColor(RectUtility.AddPadding(position, iconPadding), icon);
}
}
public static (bool, bool) IconButtonGeneric(Rect position)
@ -447,8 +426,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
using (SetAlpha(0))
{
bool result = GUI.Button(position, string.Empty, EditorStyles.miniButtonMid);
var currentEvent = Event.current;
return (GUI.enabled && HitTest(position, currentEvent), result);
var current = Event.current;
return (GUI.enabled && HitTest(position, current), result);
}
}
public static bool IconHoverScan(Rect position, Event current)
@ -472,25 +451,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
DrawIcon(position, Icons.Instance.HelpIcon, 0, description);
}
}
public static void WorldHyperlinkButton(Rect position, EcsWorld world)
{
var current = Event.current;
var hover = IconHoverScan(position, current);
var click = IconButton(position, Icons.Instance.HyperlinkIcon, 2f, string.Empty);
if (GUI.enabled)
{
if (click)
{
var monitor = world.Get<EntityLinksComponent>().GetWorldMonitor();
if (monitor != null)
{
EditorGUIUtility.PingObject(monitor);
Selection.activeObject = monitor;
}
}
}
}
public static void EntityHyperlinkButton(Rect position, EcsWorld world, int entityID)
{
var current = Event.current;
@ -525,13 +486,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
if (current.type == EventType.MouseUp)
{
EditorGUIUtility.PingObject(script);
Event.current.Use();
}
else if (current.type == EventType.MouseDown && current.clickCount >= 2)
{
//UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(); //TODO
AssetDatabase.OpenAsset(script);
Event.current.Use();
}
}
}
@ -591,15 +550,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
private readonly Storage _storage;
private EntityLinksComponent(Storage storage) { _storage = storage; }
public void SetWorldMonitor(WorldMonitor monitor) { _storage.WorldMonitor = monitor; }
public WorldMonitor GetWorldMonitor() { return _storage.WorldMonitor; }
public void SetConnectLink(int entityID, EcsEntityConnect link) { _storage.Links[entityID].connect = link; }
public void SetMonitorLink(int entityID, EntityMonitor link) { _storage.Links[entityID].monitor = link; }
public EcsEntityConnect GetConnectLink(int entityID) { return _storage.Links[entityID].connect; }
public EntityMonitor GetMonitorLink(int entityID) { return _storage.Links[entityID].monitor; }
public void SetConnectLink(int entityID, EcsEntityConnect link) { _storage.links[entityID].connect = link; }
public void SetMonitorLink(int entityID, EntityMonitor link) { _storage.links[entityID].monitor = link; }
public EcsEntityConnect GetConnectLink(int entityID) { return _storage.links[entityID].connect; }
public EntityMonitor GetMonitorLink(int entityID) { return _storage.links[entityID].monitor; }
public UnityEngine.Object GetLink(int entityID)
{
ref var links = ref _storage.Links[entityID];
ref var links = ref _storage.links[entityID];
if (links.connect != null)
{
return links.connect;
@ -616,16 +573,15 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
private class Storage : IEcsWorldEventListener
{
public readonly EcsWorld World;
public WorldMonitor WorldMonitor;
public (EcsEntityConnect connect, EntityMonitor monitor)[] Links;
private readonly EcsWorld _world;
public (EcsEntityConnect connect, EntityMonitor monitor)[] links;
public Storage(EcsWorld world)
{
World = world;
World.AddListener(this);
Links = new (EcsEntityConnect, EntityMonitor)[World.Capacity];
_world = world;
_world.AddListener(this);
links = new (EcsEntityConnect, EntityMonitor)[_world.Capacity];
}
public void OnWorldResize(int newSize) { Array.Resize(ref Links, newSize); }
public void OnWorldResize(int newSize) { Array.Resize(ref links, newSize); }
public void OnReleaseDelEntityBuffer(ReadOnlySpan<int> buffer) { }
public void OnWorldDestroy() { }
}
@ -634,7 +590,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
EntityField(position, DragonGUIContent.Empty, entity);
}
public static void EntityField(Rect position, DragonGUIContent label, entlong entity)
public static unsafe void EntityField(Rect position, DragonGUIContent label, entlong entity)
{
EntityField(position, label, (EntitySlotInfo)entity);
}
@ -715,7 +671,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
w.a = 0.6f;
Color b = Color.black;
b.a = 0.55f;
DrawRect(position, w);
DrawRectSoftColor(position, w);
var (idRect, genWorldRect) = RectUtility.HorizontalSliceLerp(position, 0.4f);
var (genRect, worldRect) = RectUtility.HorizontalSliceLerp(genWorldRect, 0.5f);
@ -723,9 +679,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
idRect = RectUtility.AddPadding(idRect, 2, 1, 0, 0);
genRect = RectUtility.AddPadding(genRect, 1, 1, 0, 0);
worldRect = RectUtility.AddPadding(worldRect, 1, 2, 0, 0);
DrawRect(idRect, b);
DrawRect(genRect, b);
DrawRect(worldRect, b);
DrawRectSoftColor(idRect, b);
DrawRectSoftColor(genRect, b);
DrawRectSoftColor(worldRect, b);
GUIStyle style = UnityEditorUtility.GetInputFieldCenterAnhor();
@ -759,24 +715,23 @@ namespace DCFApixels.DragonECS.Unity.Editors
return DrawTypeMetaBlockPadding * 2 + contentHeight;
}
public static (bool skip, float optionsWidth) DrawTypeMetaElementBlock(ref Rect rect, SerializedProperty arrayProperty, int elementIndex, SerializedProperty elementRootProperty, ITypeMeta meta)
public static bool DrawTypeMetaElementBlock(ref Rect rect, SerializedProperty arrayProperty, int elementIndex, SerializedProperty elementRootProperty, ITypeMeta meta)
{
var result = DrawTypeMetaBlock_Internal(ref rect, elementRootProperty, meta, elementIndex, arrayProperty.arraySize);
if (result.flags.HasFlag(DrawTypeMetaBlockResultFlags.CloseButtonClicked))
if (result.HasFlag(DrawTypeMetaBlockResultFlags.CloseButtonClicked))
{
arrayProperty.DeleteArrayElementAtIndex(elementIndex);
}
return (result.flags != DrawTypeMetaBlockResultFlags.None, result.optionsWidth);
return result != DrawTypeMetaBlockResultFlags.None;
}
public static (bool skip, float optionsWidth) DrawTypeMetaBlock(ref Rect rect, SerializedProperty rootProperty, ITypeMeta meta, int index = -1, int total = -1)
public static bool DrawTypeMetaBlock(ref Rect rect, SerializedProperty rootProperty, ITypeMeta meta, int index = -1, int total = -1)
{
var result = DrawTypeMetaBlock_Internal(ref rect, rootProperty, meta, index, total);
if (result.flags.HasFlag(DrawTypeMetaBlockResultFlags.CloseButtonClicked))
if (result.HasFlag(DrawTypeMetaBlockResultFlags.CloseButtonClicked))
{
rootProperty.ResetValues();
rootProperty.DeleteCommand();
}
return (result.flags.HasFlag(DrawTypeMetaBlockResultFlags.DropExpanded), result.optionsWidth);
return result.HasFlag(DrawTypeMetaBlockResultFlags.DropExpanded);
}
[Flags]
@ -786,14 +741,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
DropExpanded = 1 << 0,
CloseButtonClicked = 1 << 1,
}
private static (DrawTypeMetaBlockResultFlags flags, float optionsWidth) DrawTypeMetaBlock_Internal(ref Rect rect, SerializedProperty rootProperty, ITypeMeta meta, int index = -1, int total = -1)
private static DrawTypeMetaBlockResultFlags DrawTypeMetaBlock_Internal(ref Rect rect, SerializedProperty rootProperty, ITypeMeta meta, int index = -1, int total = -1)
{
if (meta == null)
{
EditorGUI.DrawRect(rect, Color.black.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha));
return (DrawTypeMetaBlockResultFlags.None, 0f);
EditorGUI.DrawRect(rect, Color.black.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA));
return DrawTypeMetaBlockResultFlags.None;
}
//string name = meta.Name;
@ -811,36 +766,12 @@ 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)
.Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE)
.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha);
EditorGUI.DrawRect(rect, panelColor);
}
break;
}
}
Color panelColor = SelectPanelColor(meta, positionIndex, total)
.Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE)
.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA);
EditorGUI.DrawRect(rect, panelColor);
float optionsWidth = 0f;
Rect optionRect = rect;
rect = rect.AddPadding(DrawTypeMetaBlockPadding * 2f);
@ -850,37 +781,38 @@ namespace DCFApixels.DragonECS.Unity.Editors
optionRect.xMin = optionRect.xMax - 64;
optionRect.center += Vector2.up * DrawTypeMetaBlockPadding;
DrawTypeMetaBlockResultFlags result = DrawTypeMetaBlockResultFlags.None;
using (CheckChanged())
{
//Canceling isExpanded
bool oldIsExpanded = rootProperty.isExpanded;
if (ClickTest(optionRect))
{
rootProperty.isExpanded = oldIsExpanded;
result |= DrawTypeMetaBlockResultFlags.DropExpanded;
}
//Close button
optionRect.xMin = optionRect.xMax - HeadIconsRect.width;
optionsWidth += optionRect.width;
if (CloseButton(optionRect))
{
result |= DrawTypeMetaBlockResultFlags.CloseButtonClicked;
return (result, optionsWidth);
return result;
}
//Edit script button
if (ScriptsCache.TryGetScriptAsset(meta.FindRootTypeMeta(), out MonoScript script))
{
optionRect = HeadIconsRect.MoveTo(optionRect.center - (Vector2.right * optionRect.width));
optionsWidth += optionRect.width;
ScriptAssetButton(optionRect, script);
}
//Description icon
if (string.IsNullOrEmpty(description) == false)
{
optionRect = HeadIconsRect.MoveTo(optionRect.center - (Vector2.right * optionRect.width));
optionsWidth += optionRect.width;
DescriptionIcon(optionRect, description);
}
}
return (result, optionsWidth);
return result;
}
#endregion
@ -902,14 +834,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
return property.Next(child) && property.depth >= depth;
}
internal static bool IsNullManagedReference(this SerializedProperty property)
{
#if UNITY_2021_3_OR_NEWER
return property.managedReferenceId == ManagedReferenceUtility.RefIdNull;
#else
return property.managedReferenceId == SerializationUtility.RefIdNull;
#endif
}
internal static int GetChildPropertiesCount(this SerializedProperty property, Type type, out bool isEmpty)
{
int result = GetChildPropertiesCount(property);
@ -936,7 +860,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
bool next = propsCounter.Next(true) && lastDepth < propsCounter.depth;
while (next)
{
if (propsCounter.propertyType != SerializedPropertyType.Generic)
if(propsCounter.propertyType != SerializedPropertyType.Generic)
{
return true;
}
@ -961,13 +885,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
else
{
switch (MetaBlockColorMode)
switch (AutoColorMode)
{
case MetaBlockColorMode.Auto:
case ComponentColorMode.Auto:
{
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);
Color hsv = Color.HSVToRGB(1f / localTotal * (index % localTotal), 1, 1);
@ -1054,11 +978,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
#region Init
private static ReferenceDropDown GetReferenceDropDown(Type[] predicatTypes, Type[] sortedWithOutTypes)
{
if (_predicatTypesMenus.TryGetValue(new PredicateTypesKey(predicatTypes[0], predicatTypes, sortedWithOutTypes), out ReferenceDropDown menu) == false)
if (_predicatTypesMenus.TryGetValue((predicatTypes, sortedWithOutTypes), out ReferenceDropDown menu) == false)
{
menu = new ReferenceDropDown(predicatTypes, sortedWithOutTypes);
menu.OnSelected += SelectComponent;
_predicatTypesMenus.Add(new PredicateTypesKey(predicatTypes[0], predicatTypes, sortedWithOutTypes), menu);
_predicatTypesMenus.Add((predicatTypes, sortedWithOutTypes), menu);
}
return menu;

View File

@ -4,16 +4,16 @@ using System.Collections.Generic;
namespace DCFApixels.DragonECS.Unity.Editors
{
internal class ExpandStack
internal class ExpandMatrix
{
private const bool TOP_DEFAULT = true;
private const bool DEFAULT = false;
private static Dictionary<Type, ExpandStack> _instances = new Dictionary<Type, ExpandStack>();
public static ExpandStack Take(Type type)
private static Dictionary<Type, ExpandMatrix> _instances = new Dictionary<Type, ExpandMatrix>();
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);
}
return result;

View File

@ -9,9 +9,11 @@
#if UNITY_EDITOR
namespace DCFApixels.DragonECS.Unity.Editors
{
using DCFApixels.DragonECS.Unity.Internal;
using global::Unity.Collections.LowLevel.Unsafe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
@ -47,10 +49,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
get { return UserSettingsPrefs.instance.IsShowRuntimeComponents; }
set { UserSettingsPrefs.instance.IsShowRuntimeComponents = value; }
}
protected static MetaBlockColorMode ComponentColorMode
protected static ComponentColorMode ComponentColorMode
{
get { return UserSettingsPrefs.instance.MetaBlockColorMode; }
set { UserSettingsPrefs.instance.MetaBlockColorMode = value; }
get { return UserSettingsPrefs.instance.ComponentColorMode; }
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
}
protected bool IsMultipleTargets => targets.Length > 1;
@ -76,7 +78,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
if (AutoChechChanges)
{
using (DragonGUI.CheckChanged(serializedObject))
using (EcsGUI.CheckChanged(serializedObject))
{
StaticInit();
Init();
@ -151,28 +153,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
private IEnumerable<Attribute> _attributes = null;
private Type _propertyType = null;
private bool _isArrayElement;
private SerializedProperty _trackedArrayProperty = null;
private bool? _isArrayElement = null;
protected bool IsArrayElement
{
get
{
return _isArrayElement;
}
}
protected Type PropertyType
{
get
{
return _propertyType;
}
}
protected SerializedProperty TrackedArrayProperty
{
get
{
return _trackedArrayProperty;
if (_isArrayElement == null)
{
_isArrayElement = Attributes.Any(o => o is ArrayElementAttribute);
}
return _isArrayElement.Value;
}
}
@ -210,10 +200,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
get { return UserSettingsPrefs.instance.IsShowRuntimeComponents; }
set { UserSettingsPrefs.instance.IsShowRuntimeComponents = value; }
}
protected static MetaBlockColorMode ComponentColorMode
protected static ComponentColorMode ComponentColorMode
{
get { return UserSettingsPrefs.instance.MetaBlockColorMode; }
set { UserSettingsPrefs.instance.MetaBlockColorMode = value; }
get { return UserSettingsPrefs.instance.ComponentColorMode; }
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
}
protected virtual bool IsStaticInit { get { return _isStaticInit; } }
protected virtual bool IsInit { get { return _isInit; } }
@ -223,52 +213,21 @@ namespace DCFApixels.DragonECS.Unity.Editors
_isStaticInit = true;
OnStaticInit();
}
public void Init(SerializedProperty property)
public void Init()
{
if (IsInit) { return; }
_isInit = true;
_isArrayElement = false;
if (fieldInfo != null)
{
_propertyType = fieldInfo.FieldType;
if (_propertyType.IsArray)
{
_propertyType = _propertyType.GetElementType();
_isArrayElement = true;
}
if (_propertyType.IsGenericType && _propertyType.GetGenericTypeDefinition() == typeof(List<>))
{
_propertyType = _propertyType.GetGenericArguments()[0];
_isArrayElement = true;
}
}
OnInit(property);
OnInit();
}
protected virtual void OnStaticInit() { }
protected virtual void OnInit(SerializedProperty property) { }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
_trackedArrayProperty = DragonGUI.CurrentTrackedArrayProperty;
using (new DragonGUI.TrackArrayPropertyScope(null))
{
StaticInit();
Init(property);
return GetCustomHeight(property, label);
}
}
protected abstract float GetCustomHeight(SerializedProperty property, GUIContent label);
protected virtual void OnInit() { }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_trackedArrayProperty = DragonGUI.CurrentTrackedArrayProperty;
using (new DragonGUI.TrackArrayPropertyScope(null)) using (DragonGUI.CheckChanged(property.serializedObject))
using (EcsGUI.CheckChanged(property.serializedObject))
{
StaticInit();
Init(property);
Init();
DrawCustom(position, property, label);
}
}

View File

@ -1,253 +1,15 @@
#if UNITY_EDITOR
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.RunnersCore;
using DCFApixels.DragonECS.Unity.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
namespace DCFApixels.DragonECS.Unity.Editors
{
internal class DragonFieldDropDown : MetaObjectsDropDown<DragonFieldCahce>
{
private DragonFieldDropDown() { }
private bool _isCheckUnique;
private SerializedProperty _arrayProperty;
private SerializedProperty _fieldProperty;
public static Dictionary<PredicateTypesKey, DragonFieldDropDown> _dropDownsCache = new Dictionary<PredicateTypesKey, DragonFieldDropDown>(32);
public static DragonFieldDropDown Get(PredicateTypesKey key)
{
if (_dropDownsCache.TryGetValue(key, out var result) == false)
{
result = new DragonFieldDropDown();
IEnumerable<(DragonFieldCahce template, ITypeMeta meta)> itemMetaPairs = DragonFieldCahce.All.ToArray()
.Where(o =>
{
return key.Check(o);
})
.Select(o =>
{
var info = DragonFieldCahce.GetInfoFor(o);
return (info, (ITypeMeta)info.Meta);
});
//TODO оптимизировать или вырезать
itemMetaPairs = itemMetaPairs.OrderBy(o => o.meta.Group.Name);
result.Setup(itemMetaPairs);
_dropDownsCache[key] = result;
}
return result;
}
public void OpenForArray(Rect position, SerializedProperty arrayProperty, bool isCheckUnique)
{
_isCheckUnique = isCheckUnique;
_arrayProperty = arrayProperty;
_fieldProperty = null;
Show(position);
}
public void OpenForField(Rect position, SerializedProperty fieldProperty)
{
_isCheckUnique = false;
_arrayProperty = null;
_fieldProperty = fieldProperty;
Show(position);
}
protected override void ItemSelected(Item item)
{
if (item.Obj == null)
{
_fieldProperty.managedReferenceValue = null;
_fieldProperty.serializedObject.ApplyModifiedProperties();
return;
}
Type componentType = item.Obj.GetType();
var data = item.Obj;
if (_arrayProperty != null && data != null)
{
int index = _arrayProperty.arraySize;
if (_isCheckUnique)
{
if (data.IsUnique)
{
for (int i = 0, iMax = _arrayProperty.arraySize; i < iMax; i++)
{
if (_arrayProperty.GetArrayElementAtIndex(i).managedReferenceValue.GetType() == componentType)
{
return;
}
}
}
}
_arrayProperty.arraySize += 1;
_fieldProperty = _arrayProperty.GetArrayElementAtIndex(index);
}
if (_fieldProperty != null)
{
_fieldProperty.managedReferenceValue = data.CreateInstance();
_fieldProperty.serializedObject.ApplyModifiedProperties();
}
//Event.current.Use();
}
}
internal class DragonFieldCahce : ITypeMeta
{
Type ITypeMeta.Type => Meta.Type;
string ITypeMeta.Name => Meta.Name;
MetaColor ITypeMeta.Color => Meta.Color;
MetaDescription ITypeMeta.Description => Meta.Description;
MetaGroup ITypeMeta.Group => Meta.Group;
IReadOnlyList<string> ITypeMeta.Tags => Meta.Tags;
ITypeMeta ITypeMeta.BaseMeta => Meta;
internal static Type[] All => UnityEditorUtility._serializableTypes;
internal static HashSet<Type> AllDict;
internal static Dictionary<Type, DragonFieldCahce> RuntimeDict;
static DragonFieldCahce() { StaticInit(); }
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void StaticInit()
{
AllDict = new HashSet<Type>(All);
RuntimeDict = new Dictionary<Type, DragonFieldCahce>();
}
public static DragonFieldCahce GetInfoFor(Type type)
{
if (RuntimeDict.TryGetValue(type, out var info))
{
return info;
}
if (AllDict.Contains(type))
{
info = new DragonFieldCahce(type);
RuntimeDict.Add(type, info);
return info;
}
return null;
}
public static bool TryGetInfoFor(Type type, out DragonFieldCahce info)
{
if (RuntimeDict.TryGetValue(type, out info))
{
return true;
}
if (AllDict.Contains(type))
{
info = new DragonFieldCahce(type);
RuntimeDict.Add(type, info);
return true;
}
info = null;
return false;
}
public readonly Type Type;
public readonly Type ComponentType;
public readonly string WrappedFieldName;
public bool HasWrappedFieldName
{
get { return string.IsNullOrEmpty(WrappedFieldName) == false; }
}
public readonly bool IsUnique;
private TypeMeta _meta;
public TypeMeta Meta
{
get
{
if (_meta == null)
{
_meta = Type.GetMeta();
}
return _meta;
}
}
private bool _defaultValueTypeInit = false;
private object _defaultValueDummy;
public object DefaultValue
{
get
{
if (_defaultValueTypeInit == false)
{
if (Type.IsValueType)
{
FieldInfo field;
field = Type.GetField("Default", BindingFlags.Static | BindingFlags.Public);
if (field != null && field.FieldType == Type)
{
_defaultValueDummy = field.GetValue(null).Clone_Reflection();
}
if (_defaultValueDummy == null)
{
field = Type.GetField("Empty", BindingFlags.Static | BindingFlags.Public);
if (field != null && field.FieldType == Type)
{
_defaultValueDummy = field.GetValue(null).Clone_Reflection();
}
}
}
_defaultValueTypeInit = true;
}
return _defaultValueDummy;
}
}
public DragonFieldCahce(Type type)
{
Type = type;
IsUnique = false;
if(type.TryGetAttribute<DragonMemberWrapperAttribute>(out var atr))
{
WrappedFieldName = atr.WrappedFieldName;
var field = type.GetField(atr.WrappedFieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null && field.FieldType.IsConcreteType())
{
ComponentType = field.FieldType;
}
}
if (type.GetInterfaces().Contains(typeof(IComponentTemplate)))
{
var ct = (IComponentTemplate)Activator.CreateInstance(type);
IsUnique = ct.IsUnique;
ComponentType = ct.ComponentType;
}
if(ComponentType == null)
{
ComponentType = Type;
}
}
public object CreateInstance()
{
if (DefaultValue != null)
{
return DefaultValue.Clone_Reflection();
}
return Activator.CreateInstance(Type);
}
public override string ToString()
{
return Type.ToString();
}
}
internal class SystemsDropDown : MetaObjectsDropDown<Type>
{
public SystemsDropDown()
@ -320,11 +82,97 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
_fieldProperty.serializedObject.ApplyModifiedProperties();
DragonGUI.DelayedChanged = true;
EcsGUI.DelayedChanged = true;
}
}
}
internal class ComponentTemplatesDropDown : MetaObjectsDropDown<ComponentTemplateTypeCache>
{
private ComponentTemplatesDropDown() { }
private bool _isCheckUnique;
private SerializedProperty _arrayProperty;
private SerializedProperty _fieldProperty;
public static Dictionary<PredicateTypesKey, ComponentTemplatesDropDown> _dropDownsCache = new Dictionary<PredicateTypesKey, ComponentTemplatesDropDown>(32);
public static ComponentTemplatesDropDown Get(PredicateTypesKey key)
{
if(_dropDownsCache.TryGetValue(key, out var result) == false)
{
result = new ComponentTemplatesDropDown();
IEnumerable<(ComponentTemplateTypeCache template, ITypeMeta meta)> itemMetaPairs = ComponentTemplateTypeCache.All.ToArray()
.Where(o =>
{
return key.Check(o.Type);
})
.Select(o =>
{
return (o, o.Meta);
});
//TODO оптимизировать или вырезать
itemMetaPairs = itemMetaPairs.OrderBy(o => o.meta.Group.Name);
result.Setup(itemMetaPairs);
_dropDownsCache[key] = result;
}
return result;
}
public void OpenForArray(Rect position, SerializedProperty arrayProperty, bool isCheckUnique)
{
_isCheckUnique = isCheckUnique;
_arrayProperty = arrayProperty;
_fieldProperty = null;
Show(position);
}
public void OpenForField(Rect position, SerializedProperty fieldProperty)
{
_isCheckUnique = false;
_arrayProperty = null;
_fieldProperty = fieldProperty;
Show(position);
}
protected override void ItemSelected(Item item)
{
base.ItemSelected(item);
if (item.Obj == null)
{
_fieldProperty.managedReferenceValue = null;
_fieldProperty.serializedObject.ApplyModifiedProperties();
return;
}
Type componentType = item.Obj.GetType();
var data = item.Obj;
if (_arrayProperty != null && data != null)
{
int index = _arrayProperty.arraySize;
if (_isCheckUnique)
{
if (data.IsUnique)
{
for (int i = 0, iMax = _arrayProperty.arraySize; i < iMax; i++)
{
if (_arrayProperty.GetArrayElementAtIndex(i).managedReferenceValue.GetType() == componentType)
{
return;
}
}
}
}
_arrayProperty.arraySize += 1;
_fieldProperty = _arrayProperty.GetArrayElementAtIndex(index);
}
if (_fieldProperty != null)
{
_fieldProperty.managedReferenceValue = data.CreateInstance();
_fieldProperty.serializedObject.ApplyModifiedProperties();
}
}
}
internal class RuntimeComponentsDropDown : MetaObjectsDropDown<IEcsPool>
{
public RuntimeComponentsDropDown(IEnumerable<IEcsPool> pools)
@ -367,7 +215,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
private bool _isContainsNull;
public IEnumerable<(T, ITypeMeta)> _itemMetaPairs;
public virtual bool IsStaticList { get { return true; } }
public MetaObjectsDropDown() : base(new AdvancedDropdownState())
{
minimumSize = new Vector2(220f, EditorGUIUtility.singleLineHeight * 20);
@ -378,10 +225,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
_name = name;
_isContainsNull = isContainsNull;
_itemMetaPairs = itemMetaPairs;
if (IsStaticList)
{
_itemMetaPairs = _itemMetaPairs.ToArray();
}
}
protected override AdvancedDropdownItem BuildRoot()
{
@ -392,9 +235,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
root.AddChild(new Item(default, "<NULL>", increment++));
}
Dictionary<Key, Item> dict = new Dictionary<Key, Item>();
var list = _itemMetaPairs.ToArray();
foreach (var pair in _itemMetaPairs)
{
ITypeMeta meta = pair.Item2;
@ -480,7 +324,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
return true;
}
public override bool Equals(object obj) { return obj is Key key && Equals(key); }
public override bool Equals(object obj)
{
return obj is Key key && Equals(key);
}
public override int GetHashCode()
{
unchecked

View File

@ -1,5 +1,4 @@
#if UNITY_EDITOR
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Unity.Internal;
using System;
using System.Collections.Generic;
@ -45,10 +44,10 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
#region Properties
private static RuntimeDrawMode RuntimeDrawMode
private static ComponentColorMode AutoColorMode
{
get { return UserSettingsPrefs.instance.RuntimeDrawMode; }
set { UserSettingsPrefs.instance.RuntimeDrawMode = value; }
get { return UserSettingsPrefs.instance.ComponentColorMode; }
set { UserSettingsPrefs.instance.ComponentColorMode = value; }
}
private static bool IsShowHidden
{
@ -66,7 +65,6 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
internal class RuntimeComponentReflectionCache
{
public readonly Type Type;
public readonly bool IsValueType;
public readonly bool IsUnmanaged;
public readonly DrawerType DrawerType;
public readonly FieldInfoData[] Fields;
@ -76,12 +74,12 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
{
return _wrappers[depth];
}
public RuntimeComponentReflectionCache(Type type)
{
Type = type;
ResetWrappers();
IsUnmanaged = UnsafeUtility.IsUnmanaged(type);
IsValueType = type.IsValueType;
bool isVoideType = type == typeof(void);
bool isUnityObjectType = typeof(UnityObject).IsAssignableFrom(type);
@ -248,7 +246,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
{
bool isNull = world == null || world.IsDestroyed || world.ID == 0;
if (isNull) { return; }
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{
IsShowRuntimeComponents = EditorGUILayout.BeginFoldoutHeaderGroup(IsShowRuntimeComponents, "RUNTIME COMPONENTS", EditorStyles.foldout);
EditorGUILayout.EndFoldoutHeaderGroup();
@ -268,40 +266,41 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
object data = cmp.GetRaw(worldID);
ExpandStack expandStack = ExpandStack.Take(componentType);
ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType);
float padding = EditorGUIUtility.standardVerticalSpacing;
Rect optionButton = GUILayoutUtility.GetLastRect();
optionButton.yMin = optionButton.yMax;
optionButton.yMax += DragonGUI.HeadIconsRect.height;
optionButton.yMax += EcsGUI.HeadIconsRect.height;
optionButton.xMin = optionButton.xMax - 64;
optionButton.center += Vector2.up * padding * 2f;
//Canceling isExpanded
if (DragonGUI.ClickTest(optionButton))
if (EcsGUI.ClickTest(optionButton))
{
ref bool isExpanded = ref expandStack.Down();
ref bool isExpanded = ref expandMatrix.Down();
isExpanded = !isExpanded;
}
Color panelColor = DragonGUI.SelectPanelColor(meta, index, total);
using (DragonGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.MetaBlockFillStyle_Alpha)))
Color panelColor = EcsGUI.SelectPanelColor(meta, index, total);
using (EcsGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA)))
{
EditorGUI.BeginChangeCheck();
//Edit script button
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
{
optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
DragonGUI.ScriptAssetButton(optionButton, script);
optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
EcsGUI.ScriptAssetButton(optionButton, script);
}
//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);
optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
EcsGUI.DescriptionIcon(optionButton, meta.Description.Text);
}
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);
}
@ -337,7 +336,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
}
private void DrawRuntimeComponents(int entityID, EcsWorld world, bool isWithFoldout)
{
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (DragonGUI.SetIndentLevel(0))
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (EcsGUI.SetIndentLevel(0))
{
if (_runtimeComponentsDepth >= RuntimeComponentsMaxDepth)
{
@ -351,244 +350,81 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
}
if (isWithFoldout == false || IsShowRuntimeComponents)
{
if (DragonGUI.Layout.AddComponentButtons(out Rect dropDownRect))
if (EcsGUI.Layout.AddComponentButtons(out Rect dropDownRect))
{
RuntimeComponentsUtility.GetAddComponentGenericMenu(world).Open(dropDownRect, entityID);
}
using (DragonGUI.Layout.BeginVertical(Color.white.SetAlpha(0.066f)))
using (EcsGUI.SetBackgroundColor(GUI.color.SetAlpha(0.16f)))
{
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden);
RuntimeDrawMode = (RuntimeDrawMode)EditorGUILayout.EnumPopup("Draw Mode", selected: RuntimeDrawMode);
GUILayout.Box("", UnityEditorUtility.GetWhiteStyle(), GUILayout.ExpandWidth(true));
}
IsShowHidden = EditorGUI.Toggle(GUILayoutUtility.GetLastRect(), "Show Hidden", IsShowHidden);
world.GetComponentPoolsFor(entityID, _componentPoolsBuffer);
for (int i = 0; i < _componentPoolsBuffer.Count; i++)
{
var pool = _componentPoolsBuffer[i];
if (pool.ComponentType.IsValueType)
{
DrawRuntimeValueComponent(entityID, pool, 9, i);
}
else
{
DrawRuntimeClassComponent(entityID, pool, 9, i);
}
DrawRuntimeComponent(entityID, _componentPoolsBuffer[i], 9, i);
}
}
}
}
private struct DrawRuntimeCompoentnsCahce : IEcsWorldComponent<DrawRuntimeCompoentnsCahce>
private void DrawRuntimeComponent(int entityID, IEcsPool pool, int total, int index)
{
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;
var meta = pool.ComponentType.GetMeta();
if (meta.IsHidden == false || IsShowHidden)
{
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;
Type componentType = pool.ComponentType;
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;
}
}
object data = pool.GetRaw(entityID);
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);
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);
ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType);
float padding = EditorGUIUtility.standardVerticalSpacing;
Rect optionButton = GUILayoutUtility.GetLastRect();
optionButton.yMin = optionButton.yMax;
optionButton.yMax += DragonGUI.HeadIconsRect.height;
optionButton.yMax += EcsGUI.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)
//Canceling isExpanded
if (EcsGUI.ClickTest(optionButton))
{
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;
}
ref bool isExpanded = ref expandMatrix.Down();
isExpanded = !isExpanded;
}
Color panelColor = EcsGUI.SelectPanelColor(meta, index, total);
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetWhiteStyle(), backColor))
using (EcsGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA)))
{
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetWhiteEdge4Style(), fillColor))
EditorGUI.BeginChangeCheck();
//Close button
optionButton.xMin = optionButton.xMax - EcsGUI.HeadIconsRect.width;
if (EcsGUI.CloseButton(optionButton))
{
//Close button
optionButton.xMin = optionButton.xMax - DragonGUI.HeadIconsRect.width;
if (DragonGUI.CloseButton(optionButton))
{
pool.Del(entityID);
return;
}
//Edit script button
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
{
optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
DragonGUI.ScriptAssetButton(optionButton, script);
}
//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);
}
pool.Del(entityID);
return;
}
//Edit script button
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
{
optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
EcsGUI.ScriptAssetButton(optionButton, script);
}
//Description icon
if (string.IsNullOrEmpty(meta.Description.Text) == false)
{
optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
EcsGUI.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))
{
pool.SetRaw(entityID, resultData);
}
if (DrawRuntimeData(ref componentInfoData, UnityEditorUtility.GetLabel(meta.Name), expandMatrix, data, out object resultData, 0))
{
pool.SetRaw(entityID, resultData);
}
}
}
@ -598,12 +434,13 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
#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;
using (DragonGUI.CheckChanged())
using (EcsGUI.CheckChanged())
{
outData = data;
object newData = data;
Type type = data == null ? typeof(void) : data.GetType();
@ -614,19 +451,19 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
return false;
}
var reflectionCache = fieldInfoData.GetReflectionCache(type);
if (depth >= DEPTH_MAX || reflectionCache == null)
RuntimeComponentReflectionCache cache = fieldInfoData.GetReflectionCache(type);
if (depth >= DEPTH_MAX || cache == null)
{
EditorGUILayout.TextField(label, "error");
return false;
}
ref bool isExpanded = ref expandStack.Down();
ref bool isExpanded = ref expandMatrix.Down();
bool childElementChanged = false;
var eventType = Event.current.type;
var label2 = "-";
var drawerType = reflectionCache.DrawerType;
var drawerType = cache.DrawerType;
if (isUnityObjectField)
{
@ -635,261 +472,231 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
switch (drawerType)
{
case DrawerType.UNDEFINED:
{
EditorGUILayout.LabelField(label, label2);
}
EditorGUILayout.LabelField(label, label2);
break;
case DrawerType.Ignored:
{
EditorGUILayout.LabelField(label, label2);
}
EditorGUILayout.LabelField(label, label2);
break;
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)
{
wrapper.SO.ApplyModifiedProperties();
newData = wrapper.Data;
childElementChanged = true;
}
isExpanded = wrapper.IsExpanded;
using (EcsGUI.CheckChanged())
{
RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth);
wrapper.data = data;
wrapper.SO.Update();
wrapper.IsExpanded = isExpanded;
EditorGUILayout.PropertyField(wrapper.Property, label, true);
if (EcsGUI.Changed)
{
wrapper.SO.ApplyModifiedProperties();
newData = wrapper.Data;
childElementChanged = true;
}
isExpanded = wrapper.IsExpanded;
}
break;
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(EcsGUI.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 (EcsGUI.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];
if (DrawRuntimeData(ref field, UnityEditorUtility.GetLabel(field.UnityFormatName), expandStack, field.FieldInfo.GetValue(data), out object fieldData, depth + 1))
{
field.FieldInfo.SetValue(data, fieldData);
newData = data;
childElementChanged = true;
}
field.FieldInfo.SetValue(data, fieldData);
newData = data;
childElementChanged = true;
}
}
}
}
break;
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 (EcsGUI.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);
}
newData = newuobj;
childElementChanged = true;
newuobj = go.GetComponent(fieldInfoData.FieldType);
}
newData = newuobj;
childElementChanged = true;
}
}
break;
case DrawerType.Enum:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
var enumData = UnsafeUtility.As<object, Enum>(ref data);
newData = EditorGUILayout.EnumPopup(label, enumData);
}
else
{
EditorGUILayout.EnumPopup(label, default);
}
var enumData = UnsafeUtility.As<object, Enum>(ref data);
newData = EditorGUILayout.EnumPopup(label, enumData);
}
else
{
EditorGUILayout.EnumPopup(label, default);
}
break;
case DrawerType.EnumFlags:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
var enumData = UnsafeUtility.As<object, Enum>(ref data);
newData = EditorGUILayout.EnumFlagsField(label, enumData);
}
else
{
EditorGUILayout.EnumFlagsField(label, default);
}
var enumData = UnsafeUtility.As<object, Enum>(ref data);
newData = EditorGUILayout.EnumFlagsField(label, enumData);
}
else
{
EditorGUILayout.EnumFlagsField(label, default);
}
break;
case DrawerType.Bool:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = EditorGUILayout.Toggle(label, (bool)data);
}
else
{
EditorGUILayout.Toggle(label, default);
}
newData = EditorGUILayout.Toggle(label, (bool)data);
}
else
{
EditorGUILayout.Toggle(label, default);
}
break;
case DrawerType.String:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = EditorGUILayout.TextField(label, (string)data);
}
else
{
EditorGUILayout.TextField(label, default);
}
newData = EditorGUILayout.TextField(label, (string)data);
}
else
{
EditorGUILayout.TextField(label, default);
}
break;
case DrawerType.Float:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = EditorGUILayout.FloatField(label, (float)data);
}
else
{
EditorGUILayout.FloatField(label, default);
}
newData = EditorGUILayout.FloatField(label, (float)data);
}
else
{
EditorGUILayout.FloatField(label, default);
}
break;
case DrawerType.Double:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = EditorGUILayout.DoubleField(label, (double)data);
}
else
{
EditorGUILayout.DoubleField(label, default);
}
newData = EditorGUILayout.DoubleField(label, (double)data);
}
else
{
EditorGUILayout.DoubleField(label, default);
}
break;
case DrawerType.Byte:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = (byte)EditorGUILayout.IntField(label, (byte)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
newData = (byte)EditorGUILayout.IntField(label, (byte)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
break;
case DrawerType.SByte:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = (sbyte)EditorGUILayout.IntField(label, (sbyte)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
newData = (sbyte)EditorGUILayout.IntField(label, (sbyte)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
break;
case DrawerType.Short:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = (short)EditorGUILayout.IntField(label, (short)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
newData = (short)EditorGUILayout.IntField(label, (short)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
break;
case DrawerType.UShort:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = (ushort)EditorGUILayout.IntField(label, (ushort)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
newData = (ushort)EditorGUILayout.IntField(label, (ushort)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
break;
case DrawerType.Int:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = (int)EditorGUILayout.IntField(label, (int)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
newData = (int)EditorGUILayout.IntField(label, (int)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
break;
case DrawerType.UInt:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = (uint)EditorGUILayout.IntField(label, (int)(uint)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
newData = (uint)EditorGUILayout.IntField(label, (int)(uint)data);
}
else
{
EditorGUILayout.IntField(label, default);
}
break;
case DrawerType.Long:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = EditorGUILayout.LongField(label, (long)data);
}
else
{
EditorGUILayout.LongField(label, default);
}
newData = EditorGUILayout.LongField(label, (long)data);
}
else
{
EditorGUILayout.LongField(label, default);
}
break;
case DrawerType.ULong:
if (eventType != EventType.Layout)
{
if (eventType != EventType.Layout)
{
newData = (ulong)EditorGUILayout.LongField(label, (long)(ulong)data);
}
else
{
EditorGUILayout.LongField(label, default);
}
newData = (ulong)EditorGUILayout.LongField(label, (long)(ulong)data);
}
else
{
EditorGUILayout.LongField(label, default);
}
break;
default:
{
EditorGUILayout.LabelField(label, label2);
}
EditorGUILayout.LabelField(label, label2);
break;
}
expandStack.Up();
if (childElementChanged || DragonGUI.Changed)
expandMatrix.Up();
if (childElementChanged || EcsGUI.Changed)
{
outData = newData;
return true;
@ -898,6 +705,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
return false;
}
#endregion
public enum DrawerType
{
@ -923,7 +731,6 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
Long,
ULong,
}
#endregion
}
}
#endif

View File

@ -457,11 +457,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
#region GetDefaultStyle
private static Texture2D _whiteTexture;
private static GUIStyle _whiteStyleWithPadding;
private static GUIStyle _whiteStyle;
private static GUIStyle _whiteEdgeStyle;
private static GUIStyle _transperentBlackBackgrounStyle;
private static GUIStyle _clearBackgrounStyle;
public static Texture2D GetWhiteTexture()
@ -474,34 +470,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
private static bool IsNotInitializedStyle(GUIStyle style)
{
//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()
{
if (IsNotInitializedStyle(_whiteStyle))
{
_whiteStyle = CreateStyle(GetWhiteTexture());
_whiteStyle.padding = new RectOffset(0,0,0,0);
_whiteStyle = CreateStyle(GetWhiteTexture(), GUI.skin.label);
}
return _whiteStyle;
}
public static GUIStyle GetWhiteEdge4Style()
{
if (IsNotInitializedStyle(_whiteEdgeStyle))
{
_whiteEdgeStyle = CreateEdge4Style();
}
return _whiteEdgeStyle;
}
public static GUIStyle GetTransperentBlackBackgrounStyle()
{
if (IsNotInitializedStyle(_transperentBlackBackgrounStyle))
@ -527,7 +505,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
referenceStyle = GUI.skin.box;
}
GUIStyle result = new GUIStyle(referenceStyle);
GUIStyle result = new GUIStyle(GUI.skin.box);
Texture2D texture2D = texture;
result.hover.background = texture2D;
result.hover.scaledBackgrounds = Array.Empty<Texture2D>();
@ -539,57 +517,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
result.normal.scaledBackgrounds = Array.Empty<Texture2D>();
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)
{
var pixels = new Color[width * height];

View File

@ -2,9 +2,7 @@
{
internal static class EscEditorConsts
{
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_ALPHA = 0.26f;
public const float COMPONENT_DRAWER_DESATURATE = 0.86f;
public const int AUTO_COLOR_RAINBOW_MIN_RANGE = 7;
}

View File

@ -3,11 +3,11 @@ guid: 8f9fb2a8877577940971d81a98aeaaaa
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: d01e651682f48b548b597714f47e14b9
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: 8a708e50662813d4a99c107e6431a60b
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: 6a1d402595b00c24db2ba647fed93a5c
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: c67e8a1d6cb0e904590c7847368fe794
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,7 +7,7 @@ TextureImporter:
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -67,11 +67,11 @@ TextureImporter:
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
@ -80,7 +80,7 @@ TextureImporter:
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
@ -93,7 +93,7 @@ TextureImporter:
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
- serializedVersion: 4
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
@ -106,7 +106,7 @@ TextureImporter:
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
@ -123,6 +123,7 @@ TextureImporter:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
@ -132,6 +133,8 @@ TextureImporter:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0

View File

@ -3,11 +3,11 @@ guid: e135cf23a5d53ce48a75e163b41e39d5
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,7 +7,7 @@ TextureImporter:
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -67,11 +67,11 @@ TextureImporter:
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
@ -80,7 +80,7 @@ TextureImporter:
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
@ -93,7 +93,7 @@ TextureImporter:
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
@ -110,6 +110,7 @@ TextureImporter:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
@ -119,6 +120,8 @@ TextureImporter:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0

View File

@ -3,11 +3,11 @@ guid: ebb82b09315bde749a10dfa45e64067c
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: 5476d6e1435981e4cbc915a080f93ee6
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: d3c6215cfdc36cb448661398160560a7
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: 0df5856dbbe53494aae23b959ca05ecc
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: 561fcfb28d73d7c4f8c9fac36e8ece86
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
maxTextureSize: 32
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: 239e73d04c7ba4649bc4cc10e70e62e5
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: 5baead89a941e034e9f44d63617d3246
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: 1f25a5ca611092642a8ee4e08fafcd43
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: 9ce9d719a106be04fa4cf0c369c61e1c
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,11 +3,11 @@ guid: 223d96e24d4b49f468b628cf9839584c
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
@ -20,12 +20,11 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -64,20 +63,17 @@ TextureImporter:
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 4
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -90,7 +86,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
@ -103,7 +98,6 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
@ -120,8 +114,9 @@ TextureImporter:
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,117 @@
using System;
namespace DCFApixels.DragonECS.Unity.Editors
{
internal interface IReferenceButtonAttribute
{
Type[] PredicateTypes { get; }
bool IsHideButtonIfNotNull { get; }
}
}
#if UNITY_EDITOR
namespace DCFApixels.DragonECS.Unity.Internal
{
using DCFApixels.DragonECS.Unity.Editors;
using UnityEditor;
internal partial class UnityReflectionCache
{
public bool IsReferenceButtonCacheInit_Editor;
public bool InitReferenceButtonCache_Editor(SerializedProperty sp)
{
if (IsReferenceButtonCacheInit_Editor) { return false; }
HasSerializableData_Editor = sp.HasSerializableData();
IsReferenceButtonCacheInit_Editor = true;
return true;
}
public bool HasSerializableData_Editor;
}
}
namespace DCFApixels.DragonECS.Unity.Editors
{
using DCFApixels.DragonECS.Unity.Internal;
using System;
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(ReferenceButtonAttribute), true)]
internal sealed class ReferenceButtonAttributeDrawer : ExtendedPropertyDrawer<IReferenceButtonAttribute>
{
private Type[] _withOutTypes;
protected override void OnInit()
{
Type fieldType = fieldInfo.FieldType;
_withOutTypes = fieldType.TryGetAttribute(out ReferenceButtonWithOutAttribute a) ? a.PredicateTypes : Array.Empty<Type>();
//if (fieldType.IsGenericType)
//{
// if (fieldType.IsGenericTypeDefinition == false)
// {
// fieldType = fieldType.GetGenericTypeDefinition();
// }
//}
}
private UnityReflectionCache _reflectionCache;
private UnityReflectionCache Cahce(SerializedProperty sp)
{
if (UnityReflectionCache.InitLocal(sp.managedReferenceValue.GetType(), ref _reflectionCache))
{
_reflectionCache.InitReferenceButtonCache_Editor(sp);
}
return _reflectionCache;
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
Init();
if (property.propertyType == SerializedPropertyType.ManagedReference &&
property.managedReferenceValue != null &&
Cahce(property).HasSerializableData_Editor)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
else
{
return OneLineHeight;
}
}
protected override void DrawCustom(Rect position, SerializedProperty property, GUIContent label)
{
if(property.propertyType != SerializedPropertyType.ManagedReference)
{
GUI.Label(position, label);
return;
}
if (IsArrayElement)
{
label = UnityEditorUtility.GetLabelTemp();
}
Rect selButtnoRect = position;
selButtnoRect.height = OneLineHeight;
DrawSelectionPopupButton(selButtnoRect, property);
if (property.managedReferenceValue != null &&
Cahce(property).HasSerializableData_Editor)
{
EditorGUI.PropertyField(position, property, label, true);
}
else
{
EditorGUI.BeginProperty(position, label, property);
EditorGUI.LabelField(position, label);
EditorGUI.EndProperty();
}
}
private void DrawSelectionPopupButton(Rect position, SerializedProperty property)
{
Rect buttonRect = IsArrayElement ? position : position.AddPadding(EditorGUIUtility.labelWidth, 0f, 0f, 0f); ;
EcsGUI.DrawSelectReferenceButton(buttonRect, property, Attribute.PredicateTypes.Length == 0 ? new Type[1] { fieldInfo.FieldType } : Attribute.PredicateTypes, _withOutTypes, Attribute.IsHideButtonIfNotNull);
}
}
}
#endif

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 09884db6f09e654498c72416a199e357
guid: 69a86e40de1b68a448f49be1e83a1ed5
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -105,6 +105,10 @@ namespace DCFApixels.DragonECS.Unity.Internal
}
return _memberwiseCloneMethdo.Invoke(obj, null);
}
internal static object Clone_Reflection<T>(this T obj)
{
return Clone_Reflection((object)obj);
}
}
internal partial class UnityReflectionCache

View File

@ -351,7 +351,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
if (string.IsNullOrEmpty(item.scriptPath) == false)
{
_metaIDScriptPathPairs[item.metaID] = item.scriptPath;
_metaIDScriptPathPairs.Add(item.metaID, item.scriptPath);
}
}
}

View File

@ -1,30 +1,24 @@
using System;
using UnityEngine;
namespace DCFApixels.DragonECS.Unity.Internal
{
internal readonly struct PredicateTypesKey : IEquatable<PredicateTypesKey>
{
public readonly Type TargetType;
public readonly Type[] AllowTypes;
public readonly Type[] Types;
public readonly Type[] WithoutTypes;
public PredicateTypesKey(Type signleType) : this(signleType, new Type[] { signleType } , Type.EmptyTypes) { }
public PredicateTypesKey(Type targetType, Type[] types) : this(targetType, types, Type.EmptyTypes) { }
public PredicateTypesKey(Type targetType, Type[] types, Type[] withoutTypes)
public PredicateTypesKey(Type[] types) : this(types, Type.EmptyTypes) { }
public PredicateTypesKey(Type[] types, Type[] withoutTypes)
{
if(targetType == null)
{
Throw.ArgumentNullException();
}
TargetType = targetType;
AllowTypes = types;
Types = types;
WithoutTypes = withoutTypes;
}
public bool Check(Type type)
{
bool isAssignable = AllowTypes.Length == 0;
foreach (Type allowType in AllowTypes)
bool isAssignable = false;
foreach (Type predicateTypes in Types)
{
if (allowType.IsAssignableFrom(type))
if (predicateTypes.IsAssignableFrom(type))
{
isAssignable = true;
break;
@ -43,20 +37,15 @@ namespace DCFApixels.DragonECS.Unity.Internal
}
}
return isAssignable && TargetType.IsAssignableFrom(type);
return isAssignable;
}
public bool Equals(PredicateTypesKey other)
{
if (AllowTypes.Length != other.AllowTypes.Length) { return false; }
if (Types.Length != other.Types.Length) { return false; }
if (WithoutTypes.Length != other.WithoutTypes.Length) { return false; }
if (TargetType != other.TargetType)
for (int i = 0; i < Types.Length; i++)
{
return false;
}
for (int i = 0; i < AllowTypes.Length; i++)
{
if (AllowTypes[i] != other.AllowTypes[i])
if (Types[i] != other.Types[i])
{
return false;
}
@ -76,7 +65,8 @@ namespace DCFApixels.DragonECS.Unity.Internal
}
public override int GetHashCode()
{
return HashCode.Combine(TargetType, AllowTypes, WithoutTypes);
return HashCode.Combine(Types, WithoutTypes);
}
public static implicit operator PredicateTypesKey((Type[], Type[]) types) { return new PredicateTypesKey(types.Item1, types.Item2); }
}
}

View File

@ -6,12 +6,6 @@ namespace DCFApixels.DragonECS.Unity.Internal
{
internal static class RectUtility
{
public static Rect AddOffset(in this Rect rect, Vector2 offset)
{
var r = rect;
r.position += offset;
return r;
}
public static (Rect, Rect) HorizontalSliceLerp(in this Rect rect, float t)
{
Rect l = rect;
@ -28,12 +22,6 @@ namespace DCFApixels.DragonECS.Unity.Internal
r.xMin += with;
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)
{
Rect l = rect;

View File

@ -8,10 +8,6 @@ namespace DCFApixels.DragonECS.Unity.Internal
{
throw new ArgumentOutOfRangeException();
}
internal static void ArgumentNullException()
{
throw new ArgumentNullException();
}
internal static void Argument(string message)
{
throw new ArgumentException(message);

View File

@ -1,7 +1,7 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Unity;
using DCFApixels.DragonECS.Unity.Editors;
using System;
using System.Runtime.CompilerServices;
using UnityEngine;
@ -12,10 +12,7 @@ namespace DCFApixels.DragonECS
public struct ComponentTemplateProperty : IEquatable<ComponentTemplateProperty>
{
[SerializeReference]
[ReferenceDropDown]
[DragonMetaBlock]
private ITemplateNode _template;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ComponentTemplateProperty(ITemplateNode template)
{
@ -31,7 +28,7 @@ namespace DCFApixels.DragonECS
public Type Type
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return _template is IComponentTemplate tml ? tml.ComponentType : _template.GetType(); }
get { return _template is IComponentTemplate tml ? tml.Type : _template.GetType(); }
}
public bool IsNull
{
@ -85,4 +82,13 @@ namespace DCFApixels.DragonECS
public static bool operator !=(Null? a, ComponentTemplateProperty b) { return !b.IsNull; }
public readonly struct Null { }
}
public sealed class ComponentTemplateFieldAttribute : PropertyAttribute, IReferenceButtonAttribute
{
public Type[] PredicateTypes;
Type[] IReferenceButtonAttribute.PredicateTypes { get { return PredicateTypes; } }
bool IReferenceButtonAttribute.IsHideButtonIfNotNull { get { return true; } }
public ComponentTemplateFieldAttribute() { }
}
public sealed class ComponentTemplateAttribute : PropertyAttribute { }
}

View File

@ -9,222 +9,200 @@ namespace DCFApixels.DragonECS.Unity.Editors
[CustomPropertyDrawer(typeof(ComponentTemplateProperty), true)]
internal class ComponentTemplatePropertyDrawer : ExtendedPropertyDrawer
{
//private EcsDragonFieldDrawer _drawer = new EcsDragonFieldDrawer(new PredicateTypesKey(typeof(ITemplateNode)));
//protected override float GetCustomHeight(SerializedProperty property, GUIContent label)
//{
// property.Next(true);
// _drawer.StaticInit();
// _drawer.Init(property);
// return _drawer.GetPropertyHeight(property, label);
//}
//protected override void DrawCustom(Rect position, SerializedProperty property, GUIContent label)
//{
// var root = property.Copy();
// property.Next(true);
// _drawer.StaticInit();
// _drawer.Init(property);
// _drawer.Draw(position, root, property, label);
//}
protected override float GetCustomHeight(SerializedProperty property, GUIContent label)
private ComponentTemplateReferenceDrawer _drawer = new ComponentTemplateReferenceDrawer(new PredicateTypesKey(new Type[] { typeof(ITemplateNode) }));
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
property.Next(true);
return EditorGUI.GetPropertyHeight(property, label);
_drawer.StaticInit();
_drawer.Init();
return _drawer.GetPropertyHeight(property, label);
}
protected override void DrawCustom(Rect position, SerializedProperty property, GUIContent label)
{
var root = property.Copy();
property.Next(true);
EditorGUI.PropertyField(position, property, label);
_drawer.StaticInit();
_drawer.Init();
_drawer.Draw(position, root, property, label);
}
}
[CustomPropertyDrawer(typeof(ComponentTemplateFieldAttribute), true)]
internal class ComponentTemplateReferenceDrawer : ExtendedPropertyDrawer<ComponentTemplateFieldAttribute>
{
private const float DamagedComponentHeight = 18f * 2f;
private ComponentTemplatesDropDown _componentDropDown;
private PredicateTypesKey? _predicateOverride;
#region Properties
private float Padding => Spacing;
protected override bool IsInit => _componentDropDown != null;
#endregion
public ComponentTemplateReferenceDrawer() { }
public ComponentTemplateReferenceDrawer(PredicateTypesKey key)
{
_predicateOverride = key;
}
#region Init
protected override void OnInit()
{
PredicateTypesKey key;
if(_predicateOverride == null)
{
Type[] withOutTypes = Type.EmptyTypes;
if (fieldInfo != null)
{
withOutTypes = fieldInfo.TryGetAttribute(out ReferenceButtonWithOutAttribute a) ? a.PredicateTypes : Array.Empty<Type>();
}
if (Attribute != null)
{
var types = Attribute.PredicateTypes;
if(types == null || types.Length == 0)
{
types = new Type[] { typeof(ITemplateNode) };
}
key = new PredicateTypesKey(types, withOutTypes);
}
else
{
key = new PredicateTypesKey(new Type[] { typeof(object) }, withOutTypes);
}
_predicateOverride = key;
}
_componentDropDown = ComponentTemplatesDropDown.Get(_predicateOverride.Value);
_componentDropDown.OnSelected += SelectComponent;
}
[ThreadStatic]
private static SerializedProperty currentProperty;
private static void SelectComponent(ComponentTemplatesDropDown.Item item)
{
//EcsGUI.Changed = true;
object inst = item.Obj.CreateInstance();
currentProperty.managedReferenceValue = inst;
currentProperty.isExpanded = false;
currentProperty.serializedObject.ApplyModifiedProperties();
}
#endregion
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
bool isSerializeReference = property.propertyType == SerializedPropertyType.ManagedReference;
//#region No SerializeReference
//if (property.propertyType != SerializedPropertyType.ManagedReference)
//{
// return EditorGUI.GetPropertyHeight(property, label);
//}
//#endregion
if (isSerializeReference)
{
var instance = property.managedReferenceValue;
IComponentTemplate template = instance as IComponentTemplate;
if (instance == null)
{
return EditorGUIUtility.singleLineHeight + Padding * 2f;
}
try
{
if (instance is ComponentTemplateBase customTemplate)
{
property = property.FindPropertyRelative("component");
}
}
catch
{
property = null;
}
if (property == null)
{
return DamagedComponentHeight;
}
}
int propCount = EcsGUI.GetChildPropertiesCount(property);
return (propCount <= 0 ? EditorGUIUtility.singleLineHeight : EditorGUI.GetPropertyHeight(property, label)) + Padding * 4f;
}
protected override void DrawCustom(Rect position, SerializedProperty property, GUIContent label)
{
Draw(position, property, property, label);
}
public void Draw(Rect rect, SerializedProperty rootProperty, SerializedProperty property, GUIContent label)
{
bool isSerializeReference = property.propertyType == SerializedPropertyType.ManagedReference;
//#region No SerializeReference
//if (isSerializeReference == false)
//{
// EditorGUI.PropertyField(position, property, label, true);
// return;
//}
//#endregion
ITypeMeta meta = null;
SerializedProperty componentProp = property;
if (isSerializeReference)
{
var instance = property.managedReferenceValue;
if (instance == null)
{
DrawSelectionPopup(rect, property, label);
return;
}
IComponentTemplate template = instance as IComponentTemplate;
if (componentProp.managedReferenceValue is ComponentTemplateBase customTemplate)
{
componentProp = property.FindPropertyRelative("component");
}
if (componentProp == null)
{
DrawDamagedComponent(rect, "Damaged component template.");
return;
}
meta = template is ITypeMeta metaOverride ? metaOverride : _predicateOverride.Value.Types[0].GetMeta();
}
else
{
meta = fieldInfo.FieldType.GetMeta();
}
if (EcsGUI.DrawTypeMetaBlock(ref rect, rootProperty, meta))
{
return;
}
label.text = meta.Name;
if (componentProp.propertyType == SerializedPropertyType.Generic)
{
EditorGUI.PropertyField(rect, componentProp, label, true);
}
else
{
EditorGUI.PropertyField(rect.AddPadding(0, 20f, 0, 0), componentProp, label, true);
}
}
private void DrawSelectionPopup(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.LabelField(position, label);
Rect buttonRect = RectUtility.AddPadding(position, EditorGUIUtility.labelWidth, 0f, 0f, 0f);
if (GUI.Button(buttonRect, "Select"))
{
currentProperty = property;
_componentDropDown.Show(buttonRect);
}
}
private void DrawDamagedComponent(Rect position, string message)
{
EditorGUI.HelpBox(position, message, MessageType.Warning);
}
}
//[CustomPropertyDrawer(typeof(ComponentTemplateFieldAttribute), true)]
//internal class ComponentTemplateFieldDrawer : ExtendedPropertyDrawer<ComponentTemplateFieldAttribute>
//{
// private const float DamagedComponentHeight = 18f * 2f;
// private ComponentTemplatesDropDown _componentDropDown;
// private PredicateTypesKey? _predicateOverride;
//
// #region Properties
// private float Padding => Spacing;
// protected override bool IsInit => _componentDropDown != null;
// #endregion
//
// public ComponentTemplateFieldDrawer() { }
// public ComponentTemplateFieldDrawer(PredicateTypesKey key)
// {
// _predicateOverride = key;
// }
//
// #region Init
// protected override void OnInit(SerializedProperty property)
// {
// PredicateTypesKey key;
// if(_predicateOverride == null)
// {
// Type[] withOutTypes = Type.EmptyTypes;
// if (fieldInfo != null)
// {
// withOutTypes = fieldInfo.TryGetAttribute(out ReferenceButtonWithOutAttribute a) ? a.PredicateTypes : Array.Empty<Type>();
// }
// if (Attribute != null)
// {
// var types = Attribute.PredicateTypes;
// if(types == null || types.Length == 0)
// {
// types = new Type[] { typeof(ITemplateNode) };
// }
// key = new PredicateTypesKey(typeof(ITemplateNode), types, withOutTypes);
// }
// else
// {
// key = new PredicateTypesKey(typeof(object), withOutTypes);
// }
// _predicateOverride = key;
// }
// _componentDropDown = ComponentTemplatesDropDown.Get(_predicateOverride.Value);
// _componentDropDown.OnSelected += SelectComponent;
// }
//
// [ThreadStatic]
// private static SerializedProperty currentProperty;
// private static void SelectComponent(ComponentTemplatesDropDown.Item item)
// {
// //EcsGUI.Changed = true;
// object inst = item.Obj.CreateInstance();
// currentProperty.managedReferenceValue = inst;
// currentProperty.isExpanded = false;
// currentProperty.serializedObject.ApplyModifiedProperties();
// }
// #endregion
//
// public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
// {
// bool isSerializeReference = property.propertyType == SerializedPropertyType.ManagedReference;
// //#region No SerializeReference
// //if (property.propertyType != SerializedPropertyType.ManagedReference)
// //{
// // return EditorGUI.GetPropertyHeight(property, label);
// //}
// //#endregion
//
// if (isSerializeReference)
// {
// var instance = property.managedReferenceValue;
// IComponentTemplate template = instance as IComponentTemplate;
// if (instance == null)
// {
// return EditorGUIUtility.singleLineHeight + Padding * 2f;
// }
//
// try
// {
// if (instance is ComponentTemplateBase customTemplate)
// {
// property = property.FindPropertyRelative("component");
// }
// }
// catch
// {
// property = null;
// }
// if (property == null)
// {
// return DamagedComponentHeight;
// }
// }
//
// int propCount = EcsGUI.GetChildPropertiesCount(property);
//
// return (propCount <= 0 ? EditorGUIUtility.singleLineHeight : EditorGUI.GetPropertyHeight(property, label)) + Padding * 4f;
// }
//
// protected override void DrawCustom(Rect position, SerializedProperty property, GUIContent label)
// {
// Draw(position, property, property, label);
// }
// public void Draw(Rect rect, SerializedProperty rootProperty, SerializedProperty property, GUIContent label)
// {
// bool isSerializeReference = property.propertyType == SerializedPropertyType.ManagedReference;
// //#region No SerializeReference
// //if (isSerializeReference == false)
// //{
// // EditorGUI.PropertyField(position, property, label, true);
// // return;
// //}
// //#endregion
//
// ITypeMeta meta = null;
// SerializedProperty componentProp = property;
// if (isSerializeReference)
// {
// var template = property.managedReferenceValue;
// if (template == null)
// {
// DrawSelectionPopup(rect, property, label);
// return;
// }
//
// IComponentTemplate componentTemplate = template as IComponentTemplate;
// if (componentProp.managedReferenceValue is ComponentTemplateBase customTemplate)
// {
// componentProp = property.FindPropertyRelative("component");
// }
// if (componentProp == null)
// {
// DrawDamagedComponent(rect, "Damaged component template.");
// return;
// }
//
// meta = template as ITypeMeta;
// if (meta == null)
// {
// if (componentTemplate != null)
// {
// meta = componentTemplate.ComponentType.GetMeta();
// }
// else
// {
// meta = template.GetMeta();
// }
// }
// }
// else
// {
// meta = fieldInfo.FieldType.GetMeta();
// }
//
//
// if (EcsGUI.DrawTypeMetaBlock(ref rect, rootProperty, meta).skip)
// {
// return;
// }
//
// label.text = meta.Name;
// if (componentProp.propertyType == SerializedPropertyType.Generic)
// {
// EditorGUI.PropertyField(rect, componentProp, label, true);
// }
// else
// {
// EditorGUI.PropertyField(rect.AddPadding(0, 20f, 0, 0), componentProp, label, true);
// }
// }
//
// private void DrawSelectionPopup(Rect position, SerializedProperty property, GUIContent label)
// {
// EditorGUI.LabelField(position, label);
// Rect buttonRect = RectUtility.AddPadding(position, EditorGUIUtility.labelWidth, 0f, 0f, 0f);
// if (GUI.Button(buttonRect, "Select"))
// {
// currentProperty = property;
// _componentDropDown.Show(buttonRect);
// }
// }
// private void DrawDamagedComponent(Rect position, string message)
// {
// EditorGUI.HelpBox(position, message, MessageType.Warning);
// }
//}
}
#endif

View File

@ -10,14 +10,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
internal abstract class EntityTemplateEditorBase : ExtendedEditor
{
private DragonFieldDropDown _componentDropDown;
private ComponentTemplatesDropDown _componentDropDown;
private SerializedProperty _componentTemplatesProp;
private SerializedProperty _templatesProp;
private SerializedProperty _componentsProp;
private ReorderableList _reorderableComponentsList;
private int _reorderableComponentsListLastCount;
private static readonly Type[] _predicateTypes = new Type[] { typeof(IComponentTemplate), typeof(IEcsComponentMember) };
private static readonly Type[] _predicateTypes = new Type[] { typeof(ITemplateNode) };
protected abstract bool IsSO { get; }
@ -25,12 +24,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
protected override bool IsInit { get { return _componentDropDown != null; } }
protected override void OnInit()
{
_componentDropDown = DragonFieldDropDown.Get(new PredicateTypesKey(typeof(ITemplateNode), _predicateTypes, Type.EmptyTypes));
_componentDropDown = ComponentTemplatesDropDown.Get(new PredicateTypesKey(_predicateTypes, Type.EmptyTypes));
_componentTemplatesProp = serializedObject.FindProperty("_componentTemplates");
_templatesProp = serializedObject.FindProperty("_templates");
_componentsProp = serializedObject.FindProperty("_componentTemplates");
_reorderableComponentsList = new ReorderableList(serializedObject, _componentTemplatesProp, true, false, false, false);
_reorderableComponentsList = new ReorderableList(serializedObject, _componentsProp, true, false, false, false);
_reorderableComponentsList.onAddCallback += OnReorderableComponentsListAdd;
_reorderableComponentsList.onRemoveCallback += OnReorderableListRemove;
_reorderableComponentsList.drawElementCallback += OnReorderableListDrawEmptyElement;
@ -52,7 +50,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void OnReorderableListReorder(ReorderableList list)
{
DragonGUI.Changed = true;
EcsGUI.Changed = true;
}
private SerializedProperty GetTargetProperty(SerializedProperty prop)
@ -75,74 +73,55 @@ namespace DCFApixels.DragonECS.Unity.Editors
private float OnReorderableComponentsListElementHeight(int index)
{
SerializedProperty prop = _componentTemplatesProp.GetArrayElementAtIndex(index);
GUIContent label = UnityEditorUtility.GetLabelTemp();
return EditorGUI.GetPropertyHeight(prop, label) + Spacing * 2f;
//var componentProperty = GetTargetProperty(_componentTemplatesProp.GetArrayElementAtIndex(index));
//float result = EditorGUI.GetPropertyHeight(componentProperty);
//return EcsGUI.GetTypeMetaBlockHeight(result) + Spacing * 2f;
var componentProperty = GetTargetProperty(_componentsProp.GetArrayElementAtIndex(index));
float result = EditorGUI.GetPropertyHeight(componentProperty);
return EcsGUI.GetTypeMetaBlockHeight(result) + Spacing * 2f;
}
private void OnReorderableComponentsListDrawElement(Rect rect, int index, bool isActive, bool isFocused)
{
if (index < 0 || Event.current.type == EventType.Used) { return; }
SerializedProperty prop = _componentTemplatesProp.GetArrayElementAtIndex(index);
GUIContent label = UnityEditorUtility.GetLabelTemp();
rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing);
using (EcsGUI.CheckChanged())
{
SerializedProperty prop = _componentsProp.GetArrayElementAtIndex(index);
EditorGUI.PropertyField(rect, prop, label);
return;
//rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing);
//using (EcsGUI.CheckChanged())
//{
// SerializedProperty prop = _componentTemplatesProp.GetArrayElementAtIndex(index);
//
// var template = prop.managedReferenceValue;
// if (template == null)
// {
// //DrawDamagedComponent_Replaced(prop, index);
// EditorGUI.PropertyField(rect, prop, UnityEditorUtility.GetLabel(prop.displayName), true);
// return;
// }
// IComponentTemplate componentTemplate = template as IComponentTemplate;
// var componentProp = GetTargetProperty(prop);
//
// ITypeMeta meta = template as ITypeMeta;
// if(meta == null)
// {
// if (componentTemplate != null)
// {
// meta = componentTemplate.ComponentType.GetMeta();
// }
// else
// {
// meta = template.GetMeta();
// }
// }
//
// if (EcsGUI.DrawTypeMetaElementBlock(ref rect, _componentTemplatesProp, index, componentProp, meta).skip)
// {
// return;
// }
//
//
// GUIContent label = UnityEditorUtility.GetLabel(meta.Name);
// if (componentProp.propertyType == SerializedPropertyType.Generic)
// {
// EditorGUI.PropertyField(rect, componentProp, label, true);
// }
// else
// {
// EditorGUI.PropertyField(rect.AddPadding(0, 20f, 0, 0), componentProp, label, true);
// }
//
//}
IComponentTemplate template = prop.managedReferenceValue as IComponentTemplate;
if (template == null || prop.managedReferenceValue == null)
{
//DrawDamagedComponent_Replaced(prop, index);
EditorGUI.PropertyField(rect, prop, UnityEditorUtility.GetLabel(prop.displayName), true);
return;
}
var componentProp = GetTargetProperty(prop);
ITypeMeta meta = template is ITypeMeta metaOverride ? metaOverride : template.Type.GetMeta();
if (EcsGUI.DrawTypeMetaElementBlock(ref rect, _componentsProp, index, componentProp, meta))
{
return;
}
GUIContent label = UnityEditorUtility.GetLabel(meta.Name);
if (componentProp.propertyType == SerializedPropertyType.Generic)
{
EditorGUI.PropertyField(rect, componentProp, label, true);
}
else
{
EditorGUI.PropertyField(rect.AddPadding(0, 20f, 0, 0), componentProp, label, true);
}
}
}
private void OnReorderableComponentsListAdd(ReorderableList list)
{
list.serializedProperty.arraySize += 1;
list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).ResetValues();
DragonGUI.Changed = true;
EcsGUI.Changed = true;
}
private void OnReorderableListRemove(ReorderableList list)
{
@ -158,7 +137,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
list.serializedProperty.DeleteArrayElementAtIndex(list.selectedIndices[i]);
}
DragonGUI.Changed = true;
EcsGUI.Changed = true;
}
#endregion
@ -168,11 +147,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
Init();
if (IsSO)
{
DragonGUI.Layout.ManuallySerializeButton(targets);
EcsGUI.Layout.ManuallySerializeButton(targets);
}
if (IsMultipleTargets)
@ -185,17 +162,17 @@ namespace DCFApixels.DragonECS.Unity.Editors
//костыль который насильно заставляет _reorderableComponentsList пересчитать высоту
if (_reorderableComponentsListLastCount != _reorderableComponentsList.count)
{
DragonGUI.Changed = true;
EcsGUI.Changed = true;
_reorderableComponentsListLastCount = _reorderableComponentsList.count;
}
}
if (IsMultipleTargets == false && SerializationUtility.HasManagedReferencesWithMissingTypes(target))
{
using (DragonGUI.Layout.BeginHorizontal(EditorStyles.helpBox))
using (EcsGUI.Layout.BeginHorizontal(EditorStyles.helpBox))
{
GUILayout.Label(UnityEditorUtility.GetLabel(Icons.Instance.WarningIcon), GUILayout.ExpandWidth(false));
using (DragonGUI.Layout.BeginVertical())
using (EcsGUI.Layout.BeginVertical())
{
GUILayout.Label("This object contains SerializeReference types which are missing.", EditorStyles.miniLabel);
if (GUILayout.Button("Repaire References Tool", EditorStyles.miniButton, GUILayout.MaxWidth(200f)))
@ -209,44 +186,33 @@ namespace DCFApixels.DragonECS.Unity.Editors
SerializedProperty iterator = serializedObject.GetIterator();
iterator.NextVisible(true);
using (DragonGUI.Disable)
{
EditorGUILayout.PropertyField(iterator, true);
}
while (iterator.NextVisible(false))
{
if ((_componentTemplatesProp != null && iterator.name == _componentTemplatesProp.name) ||
(_templatesProp != null && iterator.name == _templatesProp.name))
if (_componentsProp != null && iterator.name == _componentsProp.name)
{
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{
DrawTop(_componentsProp);
_reorderableComponentsList.DoLayoutList();
}
}
else
{
EditorGUILayout.PropertyField(iterator, true);
}
}
if (_templatesProp != null)
{
EditorGUILayout.PropertyField(_templatesProp, true);
}
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{
DrawTop(_componentTemplatesProp);
_reorderableComponentsList.DoLayoutList();
}
}
private void DrawTop(SerializedProperty componentsProp)
{
GUILayout.Space(2f);
switch (DragonGUI.Layout.AddClearComponentButtons(out Rect rect))
switch (EcsGUI.Layout.AddClearComponentButtons(out Rect rect))
{
case DragonGUI.AddClearButton.Add:
case EcsGUI.AddClearButton.Add:
Init();
_componentDropDown.OpenForArray(rect, componentsProp, true);
break;
case DragonGUI.AddClearButton.Clear:
case EcsGUI.AddClearButton.Clear:
Init();
componentsProp.ClearArray();
serializedObject.ApplyModifiedProperties();

View File

@ -1,35 +1,20 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Unity;
using DCFApixels.DragonECS.Unity.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
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;
}
}
}
using static DCFApixels.DragonECS.IComponentTemplate;
namespace DCFApixels.DragonECS
{
public interface IComponentTemplate : ITemplateNode
{
#region Properties
Type ComponentType { get; }
Type Type { get; }
bool IsUnique { get; }
#endregion
@ -48,168 +33,94 @@ namespace DCFApixels.DragonECS
}
[Serializable]
[DragonMemberWrapper("component")]
[MetaColor(MetaColor.DragonCyan)]
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)]
[MetaProxy(typeof(ComponentTemplateMetaProxy))]
public abstract class ComponentTemplateBase : IComponentTemplate
public abstract class ComponentTemplateBase : IComponentTemplate, ITypeMeta
{
#region Properties
public abstract Type ComponentType { get; }
public abstract Type Type { get; }
public virtual ITypeMeta BaseMeta { get { return null; } }
public virtual string Name { get { return string.Empty; } }
public virtual MetaColor Color { get { return new MetaColor(MetaColor.Black); } }
public virtual MetaGroup Group { get { return MetaGroup.Empty; } }
public virtual MetaDescription Description { get { return MetaDescription.Empty; } }
public virtual IReadOnlyList<string> Tags { get { return Array.Empty<string>(); } }
public virtual bool IsUnique { get { return true; } }
#endregion
#region Methods
public abstract object GetRaw();
public abstract void SetRaw(object raw);
public virtual void OnGizmos(Transform transform, IComponentTemplate.GizmosMode mode) { }
public virtual void OnGizmos(Transform transform, GizmosMode mode) { }
public virtual void OnValidate(UnityEngine.Object obj) { }
public abstract void Apply(short worldID, int entityID);
#endregion
#region MetaProxy
protected class ComponentTemplateMetaProxy : MetaProxyBase
{
protected TypeMeta Meta;
public override string Name { get { return Meta?.Name; } }
public override MetaColor? Color { get { return Meta != null && Meta.IsCustomColor ? Meta.Color : null; } }
public override MetaGroup Group { get { return Meta?.Group; } }
public override MetaDescription Description { get { return Meta?.Description; } }
public override IEnumerable<string> Tags { get { return Meta?.Tags; } }
public ComponentTemplateMetaProxy(Type type) : base(type)
{
Meta = null;
var fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
foreach (var field in fields)
{
if (field.Name == "component")
{
Meta = field.FieldType.GetMeta();
return;
}
}
}
}
#endregion
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public abstract class ComponentTemplateBase<T> : ComponentTemplateBase, ICloneable
where T : struct
{
protected static readonly TypeMeta Meta = EcsDebugUtility.GetTypeMeta<T>();
private static bool _defaultValueInit = false;
private static bool _hasDefaultValue = false;
private static T _defaultValue;
private static ICloneable _defaultValueCloneable;
private static CloneMethod _defaultValueCloneMethod;
private enum CloneMethod
{
Set,
Clone_Reflection,
ICloneable,
}
protected static void InitStatic()
{
if (_defaultValueInit == false)
{
_hasDefaultValue = false;
Type type = typeof(T);
FieldInfo field;
field = type.GetField("Default", BindingFlags.Static | BindingFlags.Public);
if (field != null && field.FieldType == type)
{
_defaultValue = (T)field.GetValue(null);
_hasDefaultValue = true;
}
if(_hasDefaultValue == false)
{
field = type.GetField("Empty", BindingFlags.Static | BindingFlags.Public);
if (field != null && field.FieldType == type)
{
_defaultValue = (T)field.GetValue(null);
_hasDefaultValue = true;
}
}
if (_defaultValue == null)
{
_hasDefaultValue = false;
}
if (_hasDefaultValue)
{
_defaultValueCloneable = _defaultValue as ICloneable;
_defaultValueCloneMethod = CloneMethod.Set;
if (type.IsValueType == false)
{
_defaultValueCloneMethod = CloneMethod.Clone_Reflection;
}
if (_defaultValueCloneable != null)
{
_defaultValueCloneMethod = CloneMethod.ICloneable;
}
}
_defaultValueInit = true;
}
}
protected virtual T DefaultComponent
private static bool _defaultValueTypeInit = false;
private static T _defaultValueType;
protected static T DefaultValueType
{
get
{
if (_hasDefaultValue)
if (_defaultValueTypeInit == false)
{
return CloneComponent(_defaultValue);
Type type = typeof(T);
if (type.IsValueType)
{
FieldInfo field;
field = type.GetField("Default", BindingFlags.Static | BindingFlags.Public);
if (field != null && field.FieldType == type)
{
_defaultValueType = (T)field.GetValue(null);
}
field = type.GetField("Empty", BindingFlags.Static | BindingFlags.Public);
if (field != null && field.FieldType == type)
{
_defaultValueType = (T)field.GetValue(null);
}
}
_defaultValueTypeInit = true;
}
return default;
return _defaultValueType;
}
}
[SerializeField]
protected T component;
protected T component = DefaultValueType;
[SerializeField]
[HideInInspector]
private byte _offset; // Avoids the error "Cannot get managed reference index with out bounds offset"
public ComponentTemplateBase()
{
InitStatic();
component = DefaultComponent;
}
public sealed override Type ComponentType { get { return typeof(T); } }
#region Properties
public sealed override ITypeMeta BaseMeta { get { return Meta; } }
public sealed override Type Type { get { return typeof(T); } }
public override string Name { get { return Meta.Name; } }
public override MetaColor Color { get { return Meta.Color; } }
public override MetaGroup Group { get { return Meta.Group; } }
public override MetaDescription Description { get { return Meta.Description; } }
public override IReadOnlyList<string> Tags { get { return Meta.Tags; } }
#endregion
#region Methods
public sealed override object GetRaw() { return component; }
public sealed override void SetRaw(object raw) { component = (T)raw; }
protected virtual T CloneComponent(T component)
{
#if UNITY_EDITOR
switch (_defaultValueCloneMethod)
{
case CloneMethod.Set:
return component;
case CloneMethod.Clone_Reflection:
return (T)component.Clone_Reflection();
case CloneMethod.ICloneable:
return (T)_defaultValueCloneable.Clone();
}
#endif
return default;
}
protected virtual T CloneComponent() { return component; }
object ICloneable.Clone()
{
ComponentTemplateBase<T> templateClone = (ComponentTemplateBase<T>)MemberwiseClone();
templateClone.component = CloneComponent(component);
templateClone.component = CloneComponent();
return templateClone;
}
#endregion
}
[System.Serializable]
public class ComponentTemplate<T> : ComponentTemplateBase<T>
public abstract class ComponentTemplate<T> : ComponentTemplateBase<T>
where T : struct, IEcsComponent
{
public override void Apply(short worldID, int entityID)
@ -217,8 +128,7 @@ namespace DCFApixels.DragonECS
EcsPool<T>.Apply(ref component, entityID, worldID);
}
}
[System.Serializable]
public class TagComponentTemplate<T> : ComponentTemplateBase<T>
public abstract class TagComponentTemplate<T> : ComponentTemplateBase<T>
where T : struct, IEcsTagComponent
{
public override void Apply(short worldID, int entityID)
@ -265,9 +175,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
if (_meta == null)
{
{
_meta = ComponentType.GetMeta();
}
_meta = ComponentType.GetMeta();
}
return _meta;
}
@ -286,7 +194,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
field = Type.GetField("Default", BindingFlags.Static | BindingFlags.Public);
if (field != null && field.FieldType == Type)
{
_defaultValueDummy = field.GetValue(null).Clone_Reflection();
_defaultValueDummy = field.GetValue(null);
}
if(_defaultValueDummy == null)
@ -294,7 +202,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
field = Type.GetField("Empty", BindingFlags.Static | BindingFlags.Public);
if (field != null && field.FieldType == Type)
{
_defaultValueDummy = field.GetValue(null).Clone_Reflection();
_defaultValueDummy = field.GetValue(null);
}
}
}
@ -308,17 +216,15 @@ namespace DCFApixels.DragonECS.Unity.Editors
Type = type;
IsUnique = false;
if (type.GetInterfaces().Contains(typeof(ITypeMeta)))
{
var metaOverride = (ITypeMeta)Activator.CreateInstance(type);
_meta = metaOverride;
}
if (type.GetInterfaces().Contains(typeof(IComponentTemplate)))
if (typeof(IComponentTemplate).IsAssignableFrom(type))
{
var ct = (IComponentTemplate)Activator.CreateInstance(type);
IsUnique = ct.IsUnique;
ComponentType = ct.ComponentType;
ComponentType = ct.Type;
if (ct is ITypeMeta metaOverride)
{
_meta = metaOverride;
}
}
else
{

View File

@ -2,7 +2,6 @@
#undef DEBUG
#endif
using DCFApixels.DragonECS.Unity;
using DCFApixels.DragonECS.Unity.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
@ -25,8 +24,8 @@ namespace DCFApixels.DragonECS
public class MonoEntityTemplate : MonoEntityTemplateBase, ITemplateNode
{
[SerializeReference]
[ReferenceDropDown(true)]
[DragonMetaBlock]
[ReferenceButton(true, typeof(ITemplateNode))]
[FormerlySerializedAs("_components")]
private ITemplateNode[] _componentTemplates;
#region Methods

View File

@ -2,7 +2,6 @@
#undef DEBUG
#endif
using DCFApixels.DragonECS.Unity;
using DCFApixels.DragonECS.Unity.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
@ -26,8 +25,8 @@ namespace DCFApixels.DragonECS
[SerializeField]
private ScriptableEntityTemplateBase[] _templates;
[SerializeReference]
[ReferenceDropDown(true)]
[DragonMetaBlock]
[ReferenceButton(true, typeof(ITemplateNode))]
[FormerlySerializedAs("_components")]
private ITemplateNode[] _componentTemplates;
#region Methods

View File

@ -62,7 +62,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void OnReorderableListDrawEmptyElement(Rect rect, int index, bool isActive, bool isFocused) { }
private void OnReorderableListReorder(ReorderableList list)
{
DragonGUI.Changed = true;
EcsGUI.Changed = true;
}
private void OnReorderableListRemove(ReorderableList list)
{
@ -78,7 +78,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
list.serializedProperty.DeleteArrayElementAtIndex(list.selectedIndices[i]);
}
DragonGUI.Changed = true;
EcsGUI.Changed = true;
}
#endregion
@ -86,11 +86,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
private static readonly HashSet<string> _defaultLayersSet = new HashSet<string>(PipelineTemplateUtility.DefaultLayers);
private void OnReorderableLayersListDrawElement(Rect rect, int index, bool isActive, bool isFocused)
{
using (DragonGUI.CheckChanged())
using (EcsGUI.CheckChanged())
{
var elementProp = _layersProp.GetArrayElementAtIndex(index);
string str = elementProp.stringValue;
using (DragonGUI.SetEnable(_defaultLayersSet.Contains(str) == false))
using (EcsGUI.SetEnable(_defaultLayersSet.Contains(str) == false))
{
elementProp.stringValue = EditorGUI.TextField(rect, str);
}
@ -102,7 +102,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
var added = list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1);
added.stringValue = $"Layer-{DateTime.Now.Ticks}";
added.serializedObject.ApplyModifiedProperties();
DragonGUI.Changed = true;
EcsGUI.Changed = true;
}
#endregion
@ -111,7 +111,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
if (index < 0 || Event.current.type == EventType.Used) { return; }
rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing);
using (DragonGUI.CheckChanged())
using (EcsGUI.CheckChanged())
{
SerializedProperty prop = _recordsProp.GetArrayElementAtIndex(index);
var targetProp = prop.FindPropertyRelative(nameof(PipelineTemplateUtility.Record.target));
@ -119,7 +119,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
bool isNull = targetProp.managedReferenceValue == null;
ITypeMeta meta = isNull ? null : targetProp.managedReferenceValue.GetMeta();
if (DragonGUI.DrawTypeMetaElementBlock(ref rect, _recordsProp, index, prop, meta).skip)
if (EcsGUI.DrawTypeMetaElementBlock(ref rect, _recordsProp, index, prop, meta))
{
return;
}
@ -130,14 +130,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
float result;
result = EditorGUI.GetPropertyHeight(_recordsProp.GetArrayElementAtIndex(index));
return DragonGUI.GetTypeMetaBlockHeight(result) + Spacing * 2f;
return EcsGUI.GetTypeMetaBlockHeight(result) + Spacing * 2f;
}
private void OnReorderableRecordsListAdd(ReorderableList list)
{
list.serializedProperty.arraySize += 1;
list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).ResetValues();
DragonGUI.Changed = true;
EcsGUI.Changed = true;
}
#endregion
@ -146,7 +146,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
if (IsSO)
{
DragonGUI.Layout.ManuallySerializeButton(targets);
EcsGUI.Layout.ManuallySerializeButton(targets);
}
if (IsMultipleTargets)
@ -155,13 +155,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
return;
}
DragonGUI.Changed = GUILayout.Button("Validate");
EcsGUI.Changed = GUILayout.Button("Validate");
DrawLayoutNameList(_layersProp);
EditorGUILayout.PropertyField(_parametersProp, UnityEditorUtility.GetLabel(_parametersProp.displayName));
DrawRecordList(_recordsProp);
if (DragonGUI.Changed)
if (EcsGUI.Changed)
{
serializedObject.ApplyModifiedProperties();
Validate();
@ -181,7 +181,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawLayoutNameList(SerializedProperty layersProp)
{
using (DragonGUI.Layout.BeginVertical())
using (EcsGUI.Layout.BeginVertical())
{
GUILayout.Label(UnityEditorUtility.GetLabel(layersProp.displayName), EditorStyles.boldLabel);
_reorderableLayersList.DoLayoutList();
@ -190,16 +190,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawRecordList(SerializedProperty recordsProp)
{
GUILayout.Label(UnityEditorUtility.GetLabel(recordsProp.displayName), EditorStyles.boldLabel);
using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{
GUILayout.Space(4f);
switch (DragonGUI.Layout.AddClearSystemButtons(out Rect dropDownRect))
switch (EcsGUI.Layout.AddClearSystemButtons(out Rect dropDownRect))
{
case DragonGUI.AddClearButton.Add:
case EcsGUI.AddClearButton.Add:
_systemsDropDown.OpenForArray(dropDownRect, recordsProp);
break;
case DragonGUI.AddClearButton.Clear:
case EcsGUI.AddClearButton.Clear:
recordsProp.ClearArray();
recordsProp.serializedObject.ApplyModifiedProperties();
break;

View File

@ -21,7 +21,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
using (DragonGUI.SetIndentLevel(IsArrayElement ? DragonGUI.IndentLevel : DragonGUI.IndentLevel + 1))
using (EcsGUI.SetIndentLevel(IsArrayElement ? EcsGUI.IndentLevel : EcsGUI.IndentLevel + 1))
{
Rect subPosition = position;
int depth = -1;
@ -41,7 +41,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
}
}
protected override float GetCustomHeight(SerializedProperty property, GUIContent label)
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float result = 0f;
if (IsArrayElement == false)

View File

@ -1,7 +1,7 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.RunnersCore;
using DCFApixels.DragonECS.Unity.Internal;
using System;
using System.Collections.Generic;
@ -103,8 +103,8 @@ namespace DCFApixels.DragonECS.Unity
public struct Record
{
[SerializeReference]
[ReferenceDropDown(true, typeof(IEcsModule), typeof(IEcsProcess))]
[ReferenceDropDownWithout(typeof(IEcsRunner))]
[ReferenceButton(true, typeof(IEcsModule), typeof(IEcsProcess))]
[ReferenceButtonWithOut(typeof(IEcsRunner))]
[ArrayElement]
public object target;// нельзя менять поярдок полей, иначе это поломает отрисовку в инспекторе изза применения property.Next(bool);
public AddParams parameters;

View File

@ -36,7 +36,7 @@ namespace DCFApixels.DragonECS.Unity.Docs
private static List<Type> GetTypes()
{
Type metaAttributeType = typeof(DragonMetaAttribute);
Type metaAttributeType = typeof(EcsMetaAttribute);
List<Type> result = new List<Type>(512);
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{

View File

@ -57,20 +57,6 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
private void OnGUI()
{
Event current = Event.current;
int moveSign = 0;
if (hasFocus && current.type == EventType.KeyUp && current.isKey)
{
if(current.keyCode == KeyCode.DownArrow)
{
moveSign = 1;
}
if (current.keyCode == KeyCode.UpArrow)
{
moveSign = -1;
}
}
// _selectedIndex += moveSign;
DragonDocs docs = DragonDocsPrefs.instance.Docs;
if (docs == null || docs.Metas.IsEmpty)
{
@ -93,21 +79,22 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
_selectedIndex = 0;
}
DrawToolbar();
GUILayout.BeginHorizontal(GUILayout.ExpandHeight(true));
MetaGroupInfo selectedGroupInfo;
using (DragonGUI.Layout.BeginScrollView(ref ButtonsScrolPosition, UnityEditorUtility.GetClearBackgrounStyle(), GUILayout.Width(_buttonsWidth)))
using (EcsGUI.Layout.BeginScrollView(ref ButtonsScrolPosition, UnityEditorUtility.GetClearBackgrounStyle(), GUILayout.Width(_buttonsWidth)))
{
selectedGroupInfo = DrawGroups(moveSign);
selectedGroupInfo = DrawGroups();
}
DrawDragger();
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * -2f);
using (DragonGUI.Layout.BeginScrollView(ref DataScrolPosition, UnityEditorUtility.GetTransperentBlackBackgrounStyle(), GUILayout.ExpandWidth(true)))
using (EcsGUI.Layout.BeginScrollView(ref DataScrolPosition, UnityEditorUtility.GetTransperentBlackBackgrounStyle(), GUILayout.ExpandWidth(true)))
{
DrawSelectedGroupMeta(selectedGroupInfo);
}
@ -128,17 +115,11 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
{
GUILayout.Label(infos[_selectedIndex].Path);
}
if (moveSign != 0)
{
Repaint();
return;
}
}
private void DrawToolbar()
{
using (DragonGUI.SetColor(GUI.color * 0.8f))
using (EcsGUI.SetColor(GUI.color * 0.8f))
GUILayout.BeginHorizontal(EditorStyles.toolbar);
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f);
@ -148,12 +129,12 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
DragonDocsPrefs.instance.Save(docs);
}
if (DragonGUI.Layout.IconButton(IsShowHidden ? Icons.Instance.VisibilityIconOn : Icons.Instance.VisibilityIconOff, 0f, IsShowHidden ? "Show Hidden" : "Don't Show Hidden", EditorStyles.toolbarButton, GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f)))
if (EcsGUI.Layout.IconButton(IsShowHidden ? Icons.Instance.VisibilityIconOn : Icons.Instance.VisibilityIconOff, 0f, IsShowHidden ? "Show Hidden" : "Don't Show Hidden", EditorStyles.toolbarButton, GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f)))
{
IsShowHidden = !IsShowHidden;
}
if (DragonGUI.Layout.IconButton(IsUseCustomNames ? Icons.Instance.LabelIconMeta : Icons.Instance.LabelIconType, 1f, IsUseCustomNames ? "Use Meta Name" : "Use Type Name", EditorStyles.toolbarButton, GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f)))
if (EcsGUI.Layout.IconButton(IsUseCustomNames ? Icons.Instance.LabelIconMeta : Icons.Instance.LabelIconType, 1f, IsUseCustomNames ? "Use Meta Name" : "Use Type Name", EditorStyles.toolbarButton, GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f)))
{
IsUseCustomNames = !IsUseCustomNames;
}
@ -166,7 +147,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
_searchingSampleChanged = true;
}
if ((_searchingSampleChanged && Event.current.keyCode == KeyCode.Return) ||
DragonGUI.Layout.IconButton(Icons.Instance.SearchIcon, 1f, null, EditorStyles.toolbarButton, GUILayout.ExpandHeight(true), GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f)))
EcsGUI.Layout.IconButton(Icons.Instance.SearchIcon, 1f, null, EditorStyles.toolbarButton, GUILayout.ExpandHeight(true), GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f)))
{
Searh();
}
@ -265,29 +246,29 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
private void DrawMeta(DragonDocsMeta meta, int index, int total)
{
using (DragonGUI.SetIndentLevel(0))
using (EcsGUI.SetIndentLevel(0))
{
Color panelColor = DragonGUI.SelectPanelColor(meta.Color.ToMetaColor(), meta.IsCustomColor, index, total).Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
Color panelColor = EcsGUI.SelectPanelColor(meta.Color.ToMetaColor(), meta.IsCustomColor, index, total).Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
Color alphaPanelColor = panelColor;
alphaPanelColor.a = EscEditorConsts.MetaBlockFillStyle_Alpha;
alphaPanelColor.a = EscEditorConsts.COMPONENT_DRAWER_ALPHA;
using (DragonGUI.Layout.BeginVertical(alphaPanelColor))
using (EcsGUI.Layout.BeginVertical(alphaPanelColor))
{
GUILayout.Space(1f);
//draw title block
using (DragonGUI.Layout.BeginHorizontal())
using (EcsGUI.Layout.BeginHorizontal())
{
GUILayout.TextArea(IsUseCustomNames ? meta.Name : meta.TypeName, EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
if (meta.TryGetSourceType(out System.Type targetType) && ScriptsCache.TryGetScriptAsset(targetType.GetMeta(), out MonoScript script))
{
DragonGUI.Layout.ScriptAssetButton(script, GUILayout.Width(18f));
EcsGUI.Layout.ScriptAssetButton(script, GUILayout.Width(18f));
}
if (meta.IsCustomName)
{
using (DragonGUI.SetAlpha(0.64f)) using (DragonGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleRight))
using (EcsGUI.SetAlpha(0.64f)) using (EcsGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleRight))
{
GUILayout.TextArea(IsUseCustomNames ? meta.TypeName : meta.Name, GUI.skin.label);
}
@ -301,7 +282,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
if (string.IsNullOrEmpty(meta.MetaID) == false)
{
GUILayout.Space(-EditorGUIUtility.standardVerticalSpacing);
DragonGUI.Layout.CopyMetaIDButton(meta.MetaID, GUILayout.Width(18f));
EcsGUI.Layout.CopyMetaIDButton(meta.MetaID, GUILayout.Width(18f));
}
}
@ -334,7 +315,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
GUILayout.Space(3f);
var tagsstring = string.Join(',', meta._tags);
using (DragonGUI.SetAlpha(0.5f))
using (EcsGUI.SetAlpha(0.5f))
{
GUILayout.TextArea(tagsstring, EditorStyles.wordWrappedMiniLabel);
}
@ -345,17 +326,14 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
}
}
private MetaGroupInfo DrawGroups(int moveSign)
private MetaGroupInfo DrawGroups()
{
Event current = Event.current;
MetaGroupInfo result = new MetaGroupInfo("NO_NAME", "NO_NAME", 0, 0, 0);
var infos = Prefs.Infos;
var isExpands = Prefs.IsExpands;
int prevIndex = 0;
int nextIndex = 0;
using (DragonGUI.SetIndentLevel(0))
using (EcsGUI.SetIndentLevel(0))
{
int clippingDepth = int.MaxValue;
@ -382,19 +360,10 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
{
clippingDepth = int.MaxValue;
}
if(nextIndex < _selectedIndex)
{
prevIndex = nextIndex;
}
if (nextIndex <= _selectedIndex)
{
nextIndex = i;
}
if (_searchingSample.Length == 0)
{
DragonGUI.IndentLevel = groupInfo.Depth;
EcsGUI.IndentLevel = groupInfo.Depth;
}
GUIContent label = UnityEditorUtility.GetLabel(_searchingSample.Length == 0 ? groupInfo.Name : groupInfo.Path);
@ -405,10 +374,10 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
EditorGUI.DrawRect(r, new Color(0.12f, 0.5f, 1f, 0.40f));
}
using (DragonGUI.SetColor(0, 0, 0, 0)) using (DragonGUI.Disable) { GUI.Button(r, ""); }
using (EcsGUI.SetColor(0, 0, 0, 0)) using (EcsGUI.Disable) { GUI.Button(r, ""); }
bool isClick = false;
if (DragonGUI.HitTest(r))
if (EcsGUI.HitTest(r))
{
EditorGUI.DrawRect(r, new Color(1f, 1f, 1f, 0.12f));
if (current.type == EventType.MouseUp)
@ -422,7 +391,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
if (_searchingSample.Length != 0 || (i + 1 == infos.Length || infos[i + 1].Depth <= groupInfo.Depth))
{
using (DragonGUI.SetBackgroundColor(0, 0, 0, 0))
using (EcsGUI.SetBackgroundColor(0, 0, 0, 0))
{
EditorGUI.Foldout(r, false, label, EditorStyles.foldout);
}
@ -459,18 +428,6 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
}
}
}
if(moveSign != 0)
{
if(moveSign < 0)
{
_selectedIndex = prevIndex;
}
else
{
_selectedIndex = nextIndex;
}
}
return result;
}
@ -494,7 +451,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
switch (current.type)
{
case EventType.MouseDown:
if (DragonGUI.HitTest(rect))
if (EcsGUI.HitTest(rect))
{
_buttonsWidthDragStartPos = current.mousePosition;
_buttonsWidthDragStartValue = _buttonsWidth;

View File

@ -61,7 +61,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
if (index < 0 || index >= _cachedMissingsResolvingDatas.Length) { return; }
ref var data = ref _cachedMissingsResolvingDatas[index];
using (DragonGUI.SetAlpha(0))
using (EcsGUI.SetAlpha(0))
{
if (GUI.Button(rect, ""))
{
@ -75,7 +75,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
{
EditorGUI.DrawRect(rect, _activedColor);
}
if (DragonGUI.HitTest(rect))
if (EcsGUI.HitTest(rect))
{
EditorGUI.DrawRect(rect, _dragColor);
}
@ -122,7 +122,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
GUI.Label(nameRect, name);
EditorGUI.DrawRect(oldRect, new Color(0, 0, 0, 0.16f));
GUI.Label(oldRect, oldStr);
using (DragonGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleCenter))
using (EcsGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleCenter))
{
GUI.Label(arrowRect, "->");
}
@ -160,16 +160,16 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
_panel = new GUIStyle();
_panel.padding = new RectOffset(5, 5, 5, 5);
}
using (DragonGUI.Layout.BeginVertical(_panel))
using (EcsGUI.Layout.BeginVertical(_panel))
{
const string LIST_EMPTY_MESSAGE = "List of Missings is Empty";
const string COLLECT_BUTTON = "Collect Missings";
if (_missingRefContainer.IsEmpty)
{
GUILayout.Label("", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
using (DragonGUI.SetFontSize(14))
using (DragonGUI.SetFontSize(GUI.skin.button, 14))
using (DragonGUI.SetAlignment(value: TextAnchor.MiddleCenter))
using (EcsGUI.SetFontSize(14))
using (EcsGUI.SetFontSize(GUI.skin.button, 14))
using (EcsGUI.SetAlignment(value: TextAnchor.MiddleCenter))
{
Vector2 center = GUILayoutUtility.GetLastRect().center;
Vector2 labelSize = GUI.skin.label.CalcSize(UnityEditorUtility.GetLabel(LIST_EMPTY_MESSAGE));
@ -184,7 +184,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
r = new Rect(Vector2.zero, buttonSize);
r.center = center;
r.y += buttonSize.y / 2f;
if (Event.current.type == EventType.MouseDown && DragonGUI.HitTest(r))
if (Event.current.type == EventType.MouseDown && EcsGUI.HitTest(r))
{
_isNoFound = false;
}
@ -222,8 +222,8 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
InitList();
}
var bc = DragonGUI.SetBackgroundColor(Color.black, 0.5f);
using (DragonGUI.Layout.BeginVertical(EditorStyles.helpBox))
var bc = EcsGUI.SetBackgroundColor(Color.black, 0.5f);
using (EcsGUI.Layout.BeginVertical(EditorStyles.helpBox))
{
bc.Dispose();
_scrollViewPosition = GUILayout.BeginScrollView(_scrollViewPosition, GUILayout.ExpandHeight(true));
@ -232,7 +232,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
}
GUILayout.Space(4f);
using (DragonGUI.Layout.BeginVertical(GUILayout.ExpandHeight(false)))
using (EcsGUI.Layout.BeginVertical(GUILayout.ExpandHeight(false)))
{
//GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(false));
@ -245,14 +245,14 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
if (data == null)
{
using (DragonGUI.SetAlignment(TextAnchor.MiddleCenter))
using (EcsGUI.SetAlignment(TextAnchor.MiddleCenter))
{
GUI.Label(rect, "Select any record");
}
}
else
{
using (DragonGUI.CheckChanged())
using (EcsGUI.CheckChanged())
{
rect.height = EditorGUIUtility.singleLineHeight;
rect = rect.Move(0, EditorGUIUtility.standardVerticalSpacing);
@ -261,7 +261,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
string NamespaceName = DrawEditableLine(rect, "Namespace:", data.OldTypeData.NamespaceName, data.NewTypeData.NamespaceName);
rect = rect.Move(0, EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
string AssemblyName = DrawEditableLine(rect, "Assembly:", data.OldTypeData.AssemblyName, data.NewTypeData.AssemblyName);
if (DragonGUI.Changed)
if (EcsGUI.Changed)
{
data.NewTypeData = new Internal.TypeData(ClassName, NamespaceName, AssemblyName);
}
@ -269,7 +269,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
}
}
using (DragonGUI.Layout.BeginHorizontal(GUILayout.Height(26f)))
using (EcsGUI.Layout.BeginHorizontal(GUILayout.Height(26f)))
{
if (GUILayout.Button("Re-Collect", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(false)))
{

View File

@ -1,477 +0,0 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Unity.Internal;
using System;
using UnityEngine;
namespace DCFApixels.DragonECS.Unity
{
public sealed class ReferenceDropDownAttribute : PropertyAttribute
{
public readonly Type[] AllowTypes;
public readonly bool IsHideButtonIfNotNull;
public ReferenceDropDownAttribute(bool isHideButtonIfNotNull = false) : this(isHideButtonIfNotNull, Array.Empty<Type>()) { }
public ReferenceDropDownAttribute(params Type[] predicateTypes) : this(false, predicateTypes) { }
public ReferenceDropDownAttribute(bool isHideButtonIfNotNull, params Type[] predicateTypes)
{
IsHideButtonIfNotNull = isHideButtonIfNotNull;
AllowTypes = predicateTypes;
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
}
}
public sealed class ReferenceDropDownWithoutAttribute : Attribute
{
public readonly Type[] PredicateTypes;
[Obsolete("With empty parameters, this attribute makes no sense.", true)]
public ReferenceDropDownWithoutAttribute() : this(Array.Empty<Type>()) { }
public ReferenceDropDownWithoutAttribute(params Type[] predicateTypes)
{
PredicateTypes = predicateTypes;
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
}
}
public sealed class DragonMetaBlockAttribute : PropertyAttribute { }
}
#if UNITY_EDITOR
namespace DCFApixels.DragonECS.Unity.Editors
{
using UnityEditor;
[CustomPropertyDrawer(typeof(ReferenceDropDownAttribute), true)]
[CustomPropertyDrawer(typeof(DragonMetaBlockAttribute), true)]
internal class DragonFieldDrawer : ExtendedPropertyDrawer
{
private const float DamagedComponentHeight = 18f * 2f;
private DragonFieldDropDown _dropDown;
private PredicateTypesKey? _predicateOverride;
private ReferenceDropDownAttribute ReferenceDropDownAttribute;
private ReferenceDropDownWithoutAttribute ReferenceDropDownWithoutAttribute;
private DragonMetaBlockAttribute TypeMetaBlockAttribute;
private bool _isInit = false;
private bool _hasSerializableData = true;
// this is a damn hack to prevent the drawer from being called recursively when multiple attributes are attached to it
private static GUIContent _unrecursiveLabel;
private bool _isSerializeReference;
private Type _cachedManagedType;
private long _cachedManagedTypeID;
private Type GetCachedManagedType(SerializedProperty sp)
{
var cid = sp.managedReferenceId;
if (_cachedManagedType == null || _cachedManagedTypeID != cid)
{
//bool mrNull = sp.managedReferenceId == ManagedReferenceUtility.RefIdNull;
//if(mrNull)
//{
// _cachedManagedType = null;
//}
//else
{
_cachedManagedType = sp.managedReferenceValue.GetType();
}
}
return _cachedManagedType;
}
#region Properties
private float Padding => Spacing;
protected override bool IsInit => _isInit;
private bool IsDrawDropDown => ReferenceDropDownAttribute != null;
private bool IsDrawMetaBlock => TypeMetaBlockAttribute != null;
#endregion
#region Init
protected override void OnStaticInit()
{
if (_unrecursiveLabel == null)
{
_unrecursiveLabel = new GUIContent();
}
}
protected override void OnInit(SerializedProperty sp)
{
_isSerializeReference = sp.propertyType == SerializedPropertyType.ManagedReference;
PredicateTypesKey key;
_hasSerializableData = true;
if (fieldInfo != null)
{
foreach (var atrRaw in Attributes)
{
switch (atrRaw)
{
case ReferenceDropDownAttribute atr: ReferenceDropDownAttribute = atr; break;
case ReferenceDropDownWithoutAttribute atr: ReferenceDropDownWithoutAttribute = atr; break;
case DragonMetaBlockAttribute atr: TypeMetaBlockAttribute = atr; break;
}
}
}
if (_predicateOverride == null && PropertyType != null)
{
var targetType = PropertyType;
if (ReferenceDropDownAttribute != null)
{
Type[] withOutTypes = ReferenceDropDownWithoutAttribute != null ? ReferenceDropDownWithoutAttribute.PredicateTypes : Type.EmptyTypes;
bool allAssignableTypes = targetType != typeof(ITemplateNode);
var types = ReferenceDropDownAttribute.AllowTypes;
if (types == null || types.Length == 0)
{
if (allAssignableTypes)
{
types = new Type[] { targetType };
}
else
{
types = new Type[] { typeof(IComponentTemplate), typeof(IEcsComponentMember) };
}
}
key = new PredicateTypesKey(targetType, types, withOutTypes);
}
else
{
key = new PredicateTypesKey(targetType, new Type[] { targetType });
}
_predicateOverride = key;
}
if (IsDrawDropDown)
{
_dropDown = DragonFieldDropDown.Get(_predicateOverride.Value);
_dropDown.OnSelected += SelectComponent;
}
_isInit = true;
}
[ThreadStatic]
private static SerializedProperty currentProperty;
private static void SelectComponent(DragonFieldDropDown.Item item)
{
//EcsGUI.Changed = true;
if (item.Obj == null)
{
currentProperty.managedReferenceValue = null;
}
else
{
currentProperty.managedReferenceValue = item.Obj.CreateInstance();
currentProperty.isExpanded = false;
}
currentProperty.serializedObject.ApplyModifiedProperties();
DragonGUI.DelayedChanged = true;
}
#endregion
protected override float GetCustomHeight(SerializedProperty property, GUIContent label)
{
if (ReferenceEquals(label, _unrecursiveLabel)) { return EditorGUI.GetPropertyHeight(property, label); }
_unrecursiveLabel.text = label.text;
_unrecursiveLabel.tooltip = label.tooltip;
label = _unrecursiveLabel;
if (_isSerializeReference)
{
_hasSerializableData = property.HasSerializableData();
}
SerializedProperty componentProp = property;
if (_isSerializeReference)
{
if (property.IsNullManagedReference())
{
float result = EditorGUIUtility.singleLineHeight;
if (IsDrawMetaBlock)
{
result += Padding * 2f;
}
return result;
}
try
{
//var instance = property.managedReferenceValue;
//if (DragonFieldCahce.RuntimeDict.TryGetValue(instance.GetType(), out var info) && info.HasWrappedFieldName)
var type = GetCachedManagedType(property);
if (DragonFieldCahce.RuntimeDict.TryGetValue(type, out var info) && info.HasWrappedFieldName)
{
componentProp = property.FindPropertyRelative(info.WrappedFieldName);
}
}
catch
{
componentProp = property;
}
if (componentProp == null)
{
return DamagedComponentHeight;
}
}
else
{
var fieldType = PropertyType;
if (DragonFieldCahce.RuntimeDict.TryGetValue(fieldType, out var info) && info.HasWrappedFieldName)
{
componentProp = property.FindPropertyRelative(info.WrappedFieldName);
}
}
if (componentProp == null)
{
componentProp = property;
}
{
//EcsDebug.PrintPass(_hasSerializableData);
float result = EditorGUIUtility.singleLineHeight;
if (_hasSerializableData)
{
result = EditorGUI.GetPropertyHeight(componentProp, label);
}
if (IsDrawMetaBlock)
{
result += Padding * 4f;
}
return result;
}
}
protected override void DrawCustom(Rect rect, SerializedProperty property, GUIContent label)
{
if (ReferenceEquals(label, _unrecursiveLabel)) { EditorGUI.PropertyField(rect, property, label, true); return; }
_unrecursiveLabel.text = label.text;
_unrecursiveLabel.tooltip = label.tooltip;
label = _unrecursiveLabel;
if (_isSerializeReference)
{
_hasSerializableData = property.HasSerializableData();
}
//var e = Event.current;
var rootProperty = property;
ITypeMeta meta = null;
SerializedProperty componentProp = property;
bool isDrawProperty = true;
bool isDrawDropDown = IsDrawDropDown && _isSerializeReference;
Rect srcRect = rect;
if (_isSerializeReference)
{
DragonFieldCahce info = null;
bool mrNull = property.IsNullManagedReference();
if (mrNull)
{
isDrawProperty = false;
}
else
{
//var instance = property.managedReferenceValue;
//if (DragonFieldCahce.TryGetInfoFor(instance.GetType(), out info) && info.HasWrappedFieldName)
var type = GetCachedManagedType(property);
if (DragonFieldCahce.TryGetInfoFor(type, out info) && info.HasWrappedFieldName)
{
componentProp = property.FindPropertyRelative(info.WrappedFieldName);
}
}
if (componentProp == null)
{
DrawDamagedComponent(rect, "Damaged component template.");
return;
}
if (meta == null)
{
if (info != null)
{
meta = info.Type.GetMeta();
}
else if (mrNull == false)
{
var type = GetCachedManagedType(property);
meta = type.GetMeta();
}
}
if (isDrawDropDown && mrNull == false && ReferenceDropDownAttribute.IsHideButtonIfNotNull)
{
isDrawDropDown = false;
}
}
else
{
var fieldType = PropertyType;
if (DragonFieldCahce.RuntimeDict.TryGetValue(fieldType, out var info) && info.HasWrappedFieldName)
{
componentProp = property.FindPropertyRelative(info.WrappedFieldName);
}
meta = fieldType.GetMeta();
}
if (componentProp == null)
{
componentProp = property;
}
float selectionButtonRightOffset = 0f;
if (isDrawProperty)
{
if (IsDrawMetaBlock)
{
ref var r = ref rect;
var (skip, optionsWidth) = DragonGUI.DrawTypeMetaBlock(ref r, rootProperty, meta);
selectionButtonRightOffset = optionsWidth;
if (skip)
{
return;
}
if(Event.current.type == EventType.Used)
{
return;
}
}
}
if (isDrawProperty)
{
if (IsArrayElement)
{
label.text = meta.Name;
}
}
if (isDrawDropDown)
{
srcRect.xMax -= selectionButtonRightOffset;
DrawSelectionDropDown(srcRect, property, label);
}
if (isDrawProperty)
{
var fieldRect = rect;
if (ReferenceEquals(property, componentProp) &&
componentProp.propertyType != SerializedPropertyType.Generic &&
componentProp.propertyType != SerializedPropertyType.ManagedReference)
{
fieldRect.xMax -= selectionButtonRightOffset;
isDrawDropDown = false;
}
if (_hasSerializableData)
{
//string oldText = label.text;
//label.text = string.Empty;
EditorGUI.PropertyField(fieldRect, componentProp, label, true);
//label.text = oldText;
}
else
{
EditorGUI.LabelField(rect, label);
}
}
else
{
EditorGUI.LabelField(rect, label);
}
if (isDrawDropDown)
{
DrawFakeSelectionDropDown(srcRect, property, label);
}
}
private void DrawFakeSelectionDropDown(Rect rect, SerializedProperty property, GUIContent label)
{
if (rect.width < 0) { return; }
Rect position;
if (string.IsNullOrEmpty(label.text))
{
position = rect;
}
else
{
position = rect.AddPadding(EditorGUIUtility.labelWidth, 0f, 0f, 0f);
}
position.height = OneLineHeight;
position.y += Spacing * 2;
bool isHideButtonIfNotNull = ReferenceDropDownAttribute.IsHideButtonIfNotNull;
Type type = null;
if (property.IsNullManagedReference() == false &&
property.hasMultipleDifferentValues == false)
{
type = GetCachedManagedType(property);
}
string text = type == null ? "Select..." : type.GetMeta().Name;
if (!isHideButtonIfNotNull || type == null)
{
if (GUI.Button(position, text, EditorStyles.layerMaskField))
{
}
}
}
private void DrawSelectionDropDown(Rect rect, SerializedProperty property, GUIContent label)
{
if (rect.width < 0) { return; }
Rect position;
if (string.IsNullOrEmpty(label.text))
{
position = rect;
}
else
{
position = rect.AddPadding(EditorGUIUtility.labelWidth, 0f, 0f, 0f);
}
position.height = OneLineHeight;
position.y += Spacing * 2;
bool isHideButtonIfNotNull = ReferenceDropDownAttribute.IsHideButtonIfNotNull;
Type type = null;
if (property.IsNullManagedReference() == false &&
property.hasMultipleDifferentValues == false)
{
type = GetCachedManagedType(property);
}
string text = type == null ? "Select..." : type.GetMeta().Name;
if (!isHideButtonIfNotNull || type == null)
{
if (GUI.Button(position, text, EditorStyles.layerMaskField))
{
currentProperty = property;
_dropDown.OpenForField(position, property);
}
}
else
{
GUI.Label(position, text);
}
}
private void DrawDamagedComponent(Rect position, string message)
{
EditorGUI.HelpBox(position, message, MessageType.Warning);
}
}
}
#endif

View File

@ -1,8 +1,8 @@
using UnityEngine;
namespace DCFApixels.DragonECS.Unity
namespace DCFApixels.DragonECS
{
public static class MetaColorExtensions
public static class MetaColorExstensions
{
public static Color ToUnityColor<T>(this T self) where T : IMetaColor
{

View File

@ -0,0 +1,36 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Unity.Editors;
using System;
using UnityEngine;
namespace DCFApixels.DragonECS
{
public sealed class ReferenceButtonAttribute : PropertyAttribute, IReferenceButtonAttribute
{
public readonly Type[] PredicateTypes;
public readonly bool IsHideButtonIfNotNull;
Type[] IReferenceButtonAttribute.PredicateTypes { get { return PredicateTypes; } }
bool IReferenceButtonAttribute.IsHideButtonIfNotNull { get { return IsHideButtonIfNotNull; } }
public ReferenceButtonAttribute(bool isHideButtonIfNotNull = false) : this(isHideButtonIfNotNull, Array.Empty<Type>()) { }
public ReferenceButtonAttribute(params Type[] predicateTypes) : this(false, predicateTypes) { }
public ReferenceButtonAttribute(bool isHideButtonIfNotNull, params Type[] predicateTypes)
{
IsHideButtonIfNotNull = isHideButtonIfNotNull;
PredicateTypes = predicateTypes;
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
}
}
public sealed class ReferenceButtonWithOutAttribute : Attribute
{
public readonly Type[] PredicateTypes;
[Obsolete("With empty parameters, this attribute makes no sense.", true)]
public ReferenceButtonWithOutAttribute() : this(Array.Empty<Type>()) { }
public ReferenceButtonWithOutAttribute(params Type[] predicateTypes)
{
PredicateTypes = predicateTypes;
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
}
}
}