Skip to content

Commit

Permalink
chore: avoid warning
Browse files Browse the repository at this point in the history
  • Loading branch information
lilxyzw committed Dec 12, 2024
1 parent b7f0f5a commit e0b7395
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Assets/lilToon/Editor/lilOptimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,13 @@ private static void RewriteInputHLSL(Dictionary<string, TexProp> dicT, Dictionar
{
string optHLSL = RewriteInputHLSLText(dicT, dicD, dicF, dicC);
string pathOpt = AssetDatabase.GUIDToAssetPath("571051a232e4af44a98389bda858df27");
var fi = new FileInfo(pathOpt);
var timeC = fi.CreationTime;
var timeW = fi.LastWriteTime;
var sw = new StreamWriter(pathOpt, false);
sw.Write(optHLSL);
sw.Close();
new FileInfo(pathOpt){CreationTime = timeC, LastWriteTime = timeW};
}

private static string RewriteInputHLSLText(Dictionary<string, TexProp> dicT, Dictionary<string, STProp> dicD, Dictionary<string, FloatProp> dicF, Dictionary<string, ColorProp> dicC)
Expand Down Expand Up @@ -315,11 +319,15 @@ internal static void ResetInputHLSL()
string pathBase = AssetDatabase.GUIDToAssetPath("8ff7f7d9c86e1154fb3aac5a8a8681bb");
string pathOpt = AssetDatabase.GUIDToAssetPath("571051a232e4af44a98389bda858df27");
if(string.IsNullOrEmpty(pathBase) || string.IsNullOrEmpty(pathOpt) || !File.Exists(pathBase) || !File.Exists(pathOpt)) return;
var fi = new FileInfo(pathOpt);
var timeC = fi.CreationTime;
var timeW = fi.LastWriteTime;
var sw = new StreamWriter(pathOpt, false);
var sr = new StreamReader(pathBase);
sw.Write(sr.ReadToEnd());
sw.Close();
sr.Close();
new FileInfo(pathOpt){CreationTime = timeC, LastWriteTime = timeW};
}

private static string GetIndent(int indent)
Expand Down
9 changes: 8 additions & 1 deletion Assets/lilToon/Editor/lilToonSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,14 @@ internal static void ApplyShaderSetting(lilToonSetting shaderSetting, string rep
if(shaderPath.Contains(".lilcontainer")) continue;

string baseShaderPath = baseShaderFolderPath + Path.AltDirectorySeparatorChar + Path.GetFileNameWithoutExtension(shaderPath) + ".lilinternal";
if(File.Exists(baseShaderPath)) File.WriteAllText(shaderPath, lilShaderContainer.UnpackContainer(baseShaderPath, null, doOptimize));
if(!File.Exists(baseShaderPath)) continue;

// Change without updating FileInfo
var fi = new FileInfo(shaderPath);
var timeC = fi.CreationTime;
var timeW = fi.LastWriteTime;
File.WriteAllText(shaderPath, lilShaderContainer.UnpackContainer(baseShaderPath, null, doOptimize));
new FileInfo(shaderPath){CreationTime = timeC, LastWriteTime = timeW};
}
foreach(var shaderPath in shaderPathes)
{
Expand Down

0 comments on commit e0b7395

Please sign in to comment.