What is the order of execution for the instantiated object's GetComponent.Script.DoSomething?

So, here’s the simplified code for GUN.cs, which will shoot bullet prefab with PROJECTILE.cs:

GameObject bullet = Instantiate (prefab, transform.position, transform.rotation);
bullet.GetComponent<Projectile>().DoSomething();

In this case, when does DoSomething() of Projectile.cs occur? On Projectile.cs’s Awake, OnEnable, or OnStart? Or on its first update?

Replace your version of Projectile.cs with this one:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using System.Diagnostics;
using Debug = UnityEngine.Debug;

public class Projectile : MonoBehaviour
{
	void Awake() => Test();

	void OnEnable() => Test();

	void Start() => Test();
	
	void Update() => Test();
	
	public void DoSomething() => Test();
	
	void Test(){
		StackTrace stackTrace = new StackTrace();
		MethodBase methodBase = stackTrace.GetFrame(1).GetMethod();
		string methodName = methodBase.Name;
		Debug.Log(methodName);
	}

}