Can I call Awake() and OnEnable() separately?

Hello,

I want to instantiate a prefab, and then customize the resulting gameObject before it is enabled in the scene.

What I want to do is :

  1. Deactivate the gameObject’s prefab

  2. Instantiate a copy of the gameObject

  3. Call Awake(), to set references, and to call member objects constructors

  4. Set specific values on the member objects

  5. Enable the gameObject in the scene

Problem is, the first call to gameObject.SetActive(true) calls Awake() again, which reset all the member objects.

So is there a way to enable a gameObject without Awake() being called the first time I do so?

Do I have any control on when Awake() is called ?

I was thinking to maybe use an Init() method instead of Awake(), but a boolean seems like a more coherent choice. I will do so :
`
protected bool AlreadyAwaken = false;
protected virtual void Awake()
{
if (AlreadyAwaken)
return;
else
AlreadyAwaken = true;

// Do stuff  

}
`
Thanks for your advice

I was thinking to maybe use an Init() method instead of Awake(), but a boolean seems like a more coherent choice. I will do so on my base class :

protected bool AlreadyAwaken = false;
protected virtual void Awake()
{
	if (AlreadyAwaken)
		return;
	else
		AlreadyAwaken = true;

	// Do stuff
}

Thanks for your advice