mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
update ref repairer
This commit is contained in:
parent
e79b75c81e
commit
8ccd95ea0f
@ -19,6 +19,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MetaColor(MetaColor.DragonCyan)]
|
[MetaColor(MetaColor.DragonCyan)]
|
||||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.COMPONENTS_GROUP)]
|
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.COMPONENTS_GROUP)]
|
||||||
[MetaDescription(EcsConsts.AUTHOR, "Component-reference to Unity object for EcsPool.")]
|
[MetaDescription(EcsConsts.AUTHOR, "Component-reference to Unity object for EcsPool.")]
|
||||||
|
[MetaTags(MetaTags.ENGINE_MEMBER)]
|
||||||
public struct UnityComponent<T> : IEcsComponent, IEnumerable<T>//IntelliSense hack
|
public struct UnityComponent<T> : IEcsComponent, IEnumerable<T>//IntelliSense hack
|
||||||
where T : Component
|
where T : Component
|
||||||
{
|
{
|
||||||
|
@ -2,11 +2,11 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
#region UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using DCFApixels.DragonECS.Unity.Internal;
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
using DCFApixels.DragonECS.Unity;
|
using DCFApixels.DragonECS.Unity;
|
||||||
#endregion
|
#endif
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MetaID("14AC6B239201C6A60337AF3384D237E7")]
|
[MetaID("14AC6B239201C6A60337AF3384D237E7")]
|
||||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.COMPONENTS_GROUP)]
|
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.COMPONENTS_GROUP)]
|
||||||
[MetaDescription(EcsConsts.AUTHOR, "This component is automatically added if an entity is connected to one of the EcsEntityConnect. It also contains a reference to the connected EcsEntityConnect.")]
|
[MetaDescription(EcsConsts.AUTHOR, "This component is automatically added if an entity is connected to one of the EcsEntityConnect. It also contains a reference to the connected EcsEntityConnect.")]
|
||||||
|
[MetaTags(MetaTags.ENGINE_MEMBER)]
|
||||||
public readonly struct GameObjectConnect : IEcsComponent, IEcsComponentLifecycle<GameObjectConnect>
|
public readonly struct GameObjectConnect : IEcsComponent, IEcsComponentLifecycle<GameObjectConnect>
|
||||||
{
|
{
|
||||||
public readonly EcsEntityConnect Connect;
|
public readonly EcsEntityConnect Connect;
|
||||||
|
@ -235,6 +235,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
public static FontStyleScope SetFontStyle(FontStyle value) => new FontStyleScope(GUI.skin.label, value);
|
public static FontStyleScope SetFontStyle(FontStyle value) => new FontStyleScope(GUI.skin.label, value);
|
||||||
public static FontStyleScope SetFontStyle(GUIStyle target) => new FontStyleScope(target);
|
public static FontStyleScope SetFontStyle(GUIStyle target) => new FontStyleScope(target);
|
||||||
public static FontSizeScope SetFontSize(GUIStyle target, int value) => new FontSizeScope(target, value);
|
public static FontSizeScope SetFontSize(GUIStyle target, int value) => new FontSizeScope(target, value);
|
||||||
|
public static FontSizeScope SetFontSize(int value) => new FontSizeScope(GUI.skin.label, value);
|
||||||
public static FontSizeScope SetFontSize(GUIStyle target) => new FontSizeScope(target);
|
public static FontSizeScope SetFontSize(GUIStyle target) => new FontSizeScope(target);
|
||||||
public static AlignmentScope SetAlignment(GUIStyle target, TextAnchor value) => new AlignmentScope(target, value);
|
public static AlignmentScope SetAlignment(GUIStyle target, TextAnchor value) => new AlignmentScope(target, value);
|
||||||
public static AlignmentScope SetAlignment(TextAnchor value) => new AlignmentScope(GUI.skin.label, value);
|
public static AlignmentScope SetAlignment(TextAnchor value) => new AlignmentScope(GUI.skin.label, value);
|
||||||
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
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
|
||||||
|
@ -15,6 +15,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
|||||||
[MenuItem("Tools/" + EcsConsts.FRAMEWORK_NAME + "/" + TITLE)]
|
[MenuItem("Tools/" + EcsConsts.FRAMEWORK_NAME + "/" + TITLE)]
|
||||||
public static void Open()
|
public static void Open()
|
||||||
{
|
{
|
||||||
|
_isNoFound = false;
|
||||||
var wnd = GetWindow<RefRepairerWindow>();
|
var wnd = GetWindow<RefRepairerWindow>();
|
||||||
wnd.titleContent = new GUIContent(TITLE);
|
wnd.titleContent = new GUIContent(TITLE);
|
||||||
wnd.minSize = new Vector2(140f, 140f);
|
wnd.minSize = new Vector2(140f, 140f);
|
||||||
@ -147,28 +148,71 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
|||||||
|
|
||||||
|
|
||||||
private Vector2 _scrollViewPosition;
|
private Vector2 _scrollViewPosition;
|
||||||
|
private static bool _isNoFound = false;
|
||||||
|
private GUIStyle _panel;
|
||||||
|
|
||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
{
|
{
|
||||||
|
//if (_panel == null)
|
||||||
|
{
|
||||||
|
_panel = new GUIStyle();
|
||||||
|
_panel.padding = new RectOffset(5, 5, 5, 5);
|
||||||
|
}
|
||||||
|
using (EcsGUI.Layout.BeginVertical(_panel))
|
||||||
|
{
|
||||||
|
const string LIST_EMPTY_MESSAGE = "List of Missings is Empty";
|
||||||
|
const string COLLECT_BUTTON = "Collect Missings";
|
||||||
if (_missingRefContainer.IsEmplty)
|
if (_missingRefContainer.IsEmplty)
|
||||||
{
|
{
|
||||||
if (GUILayout.Button("Collect missing references"))
|
GUILayout.Label("", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
|
||||||
|
using (EcsGUI.SetFontSize(14))
|
||||||
|
using (EcsGUI.SetFontSize(GUI.skin.button, 14))
|
||||||
|
using (EcsGUI.SetAlignment(value: TextAnchor.MiddleCenter))
|
||||||
|
{
|
||||||
|
Vector2 center = GUILayoutUtility.GetLastRect().center;
|
||||||
|
Vector2 labelSize = GUI.skin.label.CalcSize(UnityEditorUtility.GetLabel(LIST_EMPTY_MESSAGE));
|
||||||
|
Vector2 buttonSize = GUI.skin.button.CalcSize(UnityEditorUtility.GetLabel(COLLECT_BUTTON));
|
||||||
|
labelSize *= 1.2f;
|
||||||
|
buttonSize *= 1.2f;
|
||||||
|
Rect r;
|
||||||
|
r = new Rect(Vector2.zero, labelSize);
|
||||||
|
r.center = center;
|
||||||
|
r.y -= labelSize.y / 2f;
|
||||||
|
GUI.Label(r, LIST_EMPTY_MESSAGE);
|
||||||
|
r = new Rect(Vector2.zero, buttonSize);
|
||||||
|
r.center = center;
|
||||||
|
r.y += buttonSize.y / 2f;
|
||||||
|
if (Event.current.type == EventType.MouseDown && EcsGUI.HitTest(r))
|
||||||
|
{
|
||||||
|
_isNoFound = false;
|
||||||
|
}
|
||||||
|
if (GUI.Button(r, COLLECT_BUTTON, GUI.skin.button))
|
||||||
{
|
{
|
||||||
if (TryInit())
|
if (TryInit())
|
||||||
{
|
{
|
||||||
_missingRefContainer.Collect();
|
_missingRefContainer.Collect();
|
||||||
_cachedMissingsResolvingDatas = _missingRefContainer.MissingsResolvingDatas.Values.ToArray();
|
_cachedMissingsResolvingDatas = _missingRefContainer.MissingsResolvingDatas.Values.ToArray();
|
||||||
InitList();
|
InitList();
|
||||||
|
if (_missingRefContainer.IsEmplty)
|
||||||
|
{
|
||||||
|
_isNoFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUIContent label = UnityEditorUtility.GetLabel("Missing references not found in the project.");
|
||||||
|
labelSize = GUI.skin.label.CalcSize(label);
|
||||||
|
r.y += labelSize.y * 1.1f;
|
||||||
|
r.xMin -= labelSize.x / 2f;
|
||||||
|
r.xMax += labelSize.x / 2f;
|
||||||
|
if (_isNoFound)
|
||||||
|
{
|
||||||
|
GUI.Label(r, label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("Repaire missing references"))
|
|
||||||
{
|
|
||||||
_selectedMissingsResolvingData = null;
|
|
||||||
RepaireFileUtility.RepaieAsset(_missingRefContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_missingRefContainer.MissingsResolvingDatas.Count != _cachedMissingsResolvingDatas.Length)
|
if (_missingRefContainer.MissingsResolvingDatas.Count != _cachedMissingsResolvingDatas.Length)
|
||||||
{
|
{
|
||||||
_cachedMissingsResolvingDatas = _missingRefContainer.MissingsResolvingDatas.Values.ToArray();
|
_cachedMissingsResolvingDatas = _missingRefContainer.MissingsResolvingDatas.Values.ToArray();
|
||||||
@ -183,10 +227,10 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
|||||||
_reorderableResolvingDataList.DoLayoutList();
|
_reorderableResolvingDataList.DoLayoutList();
|
||||||
GUILayout.EndScrollView();
|
GUILayout.EndScrollView();
|
||||||
}
|
}
|
||||||
|
GUILayout.Space(4f);
|
||||||
|
|
||||||
|
using (EcsGUI.Layout.BeginVertical(GUILayout.ExpandHeight(false)))
|
||||||
|
{
|
||||||
GUILayout.BeginVertical(GUILayout.ExpandHeight(false));
|
|
||||||
//GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(false));
|
//GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(false));
|
||||||
|
|
||||||
var data = _selectedMissingsResolvingData;
|
var data = _selectedMissingsResolvingData;
|
||||||
@ -216,12 +260,25 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
|||||||
string AssemblyName = DrawEditableLine(rect, "Assembly:", data.OldTypeData.AssemblyName, data.NewTypeData.AssemblyName);
|
string AssemblyName = DrawEditableLine(rect, "Assembly:", data.OldTypeData.AssemblyName, data.NewTypeData.AssemblyName);
|
||||||
if (EcsGUI.Changed)
|
if (EcsGUI.Changed)
|
||||||
{
|
{
|
||||||
data.NewTypeData = new RefRepairer.Internal.TypeData(ClassName, NamespaceName, AssemblyName);
|
data.NewTypeData = new Internal.TypeData(ClassName, NamespaceName, AssemblyName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.EndVertical();
|
using (EcsGUI.Layout.BeginHorizontal(GUILayout.Height(26f)))
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("Re-Collect", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(false)))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
if (GUILayout.Button("Repaire missing references", GUILayout.ExpandHeight(true)))
|
||||||
|
{
|
||||||
|
_selectedMissingsResolvingData = null;
|
||||||
|
RepaireFileUtility.RepaieAsset(_missingRefContainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user