-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathAssetsFileDependency.cs
More file actions
75 lines (73 loc) · 2.92 KB
/
AssetsFileDependency.cs
File metadata and controls
75 lines (73 loc) · 2.92 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AssetsTools.NET
{
public class AssetsFileDependency
{
public struct GUID128
{
public long mostSignificant;
public long leastSignificant;
public void Read(AssetsFileStatefulReader reader)
{
mostSignificant = reader.ReadInt64();
leastSignificant = reader.ReadInt64();
}
public void Write(AssetsFileWriter writer)
{
writer.Write(mostSignificant);
writer.Write(leastSignificant);
}
}
public string bufferedPath;
public GUID128 guid;
public int type;
public string assetPath;
public string originalAssetPath;
public void Read(AssetsFileStatefulReader reader)
{
bufferedPath = reader.ReadNullTerminated();
guid = new GUID128();
guid.Read(reader);
type = reader.ReadInt32();
assetPath = reader.ReadNullTerminated();
originalAssetPath = assetPath;
//because lowercase "resources" is read by unity fine on linux, it either uses
//hardcoded replaces like below or it has case insensitive pathing somehow
//this isn't consistent with the original assetstools but it only supported
//windows anyway, so this will only create issues if more than these three
//pop up in the future. also, the reason I don't just replace all "library"
//with "Resources" is so that when saving, I can change it back to the original
//(like how unity_builtin_extra goes back to "resources", not "library")
if (assetPath == "resources/unity_builtin_extra")
{
assetPath = "Resources/unity_builtin_extra";
}
else if (assetPath == "library/unity default resources" || assetPath == "Library/unity default resources")
{
assetPath = "Resources/unity default resources";
}
else if (assetPath == "library/unity editor resources" || assetPath == "Library/unity editor resources")
{
assetPath = "Resources/unity editor resources";
}
}
public void Write(AssetsFileWriter writer)
{
writer.WriteNullTerminated(bufferedPath);
guid.Write(writer);
writer.Write(type);
string assetPathTemp = assetPath;
if ((assetPath == "Resources/unity_builtin_extra" ||
assetPath == "Resources/unity default resources" ||
assetPath == "Resources/unity editor resources")
&& originalAssetPath != string.Empty)
{
assetPathTemp = originalAssetPath;
}
writer.WriteNullTerminated(assetPathTemp);
}
}
}