mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
update editor
This commit is contained in:
parent
59e41eb5cd
commit
bdc707dc74
@ -54,23 +54,27 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
//using (prefs.DisableAutoSave())
|
//using (prefs.DisableAutoSave())
|
||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
prefs.IsShowHidden = EditorGUILayout.Toggle(prefs.IsShowHidden, GUILayout.Width(checkBoxWidth));
|
prefs.IsShowHidden = EditorGUILayout.ToggleLeft(
|
||||||
GUILayout.Label(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowHidden)), GUILayout.ExpandWidth(false));
|
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowHidden)),
|
||||||
|
prefs.IsShowHidden);
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
prefs.IsShowInterfaces = EditorGUILayout.Toggle(prefs.IsShowInterfaces, GUILayout.Width(checkBoxWidth));
|
prefs.IsShowInterfaces = EditorGUILayout.ToggleLeft(
|
||||||
GUILayout.Label(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowInterfaces)), GUILayout.ExpandWidth(false));
|
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowInterfaces)),
|
||||||
|
prefs.IsShowInterfaces);
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
prefs.IsShowRuntimeComponents = EditorGUILayout.Toggle(prefs.IsShowRuntimeComponents, GUILayout.Width(checkBoxWidth));
|
prefs.IsShowRuntimeComponents = EditorGUILayout.ToggleLeft(
|
||||||
GUILayout.Label(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowRuntimeComponents)), GUILayout.ExpandWidth(false));
|
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsShowRuntimeComponents)),
|
||||||
|
prefs.IsShowRuntimeComponents);
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
prefs.IsUseCustomNames = EditorGUILayout.Toggle(prefs.IsUseCustomNames, GUILayout.Width(checkBoxWidth));
|
prefs.IsUseCustomNames = EditorGUILayout.ToggleLeft(
|
||||||
GUILayout.Label(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsUseCustomNames)), GUILayout.ExpandWidth(false));
|
UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.IsUseCustomNames)),
|
||||||
|
prefs.IsUseCustomNames);
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
prefs.ComponentColorMode = (ComponentColorMode)EditorGUILayout.EnumPopup(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.ComponentColorMode)), prefs.ComponentColorMode);
|
prefs.ComponentColorMode = (ComponentColorMode)EditorGUILayout.EnumPopup(UnityEditorUtility.TransformFieldName(nameof(UserSettingsPrefs.ComponentColorMode)), prefs.ComponentColorMode);
|
||||||
@ -80,7 +84,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
GUILayout.Space(20f);
|
GUILayout.Space(20f);
|
||||||
using (EcsGUI.SetColor(Color.white * 0.5f))
|
using (EcsGUI.SetColor(Color.white * 0.5f))
|
||||||
|
{
|
||||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||||
|
}
|
||||||
//using (new EcsGUI.ColorScope(Color.white * 1.2f))
|
//using (new EcsGUI.ColorScope(Color.white * 1.2f))
|
||||||
GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f));
|
GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f));
|
||||||
rect = GUILayoutUtility.GetLastRect();
|
rect = GUILayoutUtility.GetLastRect();
|
||||||
@ -95,15 +101,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
var symbol = _defineSymbols[i];
|
var symbol = _defineSymbols[i];
|
||||||
symbol.isOn = EditorGUILayout.Toggle(symbol.isOn, GUILayout.Width(checkBoxWidth));
|
|
||||||
if (symbol.name == "DEBUG")
|
string text = symbol.name == "DEBUG" ? symbol.name + " (Build Olny)" : symbol.name;
|
||||||
{
|
symbol.isOn = EditorGUILayout.ToggleLeft(text, symbol.isOn);
|
||||||
GUILayout.Label(symbol.name + " (Build Olny)", GUILayout.ExpandWidth(false));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GUILayout.Label(symbol.name, GUILayout.ExpandWidth(false));
|
|
||||||
}
|
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
}
|
}
|
||||||
if (EditorGUI.EndChangeCheck()) { }
|
if (EditorGUI.EndChangeCheck()) { }
|
||||||
|
55
src/Internal/CustomToggleAttribute.cs
Normal file
55
src/Internal/CustomToggleAttribute.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS.Unity.Internal
|
||||||
|
{
|
||||||
|
internal class CustomToggleAttribute : PropertyAttribute
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
public bool IsInverted;
|
||||||
|
public bool IsLeft;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
|
{
|
||||||
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
|
using UnityEditor;
|
||||||
|
[CustomPropertyDrawer(typeof(CustomToggleAttribute))]
|
||||||
|
internal class LeftToggleAttributeDrawer : ExtendedPropertyDrawer<CustomToggleAttribute>
|
||||||
|
{
|
||||||
|
protected override void DrawCustom(Rect position, SerializedProperty property, GUIContent label)
|
||||||
|
{
|
||||||
|
if (property.propertyType != SerializedPropertyType.Boolean)
|
||||||
|
{
|
||||||
|
EditorGUI.PropertyField(position, property, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Attribute.Name) == false)
|
||||||
|
{
|
||||||
|
label.text = Attribute.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool value = property.boolValue;
|
||||||
|
if (Attribute.IsInverted)
|
||||||
|
{
|
||||||
|
value = !value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Attribute.IsLeft)
|
||||||
|
{
|
||||||
|
value = EditorGUI.ToggleLeft(position, label, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = EditorGUI.ToggleLeft(position, label, value);
|
||||||
|
|
||||||
|
if (Attribute.IsInverted)
|
||||||
|
{
|
||||||
|
value = !value;
|
||||||
|
}
|
||||||
|
|
||||||
|
property.boolValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
11
src/Internal/CustomToggleAttribute.cs.meta
Normal file
11
src/Internal/CustomToggleAttribute.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fc3766060e046a14f975dcb3b3ffe39c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -268,6 +268,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
public static float EntityBarHeight => EditorGUIUtility.singleLineHeight + 3f;
|
public static float EntityBarHeight => EditorGUIUtility.singleLineHeight + 3f;
|
||||||
|
|
||||||
|
private static float indent => (float)EditorGUI.indentLevel * 15f;
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
private static ComponentColorMode AutoColorMode
|
private static ComponentColorMode AutoColorMode
|
||||||
{
|
{
|
||||||
@ -447,6 +449,18 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//#region One line elems
|
||||||
|
//public static bool LeftToggle(Rect position, GUIContent label, bool value)
|
||||||
|
//{
|
||||||
|
// position = position.AddPadding(indent, 0, 0, 0);
|
||||||
|
// Rect togglePos;
|
||||||
|
// (togglePos, position) = position.HorizontalSliceLeft(18f);
|
||||||
|
//
|
||||||
|
// EditorGUI.togg(position, label);
|
||||||
|
// GUI.Label(position, label);
|
||||||
|
//}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
#region entity bar
|
#region entity bar
|
||||||
public static void EntityBarForAlive(Rect position, EntityStatus status, int id, short gen, short world)
|
public static void EntityBarForAlive(Rect position, EntityStatus status, int id, short gen, short world)
|
||||||
{
|
{
|
||||||
@ -978,6 +992,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
public static void DrawSelectReferenceButton(Rect position, SerializedProperty property, Type[] sortedPredicateTypes, Type[] sortedWithOutTypes, bool isHideButtonIfNotNull)
|
public static void DrawSelectReferenceButton(Rect position, SerializedProperty property, Type[] sortedPredicateTypes, Type[] sortedWithOutTypes, bool isHideButtonIfNotNull)
|
||||||
{
|
{
|
||||||
object obj = property.hasMultipleDifferentValues ? null : property.managedReferenceValue;
|
object obj = property.hasMultipleDifferentValues ? null : property.managedReferenceValue;
|
||||||
|
|
||||||
string text = obj == null ? "Select..." : obj.GetMeta().Name;
|
string text = obj == null ? "Select..." : obj.GetMeta().Name;
|
||||||
if (!isHideButtonIfNotNull || obj == null)
|
if (!isHideButtonIfNotNull || obj == null)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
Rect selButtnoRect = position;
|
Rect selButtnoRect = position;
|
||||||
selButtnoRect.height = OneLineHeight;
|
selButtnoRect.height = OneLineHeight;
|
||||||
DrawSelectionPopupButton(selButtnoRect, property, label);
|
DrawSelectionPopupButton(selButtnoRect, property);
|
||||||
|
|
||||||
if (property.managedReferenceValue != null)
|
if (property.managedReferenceValue != null)
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawSelectionPopupButton(Rect position, SerializedProperty property, GUIContent label)
|
private void DrawSelectionPopupButton(Rect position, SerializedProperty property)
|
||||||
{
|
{
|
||||||
Rect buttonRect = IsArrayElement ? position : position.AddPadding(EditorGUIUtility.labelWidth, 0f, 0f, 0f); ;
|
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);
|
EcsGUI.DrawSelectReferenceButton(buttonRect, property, Attribute.PredicateTypes.Length == 0 ? new Type[1] { fieldInfo.FieldType } : Attribute.PredicateTypes, _withOutTypes, Attribute.IsHideButtonIfNotNull);
|
||||||
|
@ -8,63 +8,6 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS.Unity.Editors
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
{
|
{
|
||||||
[CustomPropertyDrawer(typeof(PipelineTemplateUtility.Record))]
|
|
||||||
internal class PipelineTemplateUtilityRecordDrawer : ExtendedPropertyDrawer
|
|
||||||
{
|
|
||||||
protected override void DrawCustom(Rect position, SerializedProperty property, GUIContent label)
|
|
||||||
{
|
|
||||||
if (IsArrayElement == false)
|
|
||||||
{
|
|
||||||
Rect foldoutRect;
|
|
||||||
(foldoutRect, position) = position.VerticalSliceTop(OneLineHeight + Spacing);
|
|
||||||
property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label);
|
|
||||||
if (property.isExpanded == false)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
using (EcsGUI.SetIndentLevel(IsArrayElement ? EditorGUI.indentLevel : EditorGUI.indentLevel + 1))
|
|
||||||
{
|
|
||||||
Rect subPosition = position;
|
|
||||||
int depth = -1;
|
|
||||||
float height = 0f;
|
|
||||||
|
|
||||||
property.Next(true);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
subPosition.y += height;
|
|
||||||
height = EditorGUI.GetPropertyHeight(property);
|
|
||||||
subPosition.height = height;
|
|
||||||
|
|
||||||
EditorGUI.PropertyField(subPosition, property, true);
|
|
||||||
|
|
||||||
} while (property.NextDepth(false, ref depth));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
|
||||||
{
|
|
||||||
float result = 0f;
|
|
||||||
if (IsArrayElement == false)
|
|
||||||
{
|
|
||||||
result += OneLineHeight;
|
|
||||||
if (property.isExpanded == false)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
property.Next(true);
|
|
||||||
int depth = -1;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
result += EditorGUI.GetPropertyHeight(property, true);
|
|
||||||
} while (property.NextDepth(false, ref depth));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[CustomEditor(typeof(ScriptablePipelineTemplate))]
|
[CustomEditor(typeof(ScriptablePipelineTemplate))]
|
||||||
internal class PipelineTemplateEditorBase : ExtendedEditor<IPipelineTemplate>
|
internal class PipelineTemplateEditorBase : ExtendedEditor<IPipelineTemplate>
|
||||||
{
|
{
|
@ -0,0 +1,66 @@
|
|||||||
|
#if UNITY_EDITOR
|
||||||
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(PipelineTemplateUtility.Record))]
|
||||||
|
internal class PipelineTemplateUtilityRecordDrawer : ExtendedPropertyDrawer
|
||||||
|
{
|
||||||
|
protected override void DrawCustom(Rect position, SerializedProperty property, GUIContent label)
|
||||||
|
{
|
||||||
|
if (IsArrayElement == false)
|
||||||
|
{
|
||||||
|
Rect foldoutRect;
|
||||||
|
(foldoutRect, position) = position.VerticalSliceTop(OneLineHeight + Spacing);
|
||||||
|
property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label);
|
||||||
|
if (property.isExpanded == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using (EcsGUI.SetIndentLevel(IsArrayElement ? EditorGUI.indentLevel : EditorGUI.indentLevel + 1))
|
||||||
|
{
|
||||||
|
Rect subPosition = position;
|
||||||
|
int depth = -1;
|
||||||
|
float height = 0f;
|
||||||
|
|
||||||
|
property.Next(true);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
subPosition.y += height;
|
||||||
|
height = EditorGUI.GetPropertyHeight(property);
|
||||||
|
subPosition.height = height;
|
||||||
|
|
||||||
|
EditorGUI.PropertyField(subPosition, property, true);
|
||||||
|
|
||||||
|
} while (property.NextDepth(false, ref depth));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||||
|
{
|
||||||
|
float result = 0f;
|
||||||
|
if (IsArrayElement == false)
|
||||||
|
{
|
||||||
|
result += OneLineHeight;
|
||||||
|
if (property.isExpanded == false)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
property.Next(true);
|
||||||
|
int depth = -1;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
result += EditorGUI.GetPropertyHeight(property, true);
|
||||||
|
} while (property.NextDepth(false, ref depth));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c96272e4ae45f03408e899323c54d08f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -105,10 +105,13 @@ namespace DCFApixels.DragonECS.Unity
|
|||||||
[ArrayElement]
|
[ArrayElement]
|
||||||
public object target;// нельзя менять поярдок полей, иначе это поломает отрисовку в инспекторе изза применения property.Next(bool);
|
public object target;// нельзя менять поярдок полей, иначе это поломает отрисовку в инспекторе изза применения property.Next(bool);
|
||||||
public AddParams parameters;
|
public AddParams parameters;
|
||||||
public Record(object target, AddParams parameters)
|
[CustomToggle(Name = "Enable", IsLeft = true, IsInverted = true)]
|
||||||
|
public bool disabled;
|
||||||
|
public Record(object target, AddParams parameters, bool disabled)
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
|
this.disabled = disabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,10 +44,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public sealed override void Import(EcsPipeline.Builder b)
|
public sealed override void Import(EcsPipeline.Builder b)
|
||||||
{
|
{
|
||||||
b.Layers.MergeWith(_layers);
|
b.Layers.MergeWith(_layers);
|
||||||
foreach (var s in _records)
|
foreach (var r in _records)
|
||||||
{
|
{
|
||||||
if (s.target == null) { continue; }
|
if (r.target == null || r.disabled) { continue; }
|
||||||
b.Add(s.target, s.parameters);
|
b.Add(r.target, r.parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ namespace DCFApixels.DragonECS
|
|||||||
for (int i = 0; i < _records.Length; i++)
|
for (int i = 0; i < _records.Length; i++)
|
||||||
{
|
{
|
||||||
ref var s = ref template.records[i];
|
ref var s = ref template.records[i];
|
||||||
_records[i] = new Record(s.target, s.parameters);
|
_records[i] = new Record(s.target, s.parameters, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public sealed override void Import(EcsPipeline.Builder b)
|
public sealed override void Import(EcsPipeline.Builder b)
|
||||||
{
|
{
|
||||||
b.Layers.MergeWith(_layers);
|
b.Layers.MergeWith(_layers);
|
||||||
foreach (var s in _records)
|
foreach (var r in _records)
|
||||||
{
|
{
|
||||||
if (s.target == null) { continue; }
|
if (r.target == null || r.disabled) { continue; }
|
||||||
b.Add(s.target, s.parameters);
|
b.Add(r.target, r.parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ namespace DCFApixels.DragonECS
|
|||||||
for (int i = 0; i < _records.Length; i++)
|
for (int i = 0; i < _records.Length; i++)
|
||||||
{
|
{
|
||||||
ref var s = ref template.records[i];
|
ref var s = ref template.records[i];
|
||||||
_records[i] = new Record(s.target, s.parameters);
|
_records[i] = new Record(s.target, s.parameters, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user