From 1fcde9ff07c75cda44899624437b074f59e83070 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 19 Aug 2026 10:26:54 +0100 Subject: [PATCH 1/2] Use ResourceLoader --- README.md | 44 +++++++++---------- .../InstantiableTemplate.scriban | 2 +- .../OnInstantiateTemplate.scriban | 2 +- .../ResourceTreeTemplate.scriban | 4 +- .../SceneTreeExtensions/Resources.cs | 6 +-- .../ShaderExtensions/ShaderTemplate.scriban | 6 +-- .../ShaderGlobalsDataModel.cs | 2 +- .../SingletonTemplate.scriban | 2 +- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 25fd4ecb..3a8c288b 100644 --- a/README.md +++ b/README.md @@ -175,18 +175,18 @@ public void NextScene() where T : ISceneTree public partial interface IInstantiable { static T Instantiate() where T : Node, ISceneTree - => GD.Load(T.TscnFilePath).Instantiate(); + => ResourceLoader.Load(T.TscnFilePath).Instantiate(); } public partial interface IInstantiable where T : Node, IInstantiable, ISceneTree { - static T Instantiate() => GD.Load(T.TscnFilePath).Instantiate(); + static T Instantiate() => ResourceLoader.Load(T.TscnFilePath).Instantiate(); } public static partial class Instantiator { public static T Instantiate() where T : Node, ISceneTree - => GD.Load(T.TscnFilePath).Instantiate(); + => ResourceLoader.Load(T.TscnFilePath).Instantiate(); } ``` Usage: @@ -612,7 +612,7 @@ Generates: partial class Scene1 { [EditorBrowsable(EditorBrowsableState.Never)] - private static PackedScene _Scene1 => field ??= GD.Load("res://Path/To/Scene1.tscn"); + private static PackedScene _Scene1 => field ??= ResourceLoader.Load("res://Path/To/Scene1.tscn"); public static Scene1 New() => (Scene1)_Scene1.Instantiate(); @@ -622,7 +622,7 @@ partial class Scene1 partial class Scene2 { [EditorBrowsable(EditorBrowsableState.Never)] - private static PackedScene _Scene2 => field ??= GD.Load("res://Path/To/Scene2.tscn"); + private static PackedScene _Scene2 => field ??= ResourceLoader.Load("res://Path/To/Scene2.tscn"); public static Scene2 New() { @@ -644,7 +644,7 @@ partial class Scene2 partial class Scene3 { [EditorBrowsable(EditorBrowsableState.Never)] - private static PackedScene _Scene3 => field ??= GD.Load("res://Path/To/Scene3.tscn"); + private static PackedScene _Scene3 => field ??= ResourceLoader.Load("res://Path/To/Scene3.tscn"); public static Scene3 Instantiate(int arg1, string arg2, object arg3 = null) { @@ -845,7 +845,7 @@ Generates: partial class MyScene { [EditorBrowsable(EditorBrowsableState.Never)] - private static PackedScene _MyScene => field ??= GD.Load("res://Path/To/MyScene.tscn"); + private static PackedScene _MyScene => field ??= ResourceLoader.Load("res://Path/To/MyScene.tscn"); public static MyScene Instantiate(string myArg1, int myArg2) { @@ -894,8 +894,8 @@ Usage: //[ResourceTree("./Assets")] // Scan from /Assets //[ResourceTree("res://Assets")] // Scan from res://Assets -//[ResourceTree(resg: ResG.LoadRes)] // Generate strongly typed properties that call GD.Load (default) -//[ResourceTree(resg: ResG.ResPaths)] // Generate resource paths for files (in addition to or instead of GD.Load) +//[ResourceTree(resg: ResG.LoadRes)] // Generate strongly typed properties that call ResourceLoader.Load (default) +//[ResourceTree(resg: ResG.ResPaths)] // Generate resource paths for files (in addition to or instead of ResourceLoader.Load) //[ResourceTree(resg: ResG.DirPaths)] // Generate resource paths for directories //[ResourceTree(resg: ResG.All)] // Everything @@ -932,7 +932,7 @@ partial class MyRes public static partial class IconSvg // -- (Res.ResPaths | Res.Load - generates nested type) { public static string ResPath => "res://Assets/icon.svg"; - public static CompressedTexture2D Load() => GD.Load(ResPath); + public static CompressedTexture2D Load() => ResourceLoader.Load(ResPath); } public static string HelpTxt => "res://Assets/Help.txt"; // -- (xtras - always generated as resource path) @@ -944,13 +944,13 @@ partial class MyRes public static class TrEnTranslation // -- (uses importer generated files instead of raw input file) { public static string ResPath => "res://Assets/tr/tr.en.translation"; - public static OptimizedTranslation Load() => GD.Load(ResPath); + public static OptimizedTranslation Load() => ResourceLoader.Load(ResPath); } public static class TrFrTranslation { public static string ResPath => "res://Assets/tr/tr.fr.translation"; - public static OptimizedTranslation Load() => GD.Load(ResPath); + public static OptimizedTranslation Load() => ResourceLoader.Load(ResPath); } } } @@ -962,19 +962,19 @@ partial class MyRes public static class MySceneTscn { public static string ResPath => "res://Scenes/MyScene.tscn"; - public static PackedScene Load() => GD.Load(ResPath); + public static PackedScene Load() => ResourceLoader.Load(ResPath); } public static class MySceneGd { public static string ResPath => "res://Scenes/MyScene.gd"; - public static GDScript Load() => GD.Load(ResPath); + public static GDScript Load() => ResourceLoader.Load(ResPath); } public static class MySceneCs { public static string ResPath => "res://Scenes/MyScene.cs"; - public static CSharpScript Load() => GD.Load(ResPath); + public static CSharpScript Load() => ResourceLoader.Load(ResPath); } public static string MySceneCsUid => "uid://tyjsxc2njtw2"; // -- (Res.Uid) @@ -993,12 +993,12 @@ partial class MyRes { public static partial class Assets { - public static CompressedTexture2D IconSvg => GD.Load("res://Assets/icon.svg"); + public static CompressedTexture2D IconSvg => ResourceLoader.Load("res://Assets/icon.svg"); public static class Tr { - public static OptimizedTranslation TrEnTranslation => GD.Load("res://Assets/tr/tr.en.translation"); - public static OptimizedTranslation TrFrTranslation => GD.Load("res://Assets/tr/tr.fr.translation"); + public static OptimizedTranslation TrEnTranslation => ResourceLoader.Load("res://Assets/tr/tr.en.translation"); + public static OptimizedTranslation TrFrTranslation => ResourceLoader.Load("res://Assets/tr/tr.fr.translation"); } } } @@ -1090,7 +1090,7 @@ Generates: partial class MyShader { public const string ShaderPath = "res://Path/To/MyShader.gdshader"; - public static Shader LoadShader() => GD.Load(ShaderPath); + public static Shader LoadShader() => ResourceLoader.Load(ShaderPath); public ShaderMaterial Material { get; private init; } @@ -1154,7 +1154,7 @@ Generates: static partial class MyShader { public const string ShaderPath = "res://Path/To/MyShader.gdshader"; - public static Shader LoadShader() => GD.Load(ShaderPath); + public static Shader LoadShader() => ResourceLoader.Load(ShaderPath); public static ShaderMaterial New() => NewMaterial(); public static ShaderMaterial NewMaterial() { @@ -1205,7 +1205,7 @@ Generates: partial class MyShader { public const string ShaderPath = "res://Path/To/MyShader.gdshader"; - public static Shader LoadShader() => GD.Load(ShaderPath); + public static Shader LoadShader() => ResourceLoader.Load(ShaderPath); public MyShader() { @@ -1336,7 +1336,7 @@ partial class MyNode partial class MyScene { - public static MyScene Instance { get; } = InitScene((MyScene)GD.Load("res://PathTo/MyScene.tscn").Instantiate()); + public static MyScene Instance { get; } = InitScene((MyScene)ResourceLoader.Load("res://PathTo/MyScene.tscn").Instantiate()); [EditorBrowsable(EditorBrowsableState.Never)] private static MyScene InitScene(MyScene x) { x.InitScene(); return x; } private MyScene() { } } diff --git a/SourceGenerators/InstantiableExtensions/InstantiableTemplate.scriban b/SourceGenerators/InstantiableExtensions/InstantiableTemplate.scriban index 03d8e00f..7d9a036b 100644 --- a/SourceGenerators/InstantiableExtensions/InstantiableTemplate.scriban +++ b/SourceGenerators/InstantiableExtensions/InstantiableTemplate.scriban @@ -5,7 +5,7 @@ private static PackedScene __{{ClassName}}; [{{EditorBrowsableNever}}] - private static PackedScene _{{ClassName}} => __{{ClassName}} ??= GD.Load("{{Tscn}}"); + private static PackedScene _{{ClassName}} => __{{ClassName}} ??= ResourceLoader.Load("{{Tscn}}"); #nullable restore {{~ if InitList.empty? ~}} diff --git a/SourceGenerators/OnInstantiateExtensions/OnInstantiateTemplate.scriban b/SourceGenerators/OnInstantiateExtensions/OnInstantiateTemplate.scriban index d653b354..1a4c9074 100644 --- a/SourceGenerators/OnInstantiateExtensions/OnInstantiateTemplate.scriban +++ b/SourceGenerators/OnInstantiateExtensions/OnInstantiateTemplate.scriban @@ -12,7 +12,7 @@ partial class {{ClassName}} private static PackedScene __scene__; [EditorBrowsable(EditorBrowsableState.Never)] - private static PackedScene __Scene__ => __scene__ ??= GD.Load("{{ResourcePath}}"); + private static PackedScene __Scene__ => __scene__ ??= ResourceLoader.Load("{{ResourcePath}}"); {{~ end ~}} #nullable restore diff --git a/SourceGenerators/ResourceTreeExtensions/ResourceTreeTemplate.scriban b/SourceGenerators/ResourceTreeExtensions/ResourceTreeTemplate.scriban index 23d9e306..ef25fc97 100644 --- a/SourceGenerators/ResourceTreeExtensions/ResourceTreeTemplate.scriban +++ b/SourceGenerators/ResourceTreeExtensions/ResourceTreeTemplate.scriban @@ -6,10 +6,10 @@ {{~ TAB depth}}public static class {{SAFE_NAME node depth}} {{~ TAB depth}}{ {{~ TAB depth}} public static string ResPath => "{{node.Value.Path}}"; - {{~ TAB depth}} public static {{node.Value.Type}} Load() => GD.Load<{{node.Value.Type}}>(ResPath); + {{~ TAB depth}} public static {{node.Value.Type}} Load() => ResourceLoader.Load<{{node.Value.Type}}>(ResPath); {{~ TAB depth}}} {{~ else ~}} - {{~ TAB depth}}public static {{node.Value.Type}} {{node.Value.Name}} => GD.Load<{{node.Value.Type}}>("{{node.Value.Path}}"); + {{~ TAB depth}}public static {{node.Value.Type}} {{node.Value.Name}} => ResourceLoader.Load<{{node.Value.Type}}>("{{node.Value.Path}}"); {{~ end ~}} {{~ else ~}} {{~ if node.Value.Show ~}} diff --git a/SourceGenerators/SceneTreeExtensions/Resources.cs b/SourceGenerators/SceneTreeExtensions/Resources.cs index 62de57de..63a641ad 100644 --- a/SourceGenerators/SceneTreeExtensions/Resources.cs +++ b/SourceGenerators/SceneTreeExtensions/Resources.cs @@ -23,19 +23,19 @@ namespace Godot; public partial interface IInstantiable where T : Node, IInstantiable, ISceneTree { - static T Instantiate() => GD.Load(T.TscnFilePath).Instantiate(); + static T Instantiate() => ResourceLoader.Load(T.TscnFilePath).Instantiate(); } public partial interface IInstantiable { static T Instantiate() where T : Node, ISceneTree - => GD.Load(T.TscnFilePath).Instantiate(); + => ResourceLoader.Load(T.TscnFilePath).Instantiate(); } public static partial class Instantiator { public static T Instantiate() where T : Node, ISceneTree - => GD.Load(T.TscnFilePath).Instantiate(); + => ResourceLoader.Load(T.TscnFilePath).Instantiate(); } #endif".Trim(); } diff --git a/SourceGenerators/ShaderExtensions/ShaderTemplate.scriban b/SourceGenerators/ShaderExtensions/ShaderTemplate.scriban index 779e0245..ecc5ad93 100644 --- a/SourceGenerators/ShaderExtensions/ShaderTemplate.scriban +++ b/SourceGenerators/ShaderExtensions/ShaderTemplate.scriban @@ -2,7 +2,7 @@ {{~ func STATIC ~}} public const string ShaderPath = "{{ShaderPath}}"; - public static {{ShaderType}} LoadShader() => GD.Load<{{ShaderType}}>(ShaderPath); + public static {{ShaderType}} LoadShader() => ResourceLoader.Load<{{ShaderType}}>(ShaderPath); public static ShaderMaterial New() => NewMaterial(); public static ShaderMaterial NewMaterial() { @@ -124,7 +124,7 @@ {{~ func MATERIAL ~}} public const string ShaderPath = "{{ShaderPath}}"; - public static {{ShaderType}} LoadShader() => GD.Load<{{ShaderType}}>(ShaderPath); + public static {{ShaderType}} LoadShader() => ResourceLoader.Load<{{ShaderType}}>(ShaderPath); public {{ClassName}}() { @@ -233,7 +233,7 @@ {{~ func OTHER ~}} public const string ShaderPath = "{{ShaderPath}}"; - public static {{ShaderType}} LoadShader() => GD.Load<{{ShaderType}}>(ShaderPath); + public static {{ShaderType}} LoadShader() => ResourceLoader.Load<{{ShaderType}}>(ShaderPath); public ShaderMaterial Material { get; private init; } diff --git a/SourceGenerators/ShaderGlobalsExtensions/ShaderGlobalsDataModel.cs b/SourceGenerators/ShaderGlobalsExtensions/ShaderGlobalsDataModel.cs index f9398e96..96a71d51 100644 --- a/SourceGenerators/ShaderGlobalsExtensions/ShaderGlobalsDataModel.cs +++ b/SourceGenerators/ShaderGlobalsExtensions/ShaderGlobalsDataModel.cs @@ -66,7 +66,7 @@ string ConvertValue(string v) return v is null ? null : TryAsRes() ?? TryAsCtor() ?? SafeValue(v); string TryAsRes() - => v.StartsWith("res://") ? @$"GD.Load<{csType}>(""{v}"")" : null; + => v.StartsWith("res://") ? @$"ResourceLoader.Load<{csType}>(""{v}"")" : null; string TryAsCtor() { diff --git a/SourceGenerators/SingletonExtensions/SingletonTemplate.scriban b/SourceGenerators/SingletonExtensions/SingletonTemplate.scriban index e11f8bf0..a4be865b 100644 --- a/SourceGenerators/SingletonExtensions/SingletonTemplate.scriban +++ b/SourceGenerators/SingletonExtensions/SingletonTemplate.scriban @@ -2,7 +2,7 @@ {{- capture new -}} {{- if TSCN -}} - ({{ClassName}})GD.Load("{{TSCN}}").Instantiate() + ({{ClassName}})ResourceLoader.Load("{{TSCN}}").Instantiate() {{- else -}} new() {{- end -}} From e1fa6982274f39fd74324c10f63f2061235dac4b Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 19 Aug 2026 10:51:59 +0100 Subject: [PATCH 2/2] Use cacheMode = IgnoreDeep --- README.md | 40 +++++++++---------- .../InstantiableTemplate.scriban | 2 +- .../OnInstantiateTemplate.scriban | 2 +- .../ResourceTreeTemplate.scriban | 4 +- .../SceneTreeExtensions/Resources.cs | 6 +-- .../ShaderExtensions/ShaderTemplate.scriban | 6 +-- .../ShaderGlobalsDataModel.cs | 2 +- .../SingletonTemplate.scriban | 2 +- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 3a8c288b..3bc4e964 100644 --- a/README.md +++ b/README.md @@ -175,18 +175,18 @@ public void NextScene() where T : ISceneTree public partial interface IInstantiable { static T Instantiate() where T : Node, ISceneTree - => ResourceLoader.Load(T.TscnFilePath).Instantiate(); + => ResourceLoader.Load(T.TscnFilePath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep).Instantiate(); } public partial interface IInstantiable where T : Node, IInstantiable, ISceneTree { - static T Instantiate() => ResourceLoader.Load(T.TscnFilePath).Instantiate(); + static T Instantiate() => ResourceLoader.Load(T.TscnFilePath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep).Instantiate(); } public static partial class Instantiator { public static T Instantiate() where T : Node, ISceneTree - => ResourceLoader.Load(T.TscnFilePath).Instantiate(); + => ResourceLoader.Load(T.TscnFilePath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep).Instantiate(); } ``` Usage: @@ -612,7 +612,7 @@ Generates: partial class Scene1 { [EditorBrowsable(EditorBrowsableState.Never)] - private static PackedScene _Scene1 => field ??= ResourceLoader.Load("res://Path/To/Scene1.tscn"); + private static PackedScene _Scene1 => field ??= ResourceLoader.Load("res://Path/To/Scene1.tscn", cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public static Scene1 New() => (Scene1)_Scene1.Instantiate(); @@ -622,7 +622,7 @@ partial class Scene1 partial class Scene2 { [EditorBrowsable(EditorBrowsableState.Never)] - private static PackedScene _Scene2 => field ??= ResourceLoader.Load("res://Path/To/Scene2.tscn"); + private static PackedScene _Scene2 => field ??= ResourceLoader.Load("res://Path/To/Scene2.tscn", cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public static Scene2 New() { @@ -644,7 +644,7 @@ partial class Scene2 partial class Scene3 { [EditorBrowsable(EditorBrowsableState.Never)] - private static PackedScene _Scene3 => field ??= ResourceLoader.Load("res://Path/To/Scene3.tscn"); + private static PackedScene _Scene3 => field ??= ResourceLoader.Load("res://Path/To/Scene3.tscn", cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public static Scene3 Instantiate(int arg1, string arg2, object arg3 = null) { @@ -845,7 +845,7 @@ Generates: partial class MyScene { [EditorBrowsable(EditorBrowsableState.Never)] - private static PackedScene _MyScene => field ??= ResourceLoader.Load("res://Path/To/MyScene.tscn"); + private static PackedScene _MyScene => field ??= ResourceLoader.Load("res://Path/To/MyScene.tscn", cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public static MyScene Instantiate(string myArg1, int myArg2) { @@ -932,7 +932,7 @@ partial class MyRes public static partial class IconSvg // -- (Res.ResPaths | Res.Load - generates nested type) { public static string ResPath => "res://Assets/icon.svg"; - public static CompressedTexture2D Load() => ResourceLoader.Load(ResPath); + public static CompressedTexture2D Load() => ResourceLoader.Load(ResPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); } public static string HelpTxt => "res://Assets/Help.txt"; // -- (xtras - always generated as resource path) @@ -944,13 +944,13 @@ partial class MyRes public static class TrEnTranslation // -- (uses importer generated files instead of raw input file) { public static string ResPath => "res://Assets/tr/tr.en.translation"; - public static OptimizedTranslation Load() => ResourceLoader.Load(ResPath); + public static OptimizedTranslation Load() => ResourceLoader.Load(ResPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); } public static class TrFrTranslation { public static string ResPath => "res://Assets/tr/tr.fr.translation"; - public static OptimizedTranslation Load() => ResourceLoader.Load(ResPath); + public static OptimizedTranslation Load() => ResourceLoader.Load(ResPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); } } } @@ -962,19 +962,19 @@ partial class MyRes public static class MySceneTscn { public static string ResPath => "res://Scenes/MyScene.tscn"; - public static PackedScene Load() => ResourceLoader.Load(ResPath); + public static PackedScene Load() => ResourceLoader.Load(ResPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); } public static class MySceneGd { public static string ResPath => "res://Scenes/MyScene.gd"; - public static GDScript Load() => ResourceLoader.Load(ResPath); + public static GDScript Load() => ResourceLoader.Load(ResPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); } public static class MySceneCs { public static string ResPath => "res://Scenes/MyScene.cs"; - public static CSharpScript Load() => ResourceLoader.Load(ResPath); + public static CSharpScript Load() => ResourceLoader.Load(ResPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); } public static string MySceneCsUid => "uid://tyjsxc2njtw2"; // -- (Res.Uid) @@ -993,12 +993,12 @@ partial class MyRes { public static partial class Assets { - public static CompressedTexture2D IconSvg => ResourceLoader.Load("res://Assets/icon.svg"); + public static CompressedTexture2D IconSvg => ResourceLoader.Load("res://Assets/icon.svg", cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public static class Tr { - public static OptimizedTranslation TrEnTranslation => ResourceLoader.Load("res://Assets/tr/tr.en.translation"); - public static OptimizedTranslation TrFrTranslation => ResourceLoader.Load("res://Assets/tr/tr.fr.translation"); + public static OptimizedTranslation TrEnTranslation => ResourceLoader.Load("res://Assets/tr/tr.en.translation", cacheMode: ResourceLoader.CacheMode.IgnoreDeep); + public static OptimizedTranslation TrFrTranslation => ResourceLoader.Load("res://Assets/tr/tr.fr.translation", cacheMode: ResourceLoader.CacheMode.IgnoreDeep); } } } @@ -1090,7 +1090,7 @@ Generates: partial class MyShader { public const string ShaderPath = "res://Path/To/MyShader.gdshader"; - public static Shader LoadShader() => ResourceLoader.Load(ShaderPath); + public static Shader LoadShader() => ResourceLoader.Load(ShaderPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public ShaderMaterial Material { get; private init; } @@ -1154,7 +1154,7 @@ Generates: static partial class MyShader { public const string ShaderPath = "res://Path/To/MyShader.gdshader"; - public static Shader LoadShader() => ResourceLoader.Load(ShaderPath); + public static Shader LoadShader() => ResourceLoader.Load(ShaderPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public static ShaderMaterial New() => NewMaterial(); public static ShaderMaterial NewMaterial() { @@ -1205,7 +1205,7 @@ Generates: partial class MyShader { public const string ShaderPath = "res://Path/To/MyShader.gdshader"; - public static Shader LoadShader() => ResourceLoader.Load(ShaderPath); + public static Shader LoadShader() => ResourceLoader.Load(ShaderPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public MyShader() { @@ -1336,7 +1336,7 @@ partial class MyNode partial class MyScene { - public static MyScene Instance { get; } = InitScene((MyScene)ResourceLoader.Load("res://PathTo/MyScene.tscn").Instantiate()); + public static MyScene Instance { get; } = InitScene((MyScene)ResourceLoader.Load("res://PathTo/MyScene.tscn", cacheMode: ResourceLoader.CacheMode.IgnoreDeep).Instantiate()); [EditorBrowsable(EditorBrowsableState.Never)] private static MyScene InitScene(MyScene x) { x.InitScene(); return x; } private MyScene() { } } diff --git a/SourceGenerators/InstantiableExtensions/InstantiableTemplate.scriban b/SourceGenerators/InstantiableExtensions/InstantiableTemplate.scriban index 7d9a036b..325b6cb1 100644 --- a/SourceGenerators/InstantiableExtensions/InstantiableTemplate.scriban +++ b/SourceGenerators/InstantiableExtensions/InstantiableTemplate.scriban @@ -5,7 +5,7 @@ private static PackedScene __{{ClassName}}; [{{EditorBrowsableNever}}] - private static PackedScene _{{ClassName}} => __{{ClassName}} ??= ResourceLoader.Load("{{Tscn}}"); + private static PackedScene _{{ClassName}} => __{{ClassName}} ??= ResourceLoader.Load("{{Tscn}}", cacheMode: ResourceLoader.CacheMode.IgnoreDeep); #nullable restore {{~ if InitList.empty? ~}} diff --git a/SourceGenerators/OnInstantiateExtensions/OnInstantiateTemplate.scriban b/SourceGenerators/OnInstantiateExtensions/OnInstantiateTemplate.scriban index 1a4c9074..e59cca3c 100644 --- a/SourceGenerators/OnInstantiateExtensions/OnInstantiateTemplate.scriban +++ b/SourceGenerators/OnInstantiateExtensions/OnInstantiateTemplate.scriban @@ -12,7 +12,7 @@ partial class {{ClassName}} private static PackedScene __scene__; [EditorBrowsable(EditorBrowsableState.Never)] - private static PackedScene __Scene__ => __scene__ ??= ResourceLoader.Load("{{ResourcePath}}"); + private static PackedScene __Scene__ => __scene__ ??= ResourceLoader.Load("{{ResourcePath}}", cacheMode: ResourceLoader.CacheMode.IgnoreDeep); {{~ end ~}} #nullable restore diff --git a/SourceGenerators/ResourceTreeExtensions/ResourceTreeTemplate.scriban b/SourceGenerators/ResourceTreeExtensions/ResourceTreeTemplate.scriban index ef25fc97..a0308ea8 100644 --- a/SourceGenerators/ResourceTreeExtensions/ResourceTreeTemplate.scriban +++ b/SourceGenerators/ResourceTreeExtensions/ResourceTreeTemplate.scriban @@ -6,10 +6,10 @@ {{~ TAB depth}}public static class {{SAFE_NAME node depth}} {{~ TAB depth}}{ {{~ TAB depth}} public static string ResPath => "{{node.Value.Path}}"; - {{~ TAB depth}} public static {{node.Value.Type}} Load() => ResourceLoader.Load<{{node.Value.Type}}>(ResPath); + {{~ TAB depth}} public static {{node.Value.Type}} Load() => ResourceLoader.Load<{{node.Value.Type}}>(ResPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); {{~ TAB depth}}} {{~ else ~}} - {{~ TAB depth}}public static {{node.Value.Type}} {{node.Value.Name}} => ResourceLoader.Load<{{node.Value.Type}}>("{{node.Value.Path}}"); + {{~ TAB depth}}public static {{node.Value.Type}} {{node.Value.Name}} => ResourceLoader.Load<{{node.Value.Type}}>("{{node.Value.Path}}", cacheMode: ResourceLoader.CacheMode.IgnoreDeep); {{~ end ~}} {{~ else ~}} {{~ if node.Value.Show ~}} diff --git a/SourceGenerators/SceneTreeExtensions/Resources.cs b/SourceGenerators/SceneTreeExtensions/Resources.cs index 63a641ad..22bb2cc6 100644 --- a/SourceGenerators/SceneTreeExtensions/Resources.cs +++ b/SourceGenerators/SceneTreeExtensions/Resources.cs @@ -23,19 +23,19 @@ namespace Godot; public partial interface IInstantiable where T : Node, IInstantiable, ISceneTree { - static T Instantiate() => ResourceLoader.Load(T.TscnFilePath).Instantiate(); + static T Instantiate() => ResourceLoader.Load(T.TscnFilePath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep).Instantiate(); } public partial interface IInstantiable { static T Instantiate() where T : Node, ISceneTree - => ResourceLoader.Load(T.TscnFilePath).Instantiate(); + => ResourceLoader.Load(T.TscnFilePath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep).Instantiate(); } public static partial class Instantiator { public static T Instantiate() where T : Node, ISceneTree - => ResourceLoader.Load(T.TscnFilePath).Instantiate(); + => ResourceLoader.Load(T.TscnFilePath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep).Instantiate(); } #endif".Trim(); } diff --git a/SourceGenerators/ShaderExtensions/ShaderTemplate.scriban b/SourceGenerators/ShaderExtensions/ShaderTemplate.scriban index ecc5ad93..0ee9d06e 100644 --- a/SourceGenerators/ShaderExtensions/ShaderTemplate.scriban +++ b/SourceGenerators/ShaderExtensions/ShaderTemplate.scriban @@ -2,7 +2,7 @@ {{~ func STATIC ~}} public const string ShaderPath = "{{ShaderPath}}"; - public static {{ShaderType}} LoadShader() => ResourceLoader.Load<{{ShaderType}}>(ShaderPath); + public static {{ShaderType}} LoadShader() => ResourceLoader.Load<{{ShaderType}}>(ShaderPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public static ShaderMaterial New() => NewMaterial(); public static ShaderMaterial NewMaterial() { @@ -124,7 +124,7 @@ {{~ func MATERIAL ~}} public const string ShaderPath = "{{ShaderPath}}"; - public static {{ShaderType}} LoadShader() => ResourceLoader.Load<{{ShaderType}}>(ShaderPath); + public static {{ShaderType}} LoadShader() => ResourceLoader.Load<{{ShaderType}}>(ShaderPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public {{ClassName}}() { @@ -233,7 +233,7 @@ {{~ func OTHER ~}} public const string ShaderPath = "{{ShaderPath}}"; - public static {{ShaderType}} LoadShader() => ResourceLoader.Load<{{ShaderType}}>(ShaderPath); + public static {{ShaderType}} LoadShader() => ResourceLoader.Load<{{ShaderType}}>(ShaderPath, cacheMode: ResourceLoader.CacheMode.IgnoreDeep); public ShaderMaterial Material { get; private init; } diff --git a/SourceGenerators/ShaderGlobalsExtensions/ShaderGlobalsDataModel.cs b/SourceGenerators/ShaderGlobalsExtensions/ShaderGlobalsDataModel.cs index 96a71d51..b8aafa35 100644 --- a/SourceGenerators/ShaderGlobalsExtensions/ShaderGlobalsDataModel.cs +++ b/SourceGenerators/ShaderGlobalsExtensions/ShaderGlobalsDataModel.cs @@ -66,7 +66,7 @@ string ConvertValue(string v) return v is null ? null : TryAsRes() ?? TryAsCtor() ?? SafeValue(v); string TryAsRes() - => v.StartsWith("res://") ? @$"ResourceLoader.Load<{csType}>(""{v}"")" : null; + => v.StartsWith("res://") ? @$"ResourceLoader.Load<{csType}>(""{v}"", cacheMode: ResourceLoader.CacheMode.IgnoreDeep)" : null; string TryAsCtor() { diff --git a/SourceGenerators/SingletonExtensions/SingletonTemplate.scriban b/SourceGenerators/SingletonExtensions/SingletonTemplate.scriban index a4be865b..ac93451f 100644 --- a/SourceGenerators/SingletonExtensions/SingletonTemplate.scriban +++ b/SourceGenerators/SingletonExtensions/SingletonTemplate.scriban @@ -2,7 +2,7 @@ {{- capture new -}} {{- if TSCN -}} - ({{ClassName}})ResourceLoader.Load("{{TSCN}}").Instantiate() + ({{ClassName}})ResourceLoader.Load("{{TSCN}}", cacheMode: ResourceLoader.CacheMode.IgnoreDeep).Instantiate() {{- else -}} new() {{- end -}}