Shader names include [ ] characters which are used in label groups for Addressables, so [ ] are considered invalid for addressable resources. Would be nice to rename shaders.

Avatar
  • updated
  • Fixed

If the shader elements are marked as addressable, their default address is their file path / name which includes [ ] and therefore requires manual fixing to work within addressables. or if you run the Addressables Analyze tool and it marks the shaders for you as invalid.

In the end, this causes the addressable system to fail builds due to [ ] characters.

Reporting a bug? please specify Unity version:
2021.3.15f1
Reporting a bug? please specify Shapes version:
4.2.1
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
andrew trese

Here is the specific error from the Addressables builder -- 

Address 'Assets/Asset Packs/Shapes/Shaders/Generated Materials/Disc Additive [INNER_RADIUS][SECTOR].mat' cannot contain '[ ]'.

UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContent (UnityEditor.AddressableAssets.Build.AddressablesPlayerBuildResult&)

RPG.Assets.Scripts.Editor.AddressableBuilder:BuildAddressableContent () (at Assets/Scripts/Editor/AddressableBuilder.cs:201)

RPG.Assets.Scripts.Editor.AddressableBuilder/<>c:<PerformAddressablesBuildWin64>b__4_1 () (at Assets/Scripts/Editor/AddressableBuilder.cs:51)

RPG.Assets.Scripts.Editor.AddressableBuilder:BuildAddressablesWithLogging (string,System.Action,System.Action,System.Action) (at Assets/Scripts/Editor/AddressableBuilder.cs:139)

RPG.Assets.Scripts.Editor.AddressableBuilder:PerformAddressablesBuildWin64 () (at Assets/Scripts/Editor/AddressableBuilder.cs:30)

Avatar
rak

[Edit: This solution does not work, but I'm going to leave it here in case this helps anyone to look into this further. Check my reply to this post for more details]

Hey Andrew, I ran into this annoying problem myself. But I found a solution and here is what I did to fix it if you have not figured it out yet:

1. First, go to the folder "Shapes/Shaders/Generated Materials" and delete all the generated materials.

2. Then open the GodengenShaders.cs file and edit line 123 as below:

string kws = $" ({string.Join( ")(", validKeywords )})";
if( kws.Contains( "()" ) ) // this means it has no permutations
kws = "";

Mainly, I replaced the square brackets with rounded brackets.

3. Finally, save, wait for recompilation, and then open Shpaes settings and "Regenerate Shaders and Materials"

That should fix it! I hope this gets fixed in the next update of Shapes :)

Avatar
rak
Quote from rak

[Edit: This solution does not work, but I'm going to leave it here in case this helps anyone to look into this further. Check my reply to this post for more details]

Hey Andrew, I ran into this annoying problem myself. But I found a solution and here is what I did to fix it if you have not figured it out yet:

1. First, go to the folder "Shapes/Shaders/Generated Materials" and delete all the generated materials.

2. Then open the GodengenShaders.cs file and edit line 123 as below:

string kws = $" ({string.Join( ")(", validKeywords )})";
if( kws.Contains( "()" ) ) // this means it has no permutations
kws = "";

Mainly, I replaced the square brackets with rounded brackets.

3. Finally, save, wait for recompilation, and then open Shpaes settings and "Regenerate Shaders and Materials"

That should fix it! I hope this gets fixed in the next update of Shapes :)

Ya just realized that solves only the addressable error but completely breaks the drawing scripts. There must be other scripts that are still looking for those square brackets. Need to find them and change them to round brackets. For now, I'm just gonna stick to regular lines with no end caps, they seem to be working for me even after the edit above. I will look further into this later or hopefully, this should be fixed by then.

Avatar
andrew trese

Thanks for posting this possible solution.


For now, we've just been careful to avoid letting anything in Shapes become addressable. We've got a lot of Shapes assets copied between our bundles.


It is unfortunate that Shapes has this limitation, as this is part of the go-forward setup at Unity.

Is there any chance to change how Shapes names those materials to be addressable compliant and still work?

Avatar
Freya Holmér creator

This has now been fixed for the next version!

if you want to hotfix it for now, here are the required changes:

CodegenShaders.cs

Image 770

ShapesMaterials.cs

Image 771


And then either:

A. Delete all materials in Generated Materials folder, and go to the settings and regenerate them all. This will, however, also create new GUIDs which might break some references, or

B. Rename the files either manually (would take a long time lol) or using an automated script, to make the files use parens instead of brackets

Avatar
andrew trese

Thank you!

In the next version, will any manual steps (A & B) be required or the update will sort out the GUIDs, etc?

Avatar
Freya Holmér creator

nah, if you update it once it's out, it should keep the GUIDs and no manual steps should be required!

Avatar
Freya Holmér creator
  • Fixed

this has been fixed in 4.3.0! which is live now too