mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
update stash
This commit is contained in:
parent
ecf1f4b4c4
commit
3c3fb1891d
11
src/Internal/ArrayUtility.cs.meta
Normal file
11
src/Internal/ArrayUtility.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1071dcd31ebdf5042a289eb27d8e12d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -123,7 +123,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
serializableTypes.AddRange(targetTypes);
|
||||
}
|
||||
_serializableTypes = serializableTypes.ToArray();
|
||||
_serializableTypeWithMetaIDMetas = serializableTypes.Where(type => TypeMeta.IsHasMetaID(type)).Select(type => type.GetMeta()).ToArray();
|
||||
_serializableTypeWithMetaIDMetas = serializableTypes
|
||||
.Where(type => TypeMeta.IsHasMetaID(type))
|
||||
.Select(type => type.ToMeta())
|
||||
.ToArray();
|
||||
//Array.Sort(_serializableTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
|
||||
|
||||
//_noHiddenSerializableTypes = _serializableTypes.Where(o => {
|
||||
@ -134,6 +137,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
|
||||
internal static readonly Type[] _serializableTypes;
|
||||
internal static readonly TypeMeta[] _serializableTypeWithMetaIDMetas;
|
||||
private static readonly Dictionary<string, Type> _metaIDTypePairs = new Dictionary<string, Type>();
|
||||
|
||||
public static bool TryGetTypeForMetaID(string metaID, out Type type)
|
||||
{
|
||||
return _metaIDTypePairs.TryGetValue(metaID, out type);
|
||||
}
|
||||
|
||||
//private static Type[] _noHiddenSerializableTypes;
|
||||
|
||||
private static SparseArray<GUIStyle> colorBoxeStyles = new SparseArray<GUIStyle>();
|
||||
|
@ -1,4 +1,5 @@
|
||||
#if UNITY_EDITOR
|
||||
using DCFApixels.DragonECS.Unity.RefRepairer.Editors;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
|
@ -1,104 +1,88 @@
|
||||
#if UNITY_EDITOR
|
||||
using DCFApixels.DragonECS.Unity.Internal;
|
||||
using DCFApixels.DragonECS.Unity.Editors;
|
||||
using DCFApixels.DragonECS.Unity.RefRepairer.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
[FilePath(EcsUnityConsts.LOCAL_CACHE_FOLDER + "/" + nameof(MetaIDRegistry) + ".prefs", FilePathAttribute.Location.ProjectFolder)]
|
||||
internal class MetaIDRegistry : ScriptableSingleton<MetaIDRegistry>, ISerializationCallbackReceiver
|
||||
{
|
||||
[SerializeField]
|
||||
private TypeDataList[] _typeDataLists;
|
||||
[SerializeField]
|
||||
private int _typeDataListsCount = 0;
|
||||
[SerializeField]
|
||||
private TypeDataNode[] _typeDataNodes;
|
||||
[SerializeField]
|
||||
private int _typeDataNodesCount = 0;
|
||||
#region [SerializeField]
|
||||
[Serializable]
|
||||
private struct Pair
|
||||
{
|
||||
public string metaID;
|
||||
public int listIndex;
|
||||
public Pair(string metaID, int listIndex)
|
||||
public TypeDataSerializable key;
|
||||
public string value;
|
||||
public Pair(TypeDataSerializable key, string value)
|
||||
{
|
||||
this.metaID = metaID;
|
||||
this.listIndex = listIndex;
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
private Pair[] _metaIDListIndexPairsSerializable;
|
||||
[SerializeField]
|
||||
private Pair[] _typeKeyMetaIDPairsSerializable;
|
||||
#endregion
|
||||
private Dictionary<string, int> _metaIDListIndexPairs = new Dictionary<string, int>();
|
||||
private Dictionary<TypeData, string> _typeKeyMetaIDPairs = new Dictionary<TypeData, string>();
|
||||
private bool _isChanged = false;
|
||||
|
||||
public bool TryGetMetaID(TypeData key, out string metaID)
|
||||
{
|
||||
return _typeKeyMetaIDPairs.TryGetValue(key, out metaID);
|
||||
}
|
||||
|
||||
|
||||
static MetaIDRegistry()
|
||||
{
|
||||
EditorApplication.update += BeforeCompilation;
|
||||
}
|
||||
private static void BeforeCompilation()
|
||||
{
|
||||
EditorApplication.update -= BeforeCompilation;
|
||||
instance.TryGetMetaID(default, out _);
|
||||
instance.Update();
|
||||
}
|
||||
|
||||
#region Update
|
||||
public void Reinit()
|
||||
{
|
||||
_typeKeyMetaIDPairs.Clear();
|
||||
Update();
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
var typeMetas = UnityEditorUtility._serializableTypeWithMetaIDMetas;
|
||||
bool isChanged = false;
|
||||
|
||||
for (int i = 0; i < _typeDataListsCount; i++)
|
||||
{
|
||||
_typeDataLists[i].containsFlag = false;
|
||||
}
|
||||
|
||||
foreach (var meta in typeMetas)
|
||||
{
|
||||
var type = meta.Type;
|
||||
var key = new TypeData(type.Name, type.Namespace, type.Assembly.FullName);
|
||||
var metaID = meta.MetaID;
|
||||
|
||||
var name = type.Name;
|
||||
var nameSpace = type.Namespace;
|
||||
var assembly = type.Assembly.FullName;
|
||||
|
||||
if (_metaIDListIndexPairs.TryGetValue(meta.MetaID, out int listIndex) == false)
|
||||
if (_typeKeyMetaIDPairs.TryGetValue(key, out string keyMetaID) == false)
|
||||
{
|
||||
if (_typeDataLists.Length <= _typeDataListsCount)
|
||||
if (keyMetaID != metaID)
|
||||
{
|
||||
Array.Resize(ref _typeDataLists, _typeDataLists.Length << 1);
|
||||
_typeKeyMetaIDPairs[key] = null; //Таким образом помечаются моменты когда не однозначно какой идентификатор принадлежит этому имени
|
||||
_isChanged = true;
|
||||
}
|
||||
listIndex = _typeDataListsCount++;
|
||||
_metaIDListIndexPairs.Add(meta.MetaID, listIndex);
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
ref var listRef = ref _typeDataLists[listIndex];
|
||||
listRef.containsFlag = true;
|
||||
if (listRef.count > 0 && _typeDataNodes[listRef.startNode].EqualsWith(name, nameSpace, assembly))
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_typeDataNodes.Length <= _typeDataNodesCount)
|
||||
{
|
||||
Array.Resize(ref _typeDataNodes, _typeDataNodes.Length << 1);
|
||||
}
|
||||
int nodeIndex = _typeDataNodesCount++;
|
||||
ref var nodeRef = ref _typeDataNodes[nodeIndex];
|
||||
isChanged = true;
|
||||
|
||||
nodeRef = new TypeDataNode(name, nameSpace, assembly);
|
||||
nodeRef.next = listRef.startNode;
|
||||
listRef.startNode = listIndex;
|
||||
listRef.count++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _typeDataListsCount; i++)
|
||||
{
|
||||
ref var list = ref _typeDataLists[i];
|
||||
if (list.containsFlag == false)
|
||||
{
|
||||
_metaIDListIndexPairs.Remove();
|
||||
_typeKeyMetaIDPairs[key] = metaID;
|
||||
_isChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isChanged)
|
||||
if (_isChanged)
|
||||
{
|
||||
EditorUtility.SetDirty(this);
|
||||
_isChanged = false;
|
||||
Save(true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@ -106,65 +90,22 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
#region ISerializationCallbackReceiver
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
_metaIDListIndexPairs.Clear();
|
||||
if (_typeDataNodes == null)
|
||||
_typeKeyMetaIDPairs.Clear();
|
||||
foreach (var pair in _typeKeyMetaIDPairsSerializable)
|
||||
{
|
||||
_typeDataLists = new TypeDataList[256];
|
||||
_typeDataListsCount = 0;
|
||||
_typeDataNodes = new TypeDataNode[256];
|
||||
_typeDataNodesCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var pair in _metaIDListIndexPairsSerializable)
|
||||
if (string.IsNullOrEmpty(pair.value) == false)
|
||||
{
|
||||
_metaIDListIndexPairs[pair.metaID] = pair.listIndex;
|
||||
_typeKeyMetaIDPairs[pair.key] = pair.value;
|
||||
}
|
||||
}
|
||||
Update();
|
||||
}
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
int i = 0;
|
||||
_metaIDListIndexPairsSerializable = new Pair[_metaIDListIndexPairs.Count];
|
||||
foreach (var pair in _metaIDListIndexPairs)
|
||||
_typeKeyMetaIDPairsSerializable = new Pair[_typeKeyMetaIDPairs.Count];
|
||||
foreach (var pair in _typeKeyMetaIDPairs)
|
||||
{
|
||||
_metaIDListIndexPairsSerializable[i++] = new Pair(pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Utils
|
||||
[Serializable]
|
||||
public struct TypeDataList
|
||||
{
|
||||
public string metaID_key;
|
||||
public bool containsFlag;
|
||||
public int startNode;
|
||||
public int count;
|
||||
}
|
||||
[Serializable]
|
||||
public struct TypeDataNode : ILinkedNext
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly string Namespace;
|
||||
public readonly string Assembly;
|
||||
public int next;
|
||||
|
||||
public bool EqualsWith(string name, string nameSpace, string assembly)
|
||||
{
|
||||
return name == Name && nameSpace == Namespace && assembly == Assembly;
|
||||
}
|
||||
public TypeDataNode(string name, string nameSpace, string assembly) : this()
|
||||
{
|
||||
Name = name;
|
||||
Namespace = nameSpace;
|
||||
Assembly = assembly;
|
||||
}
|
||||
int ILinkedNext.Next
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return next; }
|
||||
_typeKeyMetaIDPairsSerializable[i++] = new Pair(pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
11
src/RefRepairer/MetaIDRegistry.cs.meta
Normal file
11
src/RefRepairer/MetaIDRegistry.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcb53d0894c939c49b3e12c6286f4750
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using DCFApixels.DragonECS.Unity.RefRepairer.Internal;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
@ -7,7 +8,7 @@ using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
||||
{
|
||||
public static class UnityObjectExtensions
|
||||
{
|
||||
@ -21,7 +22,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
}
|
||||
|
||||
internal class RefRepaireUtility
|
||||
internal class MissingRefUtility
|
||||
{
|
||||
private readonly Dictionary<TypeData, ContainerMissingTypes> _missingTypes = new Dictionary<TypeData, ContainerMissingTypes>();
|
||||
|
||||
@ -163,7 +164,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
}
|
||||
|
||||
private void AddMissingType(ManagedReferenceMissingType missingType, BaseUnityObjectData unityObject)
|
||||
private void AddMissingType(ManagedReferenceMissingType missingType, UnityObjectDataBase unityObject)
|
||||
{
|
||||
var typeData = new TypeData(missingType);
|
||||
var missingTypeData = new MissingTypeData(missingType, unityObject);
|
||||
@ -173,85 +174,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
_missingTypes.Add(typeData, containerMissingTypes);
|
||||
}
|
||||
|
||||
containerMissingTypes.Add(missingTypeData);
|
||||
containerMissingTypes.ManagedReferencesMissingTypeDatas.Add(missingTypeData);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class ContainerMissingTypes
|
||||
{
|
||||
public readonly TypeData TypeData;
|
||||
|
||||
private readonly List<MissingTypeData> _managedReferencesMissingTypeDatas = new List<MissingTypeData>();
|
||||
|
||||
public IReadOnlyCollection<MissingTypeData> ManagedReferencesMissingTypeDatas => _managedReferencesMissingTypeDatas;
|
||||
|
||||
public ContainerMissingTypes(TypeData typeData)
|
||||
{
|
||||
TypeData = typeData;
|
||||
}
|
||||
|
||||
public void Add(MissingTypeData missingTypeData) => _managedReferencesMissingTypeDatas.Add(missingTypeData);
|
||||
|
||||
public void Remove(MissingTypeData missingTypeData) => _managedReferencesMissingTypeDatas.Remove(missingTypeData);
|
||||
|
||||
public void RemoveAt(int index) => _managedReferencesMissingTypeDatas.RemoveAt(index);
|
||||
}
|
||||
public struct MissingTypeData
|
||||
{
|
||||
public readonly ManagedReferenceMissingType Data;
|
||||
public readonly BaseUnityObjectData UnityObject;
|
||||
|
||||
public MissingTypeData(ManagedReferenceMissingType missingType, BaseUnityObjectData unityObject)
|
||||
{
|
||||
Data = missingType;
|
||||
UnityObject = unityObject;
|
||||
}
|
||||
}
|
||||
public struct TypeData
|
||||
{
|
||||
public readonly string AssemblyName;
|
||||
public readonly string NamespaceName;
|
||||
public readonly string ClassName;
|
||||
|
||||
public TypeData(ManagedReferenceMissingType missingType)
|
||||
{
|
||||
AssemblyName = missingType.assemblyName;
|
||||
NamespaceName = missingType.namespaceName;
|
||||
ClassName = missingType.className;
|
||||
}
|
||||
}
|
||||
public abstract class BaseUnityObjectData
|
||||
{
|
||||
public string LocalAssetPath => AssetDatabase.GUIDToAssetPath(AssetGuid);
|
||||
public abstract GUID AssetGuid { get; }
|
||||
}
|
||||
public class SceneObjectData : BaseUnityObjectData
|
||||
{
|
||||
public readonly string SceneName;
|
||||
|
||||
public override GUID AssetGuid { get; }
|
||||
|
||||
public SceneObjectData(Scene scene)
|
||||
{
|
||||
SceneName = scene.name;
|
||||
AssetGuid = AssetDatabase.GUIDFromAssetPath(scene.path);
|
||||
}
|
||||
}
|
||||
public class UnityObjectData : BaseUnityObjectData
|
||||
{
|
||||
public readonly UnityObject UnityObject;
|
||||
public override GUID AssetGuid { get; }
|
||||
|
||||
public UnityObjectData(UnityObject unityObject, string pathToPrefab)
|
||||
{
|
||||
UnityObject = unityObject;
|
||||
AssetGuid = AssetDatabase.GUIDFromAssetPath(pathToPrefab);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +1,56 @@
|
||||
using DCFApixels.DragonECS.Unity.RefRepairer.Internal;
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
||||
{
|
||||
public static class FileRepaireUtility
|
||||
internal static class FileRepaireUtility
|
||||
{
|
||||
private const string REFLINE_PATTERN = "- rid:";
|
||||
public static void Replace(string filePath)
|
||||
public static void Replace(string[] fileLines, string oldTypeData, string newTypeData)
|
||||
{
|
||||
for (int i = 0; i < fileLines.Length; i++)
|
||||
{
|
||||
if (fileLines[i].Contains(REFLINE_PATTERN))
|
||||
{
|
||||
fileLines[++i].Replace(oldTypeData, newTypeData);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static string GenerateReplacedLine(TypeData typeData)
|
||||
{
|
||||
return $"type: {{class: {typeData.ClassName}, ns: {typeData.NamespaceName}, asm: {typeData.AssemblyName}}}";
|
||||
}
|
||||
public static string GenerateReplacedLine(ManagedReferenceMissingType typeData)
|
||||
{
|
||||
return $"type: {{class: {typeData.className}, ns: {typeData.namespaceName}, asm: {typeData.assemblyName}}}";
|
||||
}
|
||||
|
||||
public struct FileScope : IDisposable
|
||||
{
|
||||
public readonly string FilePath;
|
||||
public readonly string LocalAssetPath;
|
||||
public string[] lines;
|
||||
public FileScope(string localAssetPath)
|
||||
{
|
||||
LocalAssetPath = localAssetPath;
|
||||
FilePath = $"{Application.dataPath.Replace("/Assets", "")}/{localAssetPath}";
|
||||
lines = File.ReadAllLines(localAssetPath);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
File.WriteAllLines(FilePath, lines);
|
||||
AssetDatabase.ImportAsset(LocalAssetPath, ImportAssetOptions.ForceUpdate);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
public class RepairerFile
|
||||
|
||||
|
||||
internal class RepairerFile
|
||||
{
|
||||
private readonly Type _type;
|
||||
private readonly string[] _fileLines;
|
||||
|
8
src/RefRepairer/Utils.meta
Normal file
8
src/RefRepairer/Utils.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 070d3c08bbce7714c9edbd903bb370c9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
src/RefRepairer/Utils/ContainerMissingTypes.cs
Normal file
19
src/RefRepairer/Utils/ContainerMissingTypes.cs
Normal file
@ -0,0 +1,19 @@
|
||||
#if UNITY_EDITOR
|
||||
using DCFApixels.DragonECS.Unity.RefRepairer.Internal;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
||||
{
|
||||
internal class ContainerMissingTypes
|
||||
{
|
||||
public readonly TypeData TypeData;
|
||||
public readonly string ReplacedLine;
|
||||
public readonly List<MissingTypeData> ManagedReferencesMissingTypeDatas = new List<MissingTypeData>();
|
||||
public ContainerMissingTypes(TypeData typeData)
|
||||
{
|
||||
TypeData = typeData;
|
||||
ReplacedLine = FileRepaireUtility.GenerateReplacedLine(typeData);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
src/RefRepairer/Utils/ContainerMissingTypes.cs.meta
Normal file
11
src/RefRepairer/Utils/ContainerMissingTypes.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7999f2711e8e3e040b8ae48ce5acec71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
src/RefRepairer/Utils/MissingTypeData.cs
Normal file
18
src/RefRepairer/Utils/MissingTypeData.cs
Normal file
@ -0,0 +1,18 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
||||
{
|
||||
internal readonly struct MissingTypeData
|
||||
{
|
||||
public readonly ManagedReferenceMissingType Data;
|
||||
public readonly UnityObjectDataBase UnityObject;
|
||||
|
||||
public MissingTypeData(ManagedReferenceMissingType missingType, UnityObjectDataBase unityObject)
|
||||
{
|
||||
Data = missingType;
|
||||
UnityObject = unityObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
src/RefRepairer/Utils/MissingTypeData.cs.meta
Normal file
11
src/RefRepairer/Utils/MissingTypeData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 447f4a0f7419475438468e8f08d8b7cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
src/RefRepairer/Utils/SceneObjectData.cs
Normal file
19
src/RefRepairer/Utils/SceneObjectData.cs
Normal file
@ -0,0 +1,19 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
||||
{
|
||||
internal class SceneObjectData : UnityObjectDataBase
|
||||
{
|
||||
private readonly GUID _assetGUID;
|
||||
public readonly string SceneName;
|
||||
public sealed override GUID AssetGuid { get { return _assetGUID; } }
|
||||
public SceneObjectData(Scene scene)
|
||||
{
|
||||
_assetGUID = AssetDatabase.GUIDFromAssetPath(scene.path);
|
||||
SceneName = scene.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
src/RefRepairer/Utils/SceneObjectData.cs.meta
Normal file
11
src/RefRepairer/Utils/SceneObjectData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 495419751a448a848853d4df10955da7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
55
src/RefRepairer/Utils/TypeData.cs
Normal file
55
src/RefRepairer/Utils/TypeData.cs
Normal file
@ -0,0 +1,55 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using UnityEditor;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.RefRepairer.Internal
|
||||
{
|
||||
[Serializable]
|
||||
internal struct TypeDataSerializable
|
||||
{
|
||||
public string ClassName;
|
||||
public string NamespaceName;
|
||||
public string AssemblyName;
|
||||
public TypeDataSerializable(string typeName, string namespaceName, string assemblyName)
|
||||
{
|
||||
ClassName = typeName;
|
||||
NamespaceName = namespaceName;
|
||||
AssemblyName = assemblyName;
|
||||
}
|
||||
public static implicit operator TypeDataSerializable(TypeData type) { return new TypeDataSerializable(type.ClassName, type.NamespaceName, type.AssemblyName); }
|
||||
public static implicit operator TypeData(TypeDataSerializable type) { return new TypeData(type.ClassName, type.NamespaceName, type.AssemblyName); }
|
||||
}
|
||||
internal readonly struct TypeData : IEquatable<TypeData>
|
||||
{
|
||||
public readonly string ClassName;
|
||||
public readonly string NamespaceName;
|
||||
public readonly string AssemblyName;
|
||||
public TypeData(ManagedReferenceMissingType managedReferenceMissingType)
|
||||
{
|
||||
ClassName = managedReferenceMissingType.className;
|
||||
NamespaceName = managedReferenceMissingType.namespaceName;
|
||||
AssemblyName = managedReferenceMissingType.assemblyName;
|
||||
}
|
||||
public TypeData(string typeName, string namespaceName, string assemblyName)
|
||||
{
|
||||
ClassName = typeName;
|
||||
NamespaceName = namespaceName;
|
||||
AssemblyName = assemblyName;
|
||||
}
|
||||
public bool Equals(TypeData other)
|
||||
{
|
||||
return ClassName == other.ClassName &&
|
||||
NamespaceName == other.NamespaceName &&
|
||||
AssemblyName == other.AssemblyName;
|
||||
}
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return Equals((TypeData)obj);
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(ClassName, NamespaceName, AssemblyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
src/RefRepairer/Utils/TypeData.cs.meta
Normal file
11
src/RefRepairer/Utils/TypeData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc54327da1808fb4ebb37e955e774b6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
src/RefRepairer/Utils/UnityObjectData.cs
Normal file
19
src/RefRepairer/Utils/UnityObjectData.cs
Normal file
@ -0,0 +1,19 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
||||
{
|
||||
internal class UnityObjectData : UnityObjectDataBase
|
||||
{
|
||||
private readonly GUID _assetGUID;
|
||||
public readonly UnityObject UnityObject;
|
||||
public sealed override GUID AssetGuid { get { return _assetGUID; } }
|
||||
public UnityObjectData(UnityObject unityObject, string pathToPrefab)
|
||||
{
|
||||
_assetGUID = AssetDatabase.GUIDFromAssetPath(pathToPrefab);
|
||||
UnityObject = unityObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
src/RefRepairer/Utils/UnityObjectData.cs.meta
Normal file
11
src/RefRepairer/Utils/UnityObjectData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0037513c31abb5d4ebd572d2fd17ccec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
src/RefRepairer/Utils/UnityObjectDataBase.cs
Normal file
16
src/RefRepairer/Utils/UnityObjectDataBase.cs
Normal file
@ -0,0 +1,16 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
||||
{
|
||||
internal abstract class UnityObjectDataBase
|
||||
{
|
||||
//public string LocalAssetPath => AssetDatabase.GUIDToAssetPath(AssetGuid);
|
||||
public abstract GUID AssetGuid { get; }
|
||||
public string GetLocalAssetPath()
|
||||
{
|
||||
return AssetDatabase.GUIDToAssetPath(AssetGuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
src/RefRepairer/Utils/UnityObjectDataBase.cs.meta
Normal file
11
src/RefRepairer/Utils/UnityObjectDataBase.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee1ba8deebb294644b74bfe99f1fc2bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user