-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLibraryMetadataColoriser.cs
More file actions
39 lines (33 loc) · 963 Bytes
/
LibraryMetadataColoriser.cs
File metadata and controls
39 lines (33 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
// Colour the first two characters of the guid and library/meta path to show the relationship
public class LibraryMetadataColoriser : MonoBehaviour
{
private Text m_Text;
private void Start () {
m_Text = GetComponent<Text>();
Debug.Assert(m_Text);
}
private void LateUpdate()
{
if (!string.IsNullOrEmpty(m_Text.text))
{
Object currentObject = Selection.activeObject;
string guid;
#if UNITY_2018_2_OR_NEWER
long localID;
#else
int localID;
#endif
if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(currentObject, out guid, out localID))
{
string metaStart = guid.Substring(0, 2);
string result = m_Text.text;
result = result.Replace($"<color=yellow>{metaStart}", $"<color=yellow><b><color=red>{metaStart}</color></b>");
result = result.Replace($"/{metaStart}/", $"/<b><color=red>{metaStart}</color></b>/");
m_Text.text = result;
}
}
}
}