- Home /
Removing components from prefab only
I am creating a prefab based on a game object in the scene.
GameObject prefab = PrefabUtility.CreatePrefab(localPath, obj);
GameObject gameObject = PrefabUtility.ReplacePrefab(obj, prefab, ReplacePrefabOptions.ConnectToPrefab);
ClearTitanComponents(gameObject);
Now I want to remove some components using my ClearTitanComponents() method. This method removes components of a certain type. However, when I use ReplacePrefabOptions.ConnectToPrefab, the original game object also gets its components removed. I want to keep my components in the game object, but if I use ReplacePrefabOptions.Default, the link to the game object is destroyed.
Is there a way to remove components from a prefab without removing them from the scene gameObject and without breaking the prefab link?
Your answer
Follow this Question
Related Questions
Clone of rigid body prefab destruction if at certain position 3 Answers
Cannot Destroy Instanitaed prefab. 1 Answer
Destroy an instantce of a prefab object 1 Answer
My prefab isn't getting destroyed 1 Answer
destrory prefab 1 Answer