mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 10:04:36 +08:00
add MetaIDAttribute
This commit is contained in:
parent
c12fe06b2d
commit
2410f36e7e
@ -32,16 +32,16 @@ namespace DCFApixels.DragonECS.Unity.Docs
|
||||
Array.Sort(array);
|
||||
return new DragonDocs(array);
|
||||
}
|
||||
|
||||
private static List<Type> GetTypes()
|
||||
{
|
||||
Type metaAttributeType = typeof(EcsMetaAttribute);
|
||||
Type memberType = typeof(IEcsMember);
|
||||
List<Type> result = new List<Type>(512);
|
||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
foreach (var type in assembly.GetTypes())
|
||||
{
|
||||
if ((type.IsInterface == false && type.IsAbstract == false && memberType.IsAssignableFrom(type)) || Attribute.GetCustomAttributes(type, metaAttributeType, false).Length > 1)
|
||||
if (TypeMeta.IsHasMeta(type))
|
||||
{
|
||||
result.Add(type);
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ namespace DCFApixels.DragonECS.Unity.Docs
|
||||
[DataMember, SerializeField] internal string _group = string.Empty;
|
||||
[DataMember, SerializeField] internal string[] _tags = Array.Empty<string>();
|
||||
|
||||
[DataMember, SerializeField] internal string _metaID = string.Empty;
|
||||
|
||||
[DataMember, SerializeField] internal bool _isHidden = false;
|
||||
|
||||
|
||||
@ -72,6 +74,10 @@ namespace DCFApixels.DragonECS.Unity.Docs
|
||||
{
|
||||
get { return _tags; }
|
||||
}
|
||||
public string MetaID
|
||||
{
|
||||
get { return _metaID; }
|
||||
}
|
||||
public bool IsHidden
|
||||
{
|
||||
get { return _isHidden; }
|
||||
@ -107,6 +113,8 @@ namespace DCFApixels.DragonECS.Unity.Docs
|
||||
_tags[i] = meta.Tags[i];
|
||||
}
|
||||
|
||||
_metaID = meta.MetaID;
|
||||
|
||||
_isHidden = meta.IsHidden;
|
||||
}
|
||||
|
||||
|
@ -246,58 +246,76 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
|
||||
Color alphaPanelColor = panelColor;
|
||||
alphaPanelColor.a = EscEditorConsts.COMPONENT_DRAWER_ALPHA;
|
||||
|
||||
GUILayout.BeginVertical(UnityEditorUtility.GetStyle(alphaPanelColor));
|
||||
GUILayout.Space(1f);
|
||||
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(alphaPanelColor)))
|
||||
{
|
||||
GUILayout.Space(1f);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.TextArea(IsUseCustomNames ? meta.Name : meta.TypeName, EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
|
||||
if (meta.TryGetSourceType(out System.Type targetType) && UnityEditorUtility.TryGetScriptAsset(targetType, out MonoScript script))
|
||||
{
|
||||
EcsGUI.Layout.ScriptAssetButton(script, GUILayout.Width(19f));
|
||||
}
|
||||
if (meta.IsCustomName)
|
||||
{
|
||||
using (EcsGUI.SetAlpha(0.64f)) using (EcsGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleRight))
|
||||
//draw title block
|
||||
using (EcsGUI.Layout.BeginHorizontal())
|
||||
{
|
||||
GUILayout.TextArea(IsUseCustomNames ? meta.TypeName : meta.Name, GUI.skin.label);
|
||||
GUILayout.TextArea(IsUseCustomNames ? meta.Name : meta.TypeName, EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
|
||||
if (meta.TryGetSourceType(out System.Type targetType) && UnityEditorUtility.TryGetScriptAsset(targetType, out MonoScript script))
|
||||
{
|
||||
EcsGUI.Layout.ScriptAssetButton(script, GUILayout.Width(19f));
|
||||
}
|
||||
if (meta.IsCustomName)
|
||||
{
|
||||
using (EcsGUI.SetAlpha(0.64f)) using (EcsGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleRight))
|
||||
{
|
||||
GUILayout.TextArea(IsUseCustomNames ? meta.TypeName : meta.Name, GUI.skin.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
Rect lastRect = GUILayoutUtility.GetLastRect();
|
||||
if (string.IsNullOrEmpty(meta.Description) == false)
|
||||
{
|
||||
Rect lineRect = lastRect;
|
||||
lineRect.yMin = lineRect.yMax;
|
||||
lineRect.yMax += 1f;
|
||||
lineRect.y += 5f;
|
||||
EditorGUI.DrawRect(lineRect, new Color(1, 1, 1, 0.12f));
|
||||
|
||||
GUILayout.Space(7f);
|
||||
|
||||
GUILayout.TextArea(meta.Description, EditorStyles.wordWrappedLabel);
|
||||
}
|
||||
|
||||
if (meta._tags.Length > 0)
|
||||
{
|
||||
Rect lineRect = GUILayoutUtility.GetLastRect();
|
||||
lineRect.yMin = lineRect.yMax;
|
||||
lineRect.yMax += 1f;
|
||||
lineRect.y += 5f;
|
||||
EditorGUI.DrawRect(lineRect, new Color(1, 1, 1, 0.12f));
|
||||
|
||||
GUILayout.Space(3f);
|
||||
|
||||
var tagsstring = string.Join(',', meta._tags);
|
||||
using (EcsGUI.SetAlpha(0.5f))
|
||||
//draw description block
|
||||
Rect lastRect = GUILayoutUtility.GetLastRect();
|
||||
if (string.IsNullOrEmpty(meta.Description) == false)
|
||||
{
|
||||
GUILayout.TextArea(tagsstring, EditorStyles.wordWrappedMiniLabel);
|
||||
Rect lineRect = lastRect;
|
||||
lineRect.yMin = lineRect.yMax;
|
||||
lineRect.yMax += 1f;
|
||||
lineRect.y += 5f;
|
||||
EditorGUI.DrawRect(lineRect, new Color(1, 1, 1, 0.12f));
|
||||
|
||||
GUILayout.Space(7f);
|
||||
|
||||
GUILayout.TextArea(meta.Description, EditorStyles.wordWrappedLabel);
|
||||
}
|
||||
|
||||
//footer line
|
||||
if (string.IsNullOrEmpty(meta.MetaID) == false || meta._tags.Length > 0)
|
||||
{
|
||||
Rect lineRect = GUILayoutUtility.GetLastRect();
|
||||
lineRect.yMin = lineRect.yMax;
|
||||
lineRect.yMax += 1f;
|
||||
lineRect.y += 5f;
|
||||
EditorGUI.DrawRect(lineRect, new Color(1, 1, 1, 0.12f));
|
||||
|
||||
GUILayout.Space(3f);
|
||||
}
|
||||
|
||||
//draw metaid block
|
||||
if (string.IsNullOrEmpty(meta.MetaID) == false)
|
||||
{
|
||||
using (EcsGUI.SetAlpha(0.5f))
|
||||
{
|
||||
GUILayout.TextArea(meta.MetaID, EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
//EditorGUI.DrawRect(lineRect, new Color(1, 1, 1, 0.12f));
|
||||
}
|
||||
|
||||
//draw tags block
|
||||
if (meta._tags.Length > 0)
|
||||
{
|
||||
var tagsstring = string.Join(',', meta._tags);
|
||||
using (EcsGUI.SetAlpha(0.5f))
|
||||
{
|
||||
GUILayout.TextArea(tagsstring, EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(1f);
|
||||
}
|
||||
|
||||
|
||||
GUILayout.Space(1f);
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user