creating and using list of prefabs

hello,
I have a scripts that create some new prefabs and store them in AssetDatabase, and also in a list of gameObjects.
I have two questions:

  1. I want to run this scripts only one time, in the initialization of the game. how can I do it?
  2. I have a script that is called later during the game, and in this scripts I want to use the prefabs from the first scripts. (I want to take the list of all the prefabs created).

Can someone help - how can I do it?

Thanks

One way you can attempt this is by using a global variable in your Database script, and then forwarding a variable from another script. Here is how I would do this…

AssetDBScript:

// Add global variables to be modified elsewhere.

static var prefab1 : GameObject;
static var prefab2 : GameObject;

//etc....

Then when you are ready to start the game, use this script to modify the global variable in the AssetDBScript.

#pragma strict

// Prefab variable names

public var prefabName1 : GameObject;
public var prefabName2 : GameObject;
// etc...

function Start () {
    // On start, apply variable.
    
    AssetDBScript.prefab1 = prefabName1;
    AssetDBScript.prefab2 = prefabName2;

}

When you are done with the script, you can add the prefab to the variable using the inspector.

Alternatively, you should look for the “Singleton Design pattern”.