mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
Update Editors
This commit is contained in:
parent
461c626ed3
commit
d5f6295e59
@ -1,63 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public class DragonEcsRootUnity : MonoBehaviour
|
||||
{
|
||||
[SerializeReference]
|
||||
[ReferenceButton(false, typeof(IEcsModule))]
|
||||
//[ArrayElement]
|
||||
private IEcsModule _module = new MonoBehaviourSystemWrapper();
|
||||
[SerializeField]
|
||||
private AddParams _parameters;
|
||||
|
||||
private EcsPipeline _pipeline;
|
||||
|
||||
public IEcsModule Module
|
||||
{
|
||||
get { return _module; }
|
||||
}
|
||||
public AddParams AddParams
|
||||
{
|
||||
get { return _parameters; }
|
||||
}
|
||||
public EcsPipeline Pipeline
|
||||
{
|
||||
get { return _pipeline; }
|
||||
}
|
||||
public bool IsInit
|
||||
{
|
||||
get { return _pipeline != null && _pipeline.IsInit; }
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_pipeline = EcsPipeline.New().AddModule(_module, _parameters).BuildAndInit();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_pipeline.Run();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
_pipeline.LateRun();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
_pipeline.FixedRun();
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
_pipeline?.DrawGizmos();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_pipeline.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
124
src/Buildin/EcsRootUnity.cs
Normal file
124
src/Buildin/EcsRootUnity.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu(EcsConsts.FRAMEWORK_NAME + "/" + nameof(EcsRootUnity), 30)]
|
||||
public class EcsRootUnity : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private ScriptablePipelineTemplateBase[] _scriptableTemplates;
|
||||
[SerializeField]
|
||||
private MonoPipelineTemplateBase[] _monoTemplates;
|
||||
|
||||
private EcsPipeline _pipeline;
|
||||
|
||||
public IEnumerable<ScriptablePipelineTemplateBase> ScriptableTemplates
|
||||
{
|
||||
get { return _scriptableTemplates; }
|
||||
}
|
||||
public IEnumerable<MonoPipelineTemplateBase> MonoTemplates
|
||||
{
|
||||
get { return _monoTemplates; }
|
||||
}
|
||||
public EcsPipeline Pipeline
|
||||
{
|
||||
get { return _pipeline; }
|
||||
}
|
||||
public bool IsInit
|
||||
{
|
||||
get { return _pipeline != null && _pipeline.IsInit; }
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var pipelineBuilder = EcsPipeline.New();
|
||||
foreach (var template in _scriptableTemplates)
|
||||
{
|
||||
if (template == null) { continue; }
|
||||
pipelineBuilder.Add(template);
|
||||
}
|
||||
foreach (var template in _monoTemplates)
|
||||
{
|
||||
if (template == null) { continue; }
|
||||
pipelineBuilder.Add(template);
|
||||
}
|
||||
_pipeline = pipelineBuilder.BuildAndInit();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_pipeline.Run();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
_pipeline.LateRun();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
_pipeline.FixedRun();
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
_pipeline?.DrawGizmos();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_pipeline.Destroy();
|
||||
}
|
||||
|
||||
#region Editor
|
||||
#if UNITY_EDITOR
|
||||
[ContextMenu("Autoset")]
|
||||
internal void Autoset_Editor()
|
||||
{
|
||||
Autoset(this);
|
||||
}
|
||||
[ContextMenu("Validate")]
|
||||
internal void Validate_Editor()
|
||||
{
|
||||
_scriptableTemplates = _scriptableTemplates.Where(o => o != null).ToArray();
|
||||
_monoTemplates = _monoTemplates.Where(o => o != null).ToArray();
|
||||
EditorUtility.SetDirty(this);
|
||||
}
|
||||
|
||||
private static void Autoset(EcsRootUnity target)
|
||||
{
|
||||
IEnumerable<MonoPipelineTemplateBase> result;
|
||||
if (target.MonoTemplates != null && target.MonoTemplates.Count() > 0)
|
||||
{
|
||||
result = target.MonoTemplates.Where(o => o != null).Union(GetTemplatesFor(target.transform));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = GetTemplatesFor(target.transform);
|
||||
}
|
||||
|
||||
target._monoTemplates = result.ToArray();
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
private static IEnumerable<MonoPipelineTemplateBase> GetTemplatesFor(Transform parent)
|
||||
{
|
||||
IEnumerable<MonoPipelineTemplateBase> result = parent.GetComponents<MonoPipelineTemplateBase>();
|
||||
for (int i = 0; i < parent.childCount; i++)
|
||||
{
|
||||
var child = parent.GetChild(i);
|
||||
if (child.TryGetComponent<EcsRootUnity>(out _))
|
||||
{
|
||||
return Enumerable.Empty<MonoPipelineTemplateBase>();
|
||||
}
|
||||
result = result.Concat(GetTemplatesFor(child));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
8
src/Buildin/Editor.meta
Normal file
8
src/Buildin/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a05eab751afe96d408cfe00ba94603f1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
128
src/Buildin/Editor/EcsRootUnityEditor.cs
Normal file
128
src/Buildin/Editor/EcsRootUnityEditor.cs
Normal file
@ -0,0 +1,128 @@
|
||||
#if UNITY_EDITOR
|
||||
using DCFApixels.DragonECS.Unity.Internal;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
[CustomEditor(typeof(EcsRootUnity))]
|
||||
internal class EcsRootUnityEditor : ExtendedEditor<EcsRootUnity>
|
||||
{
|
||||
protected override void DrawCustom()
|
||||
{
|
||||
DrawStatus();
|
||||
DrawTemplates();
|
||||
DrawControlButtons();
|
||||
}
|
||||
|
||||
|
||||
private enum Status
|
||||
{
|
||||
Undefined,
|
||||
NotInitialized,
|
||||
Disable,
|
||||
Run,
|
||||
}
|
||||
private Status GetStatus(EcsRootUnity target)
|
||||
{
|
||||
Status status;
|
||||
if (target.IsInit)
|
||||
{
|
||||
status = Target.enabled ? Status.Run : Status.Disable;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = Status.NotInitialized;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
private void DrawStatus()
|
||||
{
|
||||
Status status = GetStatus(Target);
|
||||
|
||||
if (IsMultipleTargets)
|
||||
{
|
||||
foreach (var target in Targets)
|
||||
{
|
||||
if (status != GetStatus(target))
|
||||
{
|
||||
status = Status.Undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Color color = default;
|
||||
string text = default;
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case Status.Undefined:
|
||||
color = Color.gray;
|
||||
text = "-";
|
||||
break;
|
||||
case Status.NotInitialized:
|
||||
color = Color.red;
|
||||
text = "Not Initialized";
|
||||
break;
|
||||
case Status.Disable:
|
||||
color = Color.yellow;
|
||||
text = "Disable";
|
||||
break;
|
||||
case Status.Run:
|
||||
color = Color.green;
|
||||
text = "Run";
|
||||
break;
|
||||
}
|
||||
|
||||
Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
EditorGUI.DrawRect(rect, color.SetAlpha(0.2f));
|
||||
GUI.Label(rect, text);
|
||||
}
|
||||
|
||||
private void DrawTemplates()
|
||||
{
|
||||
using (EcsGUI.CheckChanged())
|
||||
{
|
||||
var iterator = serializedObject.GetIterator();
|
||||
iterator.NextVisible(true);
|
||||
while (iterator.NextVisible(false))
|
||||
{
|
||||
EditorGUILayout.PropertyField(iterator, true);
|
||||
}
|
||||
|
||||
if (EcsGUI.Changed)
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void DrawControlButtons()
|
||||
{
|
||||
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 (EcsGUI.ValidateButton(buttonRect))
|
||||
{
|
||||
foreach (var target in Targets)
|
||||
{
|
||||
target.Validate_Editor();
|
||||
}
|
||||
}
|
||||
buttonRect = RectUtility.Move(buttonRect, -height, 0);
|
||||
if (EcsGUI.AutosetButton(buttonRect))
|
||||
{
|
||||
foreach (var target in Targets)
|
||||
{
|
||||
target.Autoset_Editor();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
src/Buildin/Editor/EcsRootUnityEditor.cs.meta
Normal file
11
src/Buildin/Editor/EcsRootUnityEditor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e88d839647795145973d4327272c6e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -50,6 +50,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("13DAACF9910155DD27F822442987E0AE")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, OTHER_GROUP)]
|
||||
[MetaDescription(AUTHOR, "Template for UnityComponent<T>")]
|
||||
public abstract class UnityComponentTemplate<T> : ComponentTemplateBase<UnityComponent<T>> where T : Component
|
||||
{
|
||||
public override string Name
|
||||
@ -81,24 +82,28 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("843B8EF991013F1BFD9133437E1AFE9C")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentTransformTemplate : UnityComponentTemplate<Transform> { }
|
||||
[Serializable]
|
||||
[MetaTags(MetaTags.HIDDEN)]
|
||||
[MetaID("9A4B8EF99101396C44BF789C3215E9A9")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentRigitBodyInitializer : UnityComponentTemplate<Rigidbody> { }
|
||||
[Serializable]
|
||||
[MetaTags(MetaTags.HIDDEN)]
|
||||
[MetaID("52598EF991016655335F234F20F44526")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentAnimatorInitializer : UnityComponentTemplate<Animator> { }
|
||||
[Serializable]
|
||||
[MetaTags(MetaTags.HIDDEN)]
|
||||
[MetaID("AD658EF99101E8E38BB575D5353E7B1E")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentCharacterControllerInitializer : UnityComponentTemplate<CharacterController> { }
|
||||
#endregion
|
||||
|
||||
@ -108,6 +113,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("6C6CA0F99101E80E013BCCCB5DA78FA5")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentMeshRendererTemplate : UnityComponentTemplate<MeshRenderer>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.RenderGroup; } }
|
||||
@ -117,6 +123,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("5475A1F9910109A138F609268B697A62")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentMeshFilterTemplate : UnityComponentTemplate<MeshFilter>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.RenderGroup; } }
|
||||
@ -126,6 +133,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("2C13A2F99101FAA3EA21BD351BF3B169")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentSkinnedMeshRendererTemplate : UnityComponentTemplate<SkinnedMeshRenderer>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.RenderGroup; } }
|
||||
@ -135,6 +143,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("8B57A1F991016B2E1FC57D16F2D20A64")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentSpriteRendererTemplate : UnityComponentTemplate<SpriteRenderer>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.RenderGroup; } }
|
||||
@ -147,6 +156,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("557F8EF9910132FE990CF50CBF368412")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentColliderTemplate : UnityComponentTemplate<Collider>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.ColliderGroup; } }
|
||||
@ -156,6 +166,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("43669CF99101E94AB9EC19DC8EA3878B")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentBoxColliderTemplate : UnityComponentTemplate<BoxCollider>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.ColliderGroup; } }
|
||||
@ -165,6 +176,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("749F9CF991017792E288D4E3B5BFE340")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentSphereColliderTemplate : UnityComponentTemplate<SphereCollider>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.ColliderGroup; } }
|
||||
@ -174,6 +186,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("72B09CF99101A33EBC4410B0FD8375E0")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentCapsuleColliderTemplate : UnityComponentTemplate<CapsuleCollider>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.ColliderGroup; } }
|
||||
@ -183,6 +196,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("3BBC9CF99101F7C00989D2E55A40EF1B")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentMeshColliderTemplate : UnityComponentTemplate<MeshCollider>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.ColliderGroup; } }
|
||||
@ -195,6 +209,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("1AC79CF99101C4279852BB6AE12DC61B")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentJointTemplate : UnityComponentTemplate<Joint>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.JointGroup; } }
|
||||
@ -204,6 +219,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("E3D99CF991016428C6688672052C6F4E")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentFixedJointTemplate : UnityComponentTemplate<FixedJoint>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.JointGroup; } }
|
||||
@ -213,6 +229,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("7BE59CF99101322AE307229E1466B225")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentCharacterJointTemplate : UnityComponentTemplate<CharacterJoint>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.JointGroup; } }
|
||||
@ -222,6 +239,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("FBF29CF99101EE07543CFF460854B1F6")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, TEMPLATES_GROUP)]
|
||||
[MetaDescription(AUTHOR, "...")]
|
||||
public sealed class UnityComponentConfigurableJointTemplate : UnityComponentTemplate<ConfigurableJoint>
|
||||
{
|
||||
public override MetaGroup Group { get { return UnityComponentConsts.JointGroup; } }
|
||||
|
@ -3,11 +3,13 @@ using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
using static EcsConsts;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu(EcsConsts.FRAMEWORK_NAME + "/" + nameof(AutoEntityCreator), 30)]
|
||||
[AddComponentMenu(FRAMEWORK_NAME + "/" + nameof(AutoEntityCreator), 30)]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsUnityConsts.ENTITY_BUILDING_GROUP)]
|
||||
[MetaDescription(EcsConsts.AUTHOR, nameof(MonoBehaviour) + ". Automatically creates an entity in the selected world and connects it to EcsEntityConnect.")]
|
||||
[MetaDescription(AUTHOR, nameof(MonoBehaviour) + ". Automatically creates an entity in the selected world and connects it to EcsEntityConnect.")]
|
||||
[MetaID("D699B3809201285A46DDF91BCF0540A7")]
|
||||
public class AutoEntityCreator : MonoBehaviour
|
||||
{
|
||||
|
@ -10,6 +10,8 @@ using UnityEditor;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
using static EcsConsts;
|
||||
|
||||
public static class EcsConnect
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@ -56,10 +58,10 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
[SelectionBase]
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu(EcsConsts.FRAMEWORK_NAME + "/" + nameof(EcsEntityConnect), 30)]
|
||||
[AddComponentMenu(FRAMEWORK_NAME + "/" + nameof(EcsEntityConnect), 30)]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsUnityConsts.ENTITY_BUILDING_GROUP)]
|
||||
[MetaDescription(EcsConsts.AUTHOR, nameof(MonoBehaviour) + ". Responsible for connecting the entity and GameObject using the EcsEntityConnect.ConnectWith method.")]
|
||||
[MetaDescription(AUTHOR, nameof(MonoBehaviour) + ". Responsible for connecting the entity and GameObject using the EcsEntityConnect.ConnectWith method.")]
|
||||
[MetaID("FF7EB3809201DEC2F1977C00D3B3443B")]
|
||||
public class EcsEntityConnect : MonoBehaviour
|
||||
{
|
||||
@ -210,7 +212,6 @@ namespace DCFApixels.DragonECS
|
||||
internal void Autoset_Editor()
|
||||
{
|
||||
Autoset(this);
|
||||
|
||||
}
|
||||
[ContextMenu("Autoset Cascade")]
|
||||
internal void AutosetCascade_Editor()
|
||||
|
@ -11,20 +11,15 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
protected override void DrawCustom()
|
||||
{
|
||||
EcsEntityConnect[] targets = new EcsEntityConnect[this.targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
targets[i] = (EcsEntityConnect)this.targets[i];
|
||||
}
|
||||
DrawEntityInfo(targets);
|
||||
DrawEntityInfo();
|
||||
|
||||
DrawTemplates();
|
||||
|
||||
DrawControlButtons(targets);
|
||||
DrawComponents(targets);
|
||||
DrawControlButtons();
|
||||
DrawComponents();
|
||||
}
|
||||
|
||||
private void DrawEntityInfo(EcsEntityConnect[] targets)
|
||||
private void DrawEntityInfo()
|
||||
{
|
||||
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;
|
||||
@ -49,7 +44,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawControlButtons(EcsEntityConnect[] targets)
|
||||
private void DrawControlButtons()
|
||||
{
|
||||
float height = EcsGUI.EntityBarHeight;
|
||||
Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height);
|
||||
@ -58,7 +53,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
var (_, buttonRect) = rect.HorizontalSliceRight(height);
|
||||
if (EcsGUI.AutosetCascadeButton(buttonRect))
|
||||
{
|
||||
foreach (var target in targets)
|
||||
foreach (var target in Targets)
|
||||
{
|
||||
target.AutosetCascade_Editor();
|
||||
}
|
||||
@ -66,7 +61,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
buttonRect = RectUtility.Move(buttonRect, -height, 0);
|
||||
if (EcsGUI.AutosetButton(buttonRect))
|
||||
{
|
||||
foreach (var target in targets)
|
||||
foreach (var target in Targets)
|
||||
{
|
||||
target.Autoset_Editor();
|
||||
}
|
||||
@ -76,7 +71,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
buttonRect = buttonRect.Move(-height, 0);
|
||||
if (EcsGUI.DelEntityButton(buttonRect))
|
||||
{
|
||||
foreach (var target in targets)
|
||||
foreach (var target in Targets)
|
||||
{
|
||||
target.DeleteEntity_Editor();
|
||||
}
|
||||
@ -84,7 +79,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
buttonRect = buttonRect.Move(-height, 0);
|
||||
if (EcsGUI.UnlinkButton(buttonRect))
|
||||
{
|
||||
foreach (var target in targets)
|
||||
foreach (var target in Targets)
|
||||
{
|
||||
target.UnlinkEntity_Editor();
|
||||
}
|
||||
@ -92,13 +87,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawComponents(EcsEntityConnect[] targets)
|
||||
private void DrawComponents()
|
||||
{
|
||||
if (IsMultipleTargets)
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
for (int i = 0; i < Targets.Length; i++)
|
||||
{
|
||||
if (targets[i].IsConnected == true)
|
||||
if (Targets[i].IsConnected == true)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Multiple component editing is not available.", MessageType.Warning);
|
||||
return;
|
||||
|
@ -424,6 +424,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
return click;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ValidateButton(Rect position)
|
||||
{
|
||||
return IconButton(position, Icons.Instance.RepaireIcon, 2f, "Validate");
|
||||
}
|
||||
public static bool AutosetCascadeButton(Rect position)
|
||||
{
|
||||
return IconButton(position, Icons.Instance.AutosetCascadeIcon, 0f, "Autoset Cascade");
|
||||
|
@ -12,6 +12,8 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
||||
private Texture _fileIcon = null;
|
||||
[SerializeField]
|
||||
private Texture _metaIDIcon = null;
|
||||
[SerializeField]
|
||||
private Texture _repaireIcon = null;
|
||||
|
||||
[SerializeField]
|
||||
private Texture _errorIcon = null;
|
||||
@ -45,6 +47,7 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
||||
internal Texture HelpIcon { get { return _helpIcon; } }
|
||||
internal Texture FileIcon { get { return _fileIcon; } }
|
||||
internal Texture MetaIDIcon { get { return _metaIDIcon; } }
|
||||
internal Texture RepaireIcon { get { return _repaireIcon; } }
|
||||
|
||||
internal Texture ErrorIcon { get { return _errorIcon; } }
|
||||
internal Texture WarningIcon { get { return _warningIcon; } }
|
||||
|
@ -7,6 +7,7 @@ MonoImporter:
|
||||
- _helpIcon: {fileID: 2800000, guid: e135cf23a5d53ce48a75e163b41e39d5, type: 3}
|
||||
- _fileIcon: {fileID: 2800000, guid: 4f1ca6aa9d407844485856184c785946, type: 3}
|
||||
- _metaIDIcon: {fileID: 2800000, guid: d3c6215cfdc36cb448661398160560a7, type: 3}
|
||||
- _repaireIcon: {fileID: 2800000, guid: 561fcfb28d73d7c4f8c9fac36e8ece86, type: 3}
|
||||
- _errorIcon: {fileID: 2800000, guid: c67e8a1d6cb0e904590c7847368fe794, type: 3}
|
||||
- _warningIcon: {fileID: 2800000, guid: 223d96e24d4b49f468b628cf9839584c, type: 3}
|
||||
- _passIcon: {fileID: 2800000, guid: 0df5856dbbe53494aae23b959ca05ecc, type: 3}
|
||||
|
BIN
src/Internal/Icons/RepaireIcon.png
Normal file
BIN
src/Internal/Icons/RepaireIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
122
src/Internal/Icons/RepaireIcon.png.meta
Normal file
122
src/Internal/Icons/RepaireIcon.png.meta
Normal file
@ -0,0 +1,122 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 561fcfb28d73d7c4f8c9fac36e8ece86
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 32
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -15,6 +15,7 @@ MonoBehaviour:
|
||||
_helpIcon: {fileID: 2800000, guid: e135cf23a5d53ce48a75e163b41e39d5, type: 3}
|
||||
_fileIcon: {fileID: 2800000, guid: 4f1ca6aa9d407844485856184c785946, type: 3}
|
||||
_metaIDIcon: {fileID: 2800000, guid: d3c6215cfdc36cb448661398160560a7, type: 3}
|
||||
_repaireIcon: {fileID: 2800000, guid: 561fcfb28d73d7c4f8c9fac36e8ece86, type: 3}
|
||||
_errorIcon: {fileID: 2800000, guid: c67e8a1d6cb0e904590c7847368fe794, type: 3}
|
||||
_warningIcon: {fileID: 2800000, guid: 223d96e24d4b49f468b628cf9839584c, type: 3}
|
||||
_passIcon: {fileID: 2800000, guid: 0df5856dbbe53494aae23b959ca05ecc, type: 3}
|
||||
|
@ -68,6 +68,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
[CustomEditor(typeof(ScriptablePipelineTemplate))]
|
||||
internal class PipelineTemplateEditorBase : ExtendedEditor<IPipelineTemplate>
|
||||
{
|
||||
private SerializedProperty _parametersProp;
|
||||
private SerializedProperty _layersProp;
|
||||
private SerializedProperty _recordsProp;
|
||||
private ReorderableList _reorderableLayersList;
|
||||
@ -82,6 +83,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
protected override void OnStaticInit() { }
|
||||
protected override void OnInit()
|
||||
{
|
||||
_parametersProp = FindProperty("_parameters");
|
||||
_layersProp = FindProperty("_layers");
|
||||
_recordsProp = FindProperty("_records");
|
||||
|
||||
@ -200,6 +202,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
EcsGUI.Changed = GUILayout.Button("Validate");
|
||||
|
||||
EditorGUILayout.PropertyField(_parametersProp, UnityEditorUtility.GetLabel(_parametersProp.displayName));
|
||||
DrawLayoutNameList(_layersProp);
|
||||
DrawRecordList(_recordsProp);
|
||||
|
||||
|
@ -3,11 +3,13 @@ using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
using static EcsConsts;
|
||||
|
||||
[MetaName("MonoBehaviourSystem")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaDescription("Wrapper for MonoBehaviour systems")]
|
||||
[MetaDescription(AUTHOR, "Wrapper for MonoBehaviour systems")]
|
||||
[MetaID("2877029E9201347B4F58E1EC0A4BCD1B")]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, OTHER_GROUP)]
|
||||
public class MonoBehaviourSystemWrapper : IEcsModule
|
||||
{
|
||||
public MonoBehaviour system;
|
||||
|
@ -3,11 +3,13 @@ using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
using static EcsConsts;
|
||||
|
||||
[MetaName("ScriptableObjectSystem")]
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaDescription("Wrapper for ScriptableObject systems")]
|
||||
[MetaDescription(AUTHOR, "Wrapper for ScriptableObject systems")]
|
||||
[MetaID("F5A94C5F92015B4D9286E76809311AF4")]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, OTHER_GROUP)]
|
||||
public class ScriptableObjectSystemWrapper : IEcsModule
|
||||
{
|
||||
public ScriptableObject system;
|
||||
|
@ -15,12 +15,15 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu(EcsConsts.FRAMEWORK_NAME + "/" + nameof(MonoPipelineTemplate), 30)]
|
||||
public class MonoPipelineTemplate : MonoPipelineTemplateBase, IPipelineTemplate
|
||||
public class MonoPipelineTemplate : MonoPipelineTemplateBase, IPipelineTemplate, IEcsDefaultAddParams
|
||||
{
|
||||
[SerializeField]
|
||||
[ArrayElement]
|
||||
private string[] _layers = DefaultLayers.ToArray();
|
||||
|
||||
[SerializeField]
|
||||
private AddParams _parameters;
|
||||
|
||||
[SerializeField]
|
||||
[ArrayElement]
|
||||
private Record[] _records;
|
||||
@ -29,6 +32,10 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
get { return _layers; }
|
||||
}
|
||||
public AddParams AddParams
|
||||
{
|
||||
get { return _parameters; }
|
||||
}
|
||||
public ReadOnlySpan<Record> Records
|
||||
{
|
||||
get { return _records; }
|
||||
@ -56,6 +63,7 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("Validate")]
|
||||
public bool Validate()
|
||||
{
|
||||
bool resutl = ValidateLayers(ref _layers);
|
||||
|
@ -14,12 +14,15 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
|
||||
[CreateAssetMenu(fileName = nameof(ScriptablePipelineTemplate), menuName = EcsConsts.FRAMEWORK_NAME + "/" + nameof(ScriptablePipelineTemplate), order = 1)]
|
||||
public sealed class ScriptablePipelineTemplate : ScriptablePipelineTemplateBase, IPipelineTemplate
|
||||
public sealed class ScriptablePipelineTemplate : ScriptablePipelineTemplateBase, IPipelineTemplate, IEcsDefaultAddParams
|
||||
{
|
||||
[SerializeField]
|
||||
[ArrayElement]
|
||||
private string[] _layers = DefaultLayers.ToArray();
|
||||
|
||||
[SerializeField]
|
||||
private AddParams _parameters;
|
||||
|
||||
[SerializeField]
|
||||
[ArrayElement]
|
||||
private Record[] _records;
|
||||
@ -28,6 +31,10 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
get { return _layers; }
|
||||
}
|
||||
public AddParams AddParams
|
||||
{
|
||||
get { return _parameters; }
|
||||
}
|
||||
public ReadOnlySpan<Record> Records
|
||||
{
|
||||
get { return _records; }
|
||||
@ -55,6 +62,7 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("Validate")]
|
||||
public bool Validate()
|
||||
{
|
||||
bool resutl = ValidateLayers(ref _layers);
|
||||
|
Loading…
Reference in New Issue
Block a user