mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
add subtemplates for ScriptableEntityTemplate
This commit is contained in:
parent
f9596752bb
commit
a50a1f79fa
@ -30,7 +30,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
internal class ComponentTemplateReferenceDrawer : ExtendedPropertyDrawer<ComponentTemplateReferenceAttribute>
|
internal class ComponentTemplateReferenceDrawer : ExtendedPropertyDrawer<ComponentTemplateReferenceAttribute>
|
||||||
{
|
{
|
||||||
private const float DamagedComponentHeight = 18f * 2f;
|
private const float DamagedComponentHeight = 18f * 2f;
|
||||||
private static readonly Rect HeadIconsRect = new Rect(0f, 0f, 19f, 19f);
|
|
||||||
private static ComponentDropDown _componentDropDown;
|
private static ComponentDropDown _componentDropDown;
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
@ -9,8 +9,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
internal abstract class EntityTemplateEditorBase : ExtendedEditor<IEntityTemplateInternal>
|
internal abstract class EntityTemplateEditorBase : ExtendedEditor<IEntityTemplateInternal>
|
||||||
{
|
{
|
||||||
private static readonly Rect HeadIconsRect = new Rect(0f, 0f, 19f, 19f);
|
|
||||||
|
|
||||||
private ComponentDropDown _componentDropDown;
|
private ComponentDropDown _componentDropDown;
|
||||||
|
|
||||||
private SerializedProperty _componentsProp;
|
private SerializedProperty _componentsProp;
|
||||||
@ -184,12 +182,25 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SerializedProperty iterator = serializedObject.GetIterator();
|
||||||
|
iterator.NextVisible(true);
|
||||||
|
while (iterator.NextVisible(false))
|
||||||
|
{
|
||||||
|
if (iterator.name == _componentsProp.name)
|
||||||
|
{
|
||||||
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
|
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
|
||||||
{
|
{
|
||||||
DrawTop(Target, _componentsProp);
|
DrawTop(Target, _componentsProp);
|
||||||
_reorderableComponentsList.DoLayoutList();
|
_reorderableComponentsList.DoLayoutList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EditorGUILayout.PropertyField(iterator, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private void DrawTop(IEntityTemplateInternal target, SerializedProperty componentsProp)
|
private void DrawTop(IEntityTemplateInternal target, SerializedProperty componentsProp)
|
||||||
{
|
{
|
||||||
GUILayout.Space(2f);
|
GUILayout.Space(2f);
|
||||||
|
@ -20,6 +20,8 @@ namespace DCFApixels.DragonECS
|
|||||||
[MetaID("DragonECS_7C4DBA809201D959401A5BDFB6363EC0")]
|
[MetaID("DragonECS_7C4DBA809201D959401A5BDFB6363EC0")]
|
||||||
public class ScriptableEntityTemplate : ScriptableEntityTemplateBase, IEntityTemplateInternal
|
public class ScriptableEntityTemplate : ScriptableEntityTemplateBase, IEntityTemplateInternal
|
||||||
{
|
{
|
||||||
|
[SerializeField]
|
||||||
|
private ScriptableEntityTemplateBase[] _templates;
|
||||||
[SerializeReference]
|
[SerializeReference]
|
||||||
[ReferenceButton(true, typeof(IComponentTemplate))]
|
[ReferenceButton(true, typeof(IComponentTemplate))]
|
||||||
private IComponentTemplate[] _components;
|
private IComponentTemplate[] _components;
|
||||||
@ -34,6 +36,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Methods
|
#region Methods
|
||||||
public override void Apply(short worldID, int entityID)
|
public override void Apply(short worldID, int entityID)
|
||||||
{
|
{
|
||||||
|
foreach (var template in _templates)
|
||||||
|
{
|
||||||
|
template.Apply(worldID, entityID);
|
||||||
|
}
|
||||||
foreach (var item in _components)
|
foreach (var item in _components)
|
||||||
{
|
{
|
||||||
item.Apply(worldID, entityID);
|
item.Apply(worldID, entityID);
|
||||||
|
Loading…
Reference in New Issue
Block a user