Skip to content

Commit 63591c3

Browse files
author
BlackSpiral15
committed
Added some features in Objects Auditor and SceneFile
1 parent 09e8ad1 commit 63591c3

20 files changed

+409
-502
lines changed

Assets/DeadScriptsSearcher/Examples/DemoBroken.unity

Lines changed: 264 additions & 439 deletions
Large diffs are not rendered by default.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using UnityEngine;
2+
3+
public class EmptyScript : MonoBehaviour
4+
{
5+
// Проверочный пустой скрипт для проверки живых MonoBehaviour
6+
// Test empty script for checking alive MonoBehaviours up
7+
}

Assets/DeadScriptsSearcher/Examples/EmptyScript.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/DeadScriptsSearcher/Scripts/CoreFunctions.cs

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,24 @@
22
using UnityEngine;
33
using UnityEngine.SceneManagement;
44

5-
namespace Spiral.EditorTools.DeadScriptsSearcher
5+
namespace Spiral.Core
66
{
77
public static class CoreFunctions
88
{
9-
public static string List2String(this List<string> entry)
10-
{
11-
string output = "";
12-
int count = entry.Count;
13-
for (int e = 0; e < count; e++)
14-
{
15-
output += entry[e];
16-
if (e != count - 1) output += "\n";
17-
}
18-
return output;
19-
}
20-
21-
public static List<T> Array2List<T>(this T[] ts) where T : Object
9+
/// <summary>
10+
/// Конвертирует любой массив в лист
11+
/// </summary>
12+
/// <typeparam name="T">Тип массива</typeparam>
13+
/// <param name="ts">Входной массив</param>
14+
/// <returns>Лист на основе входногоо массив</returns>
15+
public static List<T> Array2List<T>(this T[] ts) where T : class
2216
{
23-
List<T> output = new List<T>();
24-
for (int i = 0; i < ts.Length; i++) { output.Add(ts[i]); }
25-
return output;
17+
return new List<T>(ts);
2618
}
2719

20+
/// <summary>
21+
/// Конвертирует лист Transforms в лист Game Objects
22+
/// </summary>
2823
public static List<GameObject> Transforms2GameObjects(this List<Transform> transforms)
2924
{
3025
List<GameObject> reply = new List<GameObject>();
@@ -35,6 +30,9 @@ public static List<GameObject> Transforms2GameObjects(this List<Transform> trans
3530
return reply;
3631
}
3732

33+
/// <summary>
34+
/// Конвертирует лист Game Objects в лист Transforms
35+
/// </summary>
3836
public static List<Transform> GameObjects2Transforms(this List<GameObject> gameObjects)
3937
{
4038
List<Transform> reply = new List<Transform>();
@@ -101,6 +99,23 @@ public static List<Transform> CollectScene()
10199

102100
return output;
103101
}
102+
103+
/// <summary>
104+
/// Лист в одну строчку
105+
/// </summary>
106+
/// <param name="entry"></param>
107+
/// <returns></returns>
108+
public static string List2String(this List<string> entry)
109+
{
110+
string output = "";
111+
int count = entry.Count;
112+
for (int e = 0; e < count; e++)
113+
{
114+
output += entry[e];
115+
if (e != count - 1) output += "\n";
116+
}
117+
return output;
118+
}
104119
}
105120
}
106121

Assets/DeadScriptsSearcher/Scripts/SupportClasses/ComponentID.cs renamed to Assets/DeadScriptsSearcher/Scripts/DeadScripts/ComponentID.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class ComponentID
3434
/// учётки мёртвых компонентов будут выглядеть одинаково в любом случае,
3535
/// а для живых они выполняют исключительно информационную функцию.
3636
/// </summary>
37-
public SerializedProperty monoScript { get; } = null;
37+
public SerializedProperty mScript { get; } = null;
3838

3939
/// <summary>
4040
/// Метадата токен, если понадобится
@@ -46,30 +46,39 @@ public class ComponentID
4646
/// </summary>
4747
public bool alive { get { return component != null; } }
4848

49+
/// <summary>
50+
/// GUID скрипта, если есть
51+
/// </summary>
52+
public string guid { get; private set; } = "";
53+
4954
/// <summary>
5055
/// GID компонента (позволяет однозначно идентифицировать экземпляр
5156
/// компонента в файле сцены)
5257
/// </summary>
53-
public ulong cid { get { return goid.targetObjectId; } }
58+
public ulong gid { get { return goid.targetObjectId; } }
5459

5560
public ComponentID(Component comp)
5661
{
5762
component = comp;
5863
goid = GlobalObjectId.GetGlobalObjectIdSlow(comp);
59-
64+
6065
// пациент скорее жив, чем мёртв?
6166
if (alive)
6267
{
6368
type = component.GetType();
6469
metadataToken = type.MetadataToken;
6570
var serComp = new SerializedObject(comp);
66-
monoScript = serComp.FindProperty(SceneFile.unitMonoScriptField);
71+
mScript = serComp.FindProperty(SceneFile.unitMonoScriptField);
72+
if (mScript != null)
73+
{
74+
guid = SceneFile.current.GetGUID(gid, false);
75+
}
6776
}
6877
else // пациент мёртв, мы нашли битый скрипт
6978
{
7079
type = null;
7180
metadataToken = -1;
72-
monoScript = null;
81+
mScript = null;
7382
}
7483
}
7584

Assets/DeadScriptsSearcher/Scripts/DeadScripts.cs renamed to Assets/DeadScriptsSearcher/Scripts/DeadScripts/DeadScripts.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using UnityEngine;
33
using UnityEngine.SceneManagement;
4+
using Spiral.Core;
45
using static Spiral.EditorTools.DeadScriptsSearcher.Localization;
56

67
#if UNITY_EDITOR
@@ -10,10 +11,9 @@ namespace Spiral.EditorTools.DeadScriptsSearcher
1011
public static class DeadScripts
1112
{
1213
public static bool isDebugMode = false;
13-
14+
private static SceneFile sceneFile { get { return SceneFile.current; } }
1415
public static List<ObjectID> deadOIDs { get; private set; } = new List<ObjectID>();
1516
public static List<ScriptGUID> deadGUIDs { get; private set; } = new List<ScriptGUID>();
16-
1717
public static bool sceneFileLoaded
1818
{
1919
get
@@ -23,11 +23,8 @@ public static bool sceneFileLoaded
2323
return true;
2424
}
2525
}
26-
2726
public static bool isDirty { get { return SceneManager.GetActiveScene().isDirty; } }
2827

29-
private static SceneFile sceneFile = null;
30-
3128
// FUNCTIONALITY --------------------------------------------------------------------------
3229
public static void SelectDeads()
3330
{
@@ -36,6 +33,7 @@ public static void SelectDeads()
3633

3734
public static void UpdateDeadList()
3835
{
36+
SceneFile.ReloadCurrent();
3937
var objects = CoreFunctions.CollectScene().Transforms2GameObjects();
4038
int count = objects.Count;
4139

@@ -65,7 +63,6 @@ public static void UpdateDeadList()
6563
public static void SearchForDeads()
6664
{
6765
UpdateDeadList();
68-
sceneFile = new SceneFile();
6966
deadGUIDs = new List<ScriptGUID>();
7067

7168
int count = deadOIDs.Count; // список deadOIDs сформирован функцией UpdateDeadList()

Assets/DeadScriptsSearcher/Scripts/Localization.cs renamed to Assets/DeadScriptsSearcher/Scripts/DeadScripts/Localization.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ public static void DrawLanguageSelect()
8888
"Select object(s) in scene inspector to view its/their data");
8989
public readonly static LocalString strMonoView_ShowObjectInfo = new LocalString(
9090
// ru
91-
"Развернуть",
91+
"Развернуть список компонент",
9292
// en
93-
"Show");
93+
"Show components list");
9494
public readonly static LocalString strMonoView_HideObjectInfo = new LocalString(
9595
// ru
96-
"Свернуть",
96+
"Свернуть список компонент",
9797
// en
98-
"Hide");
98+
"Hide components list");
9999

100100

101101

@@ -156,9 +156,9 @@ public static void DrawLanguageSelect()
156156
"are excluded from the search.");
157157
public readonly static LocalString strFindDeadGUIDs = new LocalString(
158158
// ru
159-
"Найти мёртвые GUID в сцене:",
159+
"Найти мёртвые GUID в сцене",
160160
// en
161-
"Find dead GUIDs in the scene:");
161+
"Find dead GUIDs in the scene");
162162
public readonly static LocalString strFoundGUIDs = new LocalString(
163163
// ru
164164
"Найдено уникальных GUID: ",

0 commit comments

Comments
 (0)