Instantiating in editor not saving prefab connection?


I know a few questions have been asked about this but I still need help.

Ok so I am using a JS script to instantiate some objects in the editor, The script has a function that is being called by a C# editor script. So when it calls the function and the objects are created it does not save the prefab connection... I looked at the docs and googles it but I can't find a solution.



Make sure you’re using PrefabUtility.InstantiatePrefab

You can try creating a script containing the variables for the prefabs. From there, using GetComponent to retrieve the prefabs from your main script.

For example, in Prefabs.js

var prefab1 : GameObject;

Then in your main script,

var getPrefab : Prefabs;
var newPrefab;
function Awake()
    getPrefab = gameObject.GetComponent("Prefabs");
    newPrefab = getPrefab.prefab1;