mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 17:34:34 +08:00
update ref repairer
This commit is contained in:
parent
e79b75c81e
commit
8ccd95ea0f
@ -19,6 +19,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaColor(MetaColor.DragonCyan)]
|
||||
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.COMPONENTS_GROUP)]
|
||||
[MetaDescription(EcsConsts.AUTHOR, "Component-reference to Unity object for EcsPool.")]
|
||||
[MetaTags(MetaTags.ENGINE_MEMBER)]
|
||||
public struct UnityComponent<T> : IEcsComponent, IEnumerable<T>//IntelliSense hack
|
||||
where T : Component
|
||||
{
|
||||
|
@ -2,11 +2,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
#region UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using DCFApixels.DragonECS.Unity.Internal;
|
||||
using DCFApixels.DragonECS.Unity;
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ namespace DCFApixels.DragonECS
|
||||
[MetaID("14AC6B239201C6A60337AF3384D237E7")]
|
||||
[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.")]
|
||||
[MetaTags(MetaTags.ENGINE_MEMBER)]
|
||||
public readonly struct GameObjectConnect : IEcsComponent, IEcsComponentLifecycle<GameObjectConnect>
|
||||
{
|
||||
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(GUIStyle target) => new FontStyleScope(target);
|
||||
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 AlignmentScope SetAlignment(GUIStyle target, TextAnchor value) => new AlignmentScope(target, 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.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
|
@ -15,6 +15,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
||||
[MenuItem("Tools/" + EcsConsts.FRAMEWORK_NAME + "/" + TITLE)]
|
||||
public static void Open()
|
||||
{
|
||||
_isNoFound = false;
|
||||
var wnd = GetWindow<RefRepairerWindow>();
|
||||
wnd.titleContent = new GUIContent(TITLE);
|
||||
wnd.minSize = new Vector2(140f, 140f);
|
||||
@ -147,81 +148,137 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
|
||||
|
||||
|
||||
private Vector2 _scrollViewPosition;
|
||||
private static bool _isNoFound = false;
|
||||
private GUIStyle _panel;
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (_missingRefContainer.IsEmplty)
|
||||
//if (_panel == null)
|
||||
{
|
||||
if (GUILayout.Button("Collect missing references"))
|
||||
_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 (TryInit())
|
||||
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))
|
||||
{
|
||||
_missingRefContainer.Collect();
|
||||
_cachedMissingsResolvingDatas = _missingRefContainer.MissingsResolvingDatas.Values.ToArray();
|
||||
InitList();
|
||||
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())
|
||||
{
|
||||
_missingRefContainer.Collect();
|
||||
_cachedMissingsResolvingDatas = _missingRefContainer.MissingsResolvingDatas.Values.ToArray();
|
||||
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;
|
||||
}
|
||||
|
||||
if (_missingRefContainer.MissingsResolvingDatas.Count != _cachedMissingsResolvingDatas.Length)
|
||||
{
|
||||
_cachedMissingsResolvingDatas = _missingRefContainer.MissingsResolvingDatas.Values.ToArray();
|
||||
InitList();
|
||||
}
|
||||
|
||||
var bc = EcsGUI.SetBackgroundColor(Color.black, 0.5f);
|
||||
using (EcsGUI.Layout.BeginVertical(EditorStyles.helpBox))
|
||||
{
|
||||
bc.Dispose();
|
||||
_scrollViewPosition = GUILayout.BeginScrollView(_scrollViewPosition, GUILayout.ExpandHeight(true));
|
||||
_reorderableResolvingDataList.DoLayoutList();
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
GUILayout.Space(4f);
|
||||
|
||||
using (EcsGUI.Layout.BeginVertical(GUILayout.ExpandHeight(false)))
|
||||
{
|
||||
//GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(false));
|
||||
|
||||
var data = _selectedMissingsResolvingData;
|
||||
Rect rect = GUILayoutUtility.GetRect(
|
||||
EditorGUIUtility.currentViewWidth,
|
||||
(EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * 3f + EditorGUIUtility.standardVerticalSpacing * 2f)
|
||||
.AddPadding(EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
using (EcsGUI.SetAlignment(TextAnchor.MiddleCenter))
|
||||
{
|
||||
GUI.Label(rect, "Select any record");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (EcsGUI.CheckChanged())
|
||||
{
|
||||
rect.height = EditorGUIUtility.singleLineHeight;
|
||||
rect = rect.Move(0, EditorGUIUtility.standardVerticalSpacing);
|
||||
string ClassName = DrawEditableLine(rect, "Name:", data.OldTypeData.ClassName, data.NewTypeData.ClassName);
|
||||
rect = rect.Move(0, EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
|
||||
string NamespaceName = DrawEditableLine(rect, "Namespace:", data.OldTypeData.NamespaceName, data.NewTypeData.NamespaceName);
|
||||
rect = rect.Move(0, EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
|
||||
string AssemblyName = DrawEditableLine(rect, "Assembly:", data.OldTypeData.AssemblyName, data.NewTypeData.AssemblyName);
|
||||
if (EcsGUI.Changed)
|
||||
{
|
||||
data.NewTypeData = new Internal.TypeData(ClassName, NamespaceName, AssemblyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Repaire missing references"))
|
||||
{
|
||||
_selectedMissingsResolvingData = null;
|
||||
RepaireFileUtility.RepaieAsset(_missingRefContainer);
|
||||
}
|
||||
|
||||
if (_missingRefContainer.MissingsResolvingDatas.Count != _cachedMissingsResolvingDatas.Length)
|
||||
{
|
||||
_cachedMissingsResolvingDatas = _missingRefContainer.MissingsResolvingDatas.Values.ToArray();
|
||||
InitList();
|
||||
}
|
||||
|
||||
var bc = EcsGUI.SetBackgroundColor(Color.black, 0.5f);
|
||||
using (EcsGUI.Layout.BeginVertical(EditorStyles.helpBox))
|
||||
{
|
||||
bc.Dispose();
|
||||
_scrollViewPosition = GUILayout.BeginScrollView(_scrollViewPosition, GUILayout.ExpandHeight(true));
|
||||
_reorderableResolvingDataList.DoLayoutList();
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
|
||||
|
||||
GUILayout.BeginVertical(GUILayout.ExpandHeight(false));
|
||||
//GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(false));
|
||||
|
||||
var data = _selectedMissingsResolvingData;
|
||||
Rect rect = GUILayoutUtility.GetRect(
|
||||
EditorGUIUtility.currentViewWidth,
|
||||
(EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * 3f + EditorGUIUtility.standardVerticalSpacing * 2f)
|
||||
.AddPadding(EditorGUIUtility.standardVerticalSpacing);
|
||||
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
using (EcsGUI.SetAlignment(TextAnchor.MiddleCenter))
|
||||
using (EcsGUI.Layout.BeginHorizontal(GUILayout.Height(26f)))
|
||||
{
|
||||
GUI.Label(rect, "Select any record");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (EcsGUI.CheckChanged())
|
||||
{
|
||||
rect.height = EditorGUIUtility.singleLineHeight;
|
||||
rect = rect.Move(0, EditorGUIUtility.standardVerticalSpacing);
|
||||
string ClassName = DrawEditableLine(rect, "Name:", data.OldTypeData.ClassName, data.NewTypeData.ClassName);
|
||||
rect = rect.Move(0, EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
|
||||
string NamespaceName = DrawEditableLine(rect, "Namespace:", data.OldTypeData.NamespaceName, data.NewTypeData.NamespaceName);
|
||||
rect = rect.Move(0, EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
|
||||
string AssemblyName = DrawEditableLine(rect, "Assembly:", data.OldTypeData.AssemblyName, data.NewTypeData.AssemblyName);
|
||||
if (EcsGUI.Changed)
|
||||
if (GUILayout.Button("Re-Collect", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(false)))
|
||||
{
|
||||
data.NewTypeData = new RefRepairer.Internal.TypeData(ClassName, NamespaceName, AssemblyName);
|
||||
|
||||
}
|
||||
if (GUILayout.Button("Repaire missing references", GUILayout.ExpandHeight(true)))
|
||||
{
|
||||
_selectedMissingsResolvingData = null;
|
||||
RepaireFileUtility.RepaieAsset(_missingRefContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user