refactor():重构编辑系统,不再需要添加额外的脚本作为可编辑的入口了
This commit is contained in:
23
Assets/Script/Gameplay/Edit/EditableManager.cs
Normal file
23
Assets/Script/Gameplay/Edit/EditableManager.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Core;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Script.Gameplay.Interface;
|
||||
|
||||
namespace Script.Gameplay.Edit
|
||||
{
|
||||
public class EditableManager : MonoSingleton<EditableManager>
|
||||
{
|
||||
public static List<IEditableComponent> GetEditableComponents(GameObject target)
|
||||
{
|
||||
var components = new List<IEditableComponent>();
|
||||
foreach (var mb in target.GetComponentsInChildren<MonoBehaviour>(true))
|
||||
{
|
||||
if (mb is IEditableComponent editableComponent)
|
||||
{
|
||||
components.Add(editableComponent);
|
||||
}
|
||||
}
|
||||
return components;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user