Hello! I’m converting HDRP project to URP and by removing HDRP package it deleted some scripts from a lot of my prefabs. I would like to somehow attach another script in those null components. Is it possible? I’ve tried writing some editor scripts to do that for me but the main problem was that the changes weren’t applied to prefabs.
Here is an example of one of those scripts:
[MenuItem("Component/Find missing scripts")]
public static void FindMissing()
{
string[] prefabPaths = AssetDatabase.GetAllAssetPaths().Where(path => path.EndsWith(".prefab", System.StringComparison.OrdinalIgnoreCase)).ToArray();
foreach(string path in prefabPaths)
{
GameObject prefab = PrefabUtility.LoadPrefabContents(path);
Component[] components = prefab.GetComponents<Component>();
Component[] childComponents = prefab.GetComponentsInChildren<Component>(true);
foreach(Component component in components)
{
if(component != null && component.name.ToLower().Contains("decal"))
{
component.gameObject.AddComponent<DecalProjector>();
}
}
foreach (Component component in childComponents)
{
if (component != null && component.name.ToLower().Contains("decal"))
{
component.gameObject.AddComponent<DecalProjector>();
}
}
}
}