- Home /
Override asset on import
My unity Assets folder has the following structure
Assets
└───Custom
| |
| └─ Materials
| | Material1.mat
| | Material1.mat.meta
| | ...
| └─── Shaders
| Shader1.shader
| Shader1.shader.meta
| ...
└───Shared
|
└─ Materials
| Material1.mat
| Material1.mat.meta
| ...
└─── Shaders
Shader1.shader
Shader1.shader.meta
...
In my scene and prefabs I'm referencing the assets from my Shared folder. I'm searching for a way that when I load the project instead of loading the assets from my Shared folder I load them from my Custom one. Or put in a different way I'm looking for a way to override an asset of any type without having to update all of the references to it.
The ideal place from my point of view to do this would be in either AssetPostprocessor.OnPreprocessAsset
or in AssetPostprocessor.OnPostprocessAllAssets
but I have not been able to replace or override the assets after looking at the APIs for AssetDatabase
, AssetImporter
or even AssetImportContext
.
A couple of important notes:
I'm using 2019.3 so this means
AssetDatabase
V2I would not like to do this using
System.IO
because this files are in source control and I believe trying to track this files would cause plenty of issues.I want this to happen at design time.
Your answer
Follow this Question
Related Questions
Prefab as a subasset of a ScriptableObject 0 Answers
AssetDatabase.CreateAsset() - Value cannot be null 2 Answers
Why unity can't create/save asset (ScriptableObject ) at runtime ? 1 Answer
Getting assets / sub folders inside a folder 1 Answer
Addressables - Use Asset Database (faster) - Not loading assets within a folder 1 Answer