I understand delegates fairly well, but I’m sort of in a crunch right now and I don’t have a whole lot of time to experiment.
My question is: if I have a manager class that has a delegate in it that stores several methods from multiple instances with the same class, will a specific instance be able to take itself out of that delegate?
public class DelegatedClass : MonoBehavior {
void Awake() {
refOfManager.theDelegate += this.SomeMethod;
}
void SomeMethod() {
Debug.Log("My ID: " + GetInstanceID());
}
void OnDestroy() {
refOfManager.theDelegate -= this.SomeMethod;
}
}
When this class is destroyed, the pointer to this specific instance of the class should be taken out of the delegate right, or am I just wrong and the delegate works as a stack with First In, Last Out?