mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 17:34:34 +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>
|
||||
{
|
||||
private const float DamagedComponentHeight = 18f * 2f;
|
||||
private static readonly Rect HeadIconsRect = new Rect(0f, 0f, 19f, 19f);
|
||||
private static ComponentDropDown _componentDropDown;
|
||||
|
||||
#region Properties
|
||||
|
@ -9,8 +9,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
internal abstract class EntityTemplateEditorBase : ExtendedEditor<IEntityTemplateInternal>
|
||||
{
|
||||
private static readonly Rect HeadIconsRect = new Rect(0f, 0f, 19f, 19f);
|
||||
|
||||
private ComponentDropDown _componentDropDown;
|
||||
|
||||
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()))
|
||||
{
|
||||
DrawTop(Target, _componentsProp);
|
||||
_reorderableComponentsList.DoLayoutList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(iterator, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DrawTop(IEntityTemplateInternal target, SerializedProperty componentsProp)
|
||||
{
|
||||
GUILayout.Space(2f);
|
||||
|
@ -20,6 +20,8 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("DragonECS_7C4DBA809201D959401A5BDFB6363EC0")]
|
||||
public class ScriptableEntityTemplate : ScriptableEntityTemplateBase, IEntityTemplateInternal
|
||||
{
|
||||
[SerializeField]
|
||||
private ScriptableEntityTemplateBase[] _templates;
|
||||
[SerializeReference]
|
||||
[ReferenceButton(true, typeof(IComponentTemplate))]
|
||||
private IComponentTemplate[] _components;
|
||||
@ -34,6 +36,10 @@ namespace DCFApixels.DragonECS
|
||||
#region Methods
|
||||
public override void Apply(short worldID, int entityID)
|
||||
{
|
||||
foreach (var template in _templates)
|
||||
{
|
||||
template.Apply(worldID, entityID);
|
||||
}
|
||||
foreach (var item in _components)
|
||||
{
|
||||
item.Apply(worldID, entityID);
|
||||
|
Loading…
Reference in New Issue
Block a user