mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
refactoring
This commit is contained in:
parent
466a8c24c3
commit
f9ec037a52
@ -5,6 +5,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MetaName("ScriptableObjectSystem")]
|
[MetaName("ScriptableObjectSystem")]
|
||||||
[MetaColor(MetaColor.DragonCyan)]
|
[MetaColor(MetaColor.DragonCyan)]
|
||||||
[MetaDescription("Wrapper for ScriptableObject systems")]
|
[MetaDescription("Wrapper for ScriptableObject systems")]
|
||||||
|
[MetaID("F5A94C5F92015B4D9286E76809311AF4")]
|
||||||
public class ScriptableObjectSystemWrapper : IEcsModule
|
public class ScriptableObjectSystemWrapper : IEcsModule
|
||||||
{
|
{
|
||||||
public ScriptableObject system;
|
public ScriptableObject system;
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 21a9b666ca8f69a45a40d9621424e8f4
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 1907bf7d859547d438973057c64e9656
|
guid: 3af2df61517f386448950800d3b1ff3b
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 04572469768b4844aa9865ae16d3f18b
|
guid: 48c07a8872de79f43aa51dc33d29ba33
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
@ -1,28 +1,8 @@
|
|||||||
using DCFApixels.DragonECS.Unity.Editors;
|
using System;
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
|
||||||
{
|
|
||||||
public sealed class ReferenceButtonAttribute : PropertyAttribute, IReferenceButtonAttribute
|
|
||||||
{
|
|
||||||
public readonly Type[] PredicateTypes;
|
|
||||||
public readonly bool IsHideButtonIfNotNull;
|
|
||||||
Type[] IReferenceButtonAttribute.PredicateTypes { get { return PredicateTypes; } }
|
|
||||||
bool IReferenceButtonAttribute.IsHideButtonIfNotNull { get { return IsHideButtonIfNotNull; } }
|
|
||||||
public ReferenceButtonAttribute(bool isHideButtonIfNotNull = false) : this(isHideButtonIfNotNull, Array.Empty<Type>()) { }
|
|
||||||
public ReferenceButtonAttribute(params Type[] predicateTypes) : this(false, predicateTypes) { }
|
|
||||||
public ReferenceButtonAttribute(bool isHideButtonIfNotNull, params Type[] predicateTypes)
|
|
||||||
{
|
|
||||||
IsHideButtonIfNotNull = isHideButtonIfNotNull;
|
|
||||||
PredicateTypes = predicateTypes;
|
|
||||||
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
namespace DCFApixels.DragonECS.Unity.Editors
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
{
|
{
|
||||||
public interface IReferenceButtonAttribute
|
internal interface IReferenceButtonAttribute
|
||||||
{
|
{
|
||||||
Type[] PredicateTypes { get; }
|
Type[] PredicateTypes { get; }
|
||||||
bool IsHideButtonIfNotNull { get; }
|
bool IsHideButtonIfNotNull { get; }
|
||||||
@ -35,6 +15,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
using DCFApixels.DragonECS.Unity.Internal;
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
using System;
|
using System;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(ComponentTemplateReferenceAttribute), true)]
|
[CustomPropertyDrawer(typeof(ComponentTemplateReferenceAttribute), true)]
|
||||||
[CustomPropertyDrawer(typeof(ReferenceButtonAttribute), true)]
|
[CustomPropertyDrawer(typeof(ReferenceButtonAttribute), true)]
|
11
src/Internal/ReferenceButtonAttributeDrawer.cs.meta
Normal file
11
src/Internal/ReferenceButtonAttributeDrawer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 69a86e40de1b68a448f49be1e83a1ed5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -2,8 +2,10 @@
|
|||||||
using DCFApixels.DragonECS.Unity.Internal;
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEditorInternal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS.Unity.Editors
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
@ -24,7 +26,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
public string metaID;
|
public string metaID;
|
||||||
public string scriptPath;
|
public string scriptPath;
|
||||||
|
|
||||||
public Pair(string metaID, string scriptPath)
|
public Pair(string metaID, string scriptPath)
|
||||||
{
|
{
|
||||||
this.metaID = metaID;
|
this.metaID = metaID;
|
||||||
@ -77,9 +78,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
Save(true);
|
Save(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
if (_isInit) { return; }
|
if (_isInit && _metaIDScriptPathPairs.Count > 0) { return; }
|
||||||
|
|
||||||
_metaIDScriptPathPairs.Clear();
|
_metaIDScriptPathPairs.Clear();
|
||||||
var scriptGuids = AssetDatabase.FindAssets($"* t:MonoScript");
|
var scriptGuids = AssetDatabase.FindAssets($"* t:MonoScript");
|
||||||
|
|
||||||
@ -102,16 +105,15 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
metaIDsBuffer.Clear();
|
metaIDsBuffer.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var pair in _metaIDScriptPathPairs)
|
//foreach (var pair in _metaIDScriptPathPairs)
|
||||||
{
|
//{
|
||||||
EcsDebug.PrintPass($"k:{pair.Key} v:{pair.Value}");
|
// EcsDebug.PrintPass($"k:{pair.Key} v:{pair.Value}");
|
||||||
}
|
//}
|
||||||
|
|
||||||
_isInit = true;
|
_isInit = true;
|
||||||
|
|
||||||
Save(true);
|
Save(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reinit()
|
public void Reinit()
|
||||||
{
|
{
|
||||||
_isInit = false;
|
_isInit = false;
|
||||||
@ -290,13 +292,21 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
if (_serializableMetaIDScriptPathPairs == null) { return; }
|
if (_serializableMetaIDScriptPathPairs == null) { return; }
|
||||||
foreach (var item in _serializableMetaIDScriptPathPairs)
|
foreach (var item in _serializableMetaIDScriptPathPairs)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(item.scriptPath))
|
if (string.IsNullOrEmpty(item.scriptPath) == false)
|
||||||
{
|
{
|
||||||
_metaIDScriptPathPairs.Add(item.metaID, item.scriptPath);
|
_metaIDScriptPathPairs.Add(item.metaID, item.scriptPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Utils
|
||||||
|
private bool CheckFileExists()
|
||||||
|
{
|
||||||
|
string filePath = GetFilePath();
|
||||||
|
return File.Exists(filePath);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 82075f06aeb727149b234dffbff0cd9a
|
guid: 562ccc58fabb98d4982e7c15fdde330e
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
22
src/Utils/ReferenceButtonAttribute.cs
Normal file
22
src/Utils/ReferenceButtonAttribute.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using DCFApixels.DragonECS.Unity.Editors;
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS
|
||||||
|
{
|
||||||
|
public sealed class ReferenceButtonAttribute : PropertyAttribute, IReferenceButtonAttribute
|
||||||
|
{
|
||||||
|
public readonly Type[] PredicateTypes;
|
||||||
|
public readonly bool IsHideButtonIfNotNull;
|
||||||
|
Type[] IReferenceButtonAttribute.PredicateTypes { get { return PredicateTypes; } }
|
||||||
|
bool IReferenceButtonAttribute.IsHideButtonIfNotNull { get { return IsHideButtonIfNotNull; } }
|
||||||
|
public ReferenceButtonAttribute(bool isHideButtonIfNotNull = false) : this(isHideButtonIfNotNull, Array.Empty<Type>()) { }
|
||||||
|
public ReferenceButtonAttribute(params Type[] predicateTypes) : this(false, predicateTypes) { }
|
||||||
|
public ReferenceButtonAttribute(bool isHideButtonIfNotNull, params Type[] predicateTypes)
|
||||||
|
{
|
||||||
|
IsHideButtonIfNotNull = isHideButtonIfNotNull;
|
||||||
|
PredicateTypes = predicateTypes;
|
||||||
|
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 999d5f8fb88eafc44b8a88406eb3ec39
|
guid: f0eb5971224cb3544bfe1f9b1c296b00
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
Loading…
Reference in New Issue
Block a user