-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/build warnings 2024 09 15 #159
base: development
Are you sure you want to change the base?
Changes from all commits
31eb773
fa94257
09f0d3f
f8f2ebe
f9cdd59
2277029
90aef82
191e341
aea007d
4497acf
96f5777
3a622ba
56e3ef1
9ac5c96
194948f
0e6c93e
398b8e6
571d458
3f7fb2c
3adbc9b
d7a54f2
93617ed
65d1ffb
6e6f8fe
8eb1d48
e302443
aca944c
792893f
4c695f1
100488f
0791469
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ public static AssetDirectoryCache GetRootFolderCache(int index) | |
public static void AddRootFolder(string rootFolder) | ||
{ | ||
ArgumentException.ThrowIfNullOrEmpty(rootFolder); | ||
ArgumentNullException.ThrowIfNull(Project.Active); | ||
|
||
var rootPath = Path.Combine(Project.Active.ProjectPath, rootFolder); | ||
var info = new DirectoryInfo(rootPath); | ||
|
@@ -139,7 +140,7 @@ public static void Update(bool doUnload = true, bool forceCacheUpdate = false) | |
if (ProcessFile(file, out _)) | ||
toReimport.Add(file); | ||
} | ||
else if (!assetPathToMeta.TryGetValue(file, out var meta)) | ||
else if (!assetPathToMeta.TryGetValue(file, out _)) | ||
{ | ||
// File hasent changed but we dont have it in the cache, process it but dont reimport | ||
Debug.Log("Asset Found: " + file); | ||
|
@@ -168,7 +169,7 @@ public static void Update(bool doUnload = true, bool forceCacheUpdate = false) | |
cacheModified = true; | ||
bool hasMeta = assetPathToMeta.TryGetValue(file, out var meta); | ||
|
||
if (hasMeta) | ||
if (hasMeta && meta is not null) | ||
{ | ||
assetPathToMeta.Remove(file); | ||
|
||
|
@@ -248,7 +249,7 @@ static bool ProcessFile(string file, out bool metaOutdated) | |
{ | ||
// No meta file, create and import | ||
var newMeta = new MetaFile(fileInfo); | ||
if (newMeta.importer == null) | ||
if (newMeta.Importer == null) | ||
{ | ||
Debug.LogError($"No importer found for file:\n{fileInfo.FullName}"); | ||
return false; | ||
|
@@ -351,17 +352,18 @@ public static bool Reimport(FileInfo assetFile, bool disposeExisting = true) | |
Debug.LogError($"No valid meta file found for asset: {ToRelativePath(assetFile)}"); | ||
return false; | ||
} | ||
if (meta.importer == null) | ||
{ | ||
Debug.LogError($"No valid importer found for asset: {ToRelativePath(assetFile)}"); | ||
return false; | ||
} | ||
// TODO: FIXME: its always not null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If they modify the meta file itself for example breaking or removing the importer, then load it into the editor, the Meta file will successfully load however Importer will be null. So this check is required for that edge case. Not sure why the compiler says it cant be null. |
||
// if (meta.Importer == null) | ||
// { | ||
// Debug.LogError($"No valid importer found for asset: {ToRelativePath(assetFile)}"); | ||
// return false; | ||
// } | ||
|
||
// Import the asset | ||
SerializedAsset ctx = new(meta.guid); | ||
try | ||
{ | ||
meta.importer.Import(ctx, assetFile); | ||
meta.Importer.Import(ctx, assetFile); | ||
} | ||
catch (Exception e) | ||
{ | ||
|
@@ -494,8 +496,11 @@ public static bool Reimport(FileInfo assetFile, bool disposeExisting = true) | |
{ | ||
var serializedAsset = SerializedAsset.FromSerializedAsset(serializedAssetPath.FullName); | ||
serializedAsset.Guid = assetGuid; | ||
serializedAsset.Main.AssetID = assetGuid; | ||
serializedAsset.Main.FileID = 0; | ||
if (serializedAsset.Main is not null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should throw an error, Main not existing is an entirely broken asset, main should always exist. |
||
{ | ||
serializedAsset.Main.AssetID = assetGuid; | ||
serializedAsset.Main.FileID = 0; | ||
} | ||
for (int i = 0; i < serializedAsset.SubAssets.Count; i++) | ||
{ | ||
serializedAsset.SubAssets[i].AssetID = assetGuid; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably throw an error instead of continuing past as Meta being null here while hasMeta is true is pretty bad and should never occur.