Possible to Disable/Enable component in prefab before instantiating?

I want to disable/enable the audiosource component of a prefab in runtime, so that when I instantiate it, it will be instantiated with the audiosource component enabled/disabled . But currently I only know that we can do this AFTER instantiating the object and then removing the component from each object that is instantiated.

Editing the prefab itself is not possible as far as i know, doesn’t make a lot of sense to do that anyway. Maybe the next time you want to instantiate it you’ll need the audiosource and then would have to edit it again, leading you into an endless cycle of editing.

What you can do is this:

public GameObject prefab;

public void SpawnPrefab ()
    GameObject go = Instantiate(prefab);
    go.GetComponent<AudioSource>().enabled = false;

This will instantiate the gameobject and disable (instead of removing) its audiosource.