- Editor version: 2023.2.15f1
Invoke in class TestB shall not access private function TargetFunc in the super class TestA.
But it is compiled and executed accessing the private function.
Considering behavior of Invoke, it shall link to TargetFunc with parameter and report warning message as there are parameter.
But it link to the private function which shall not be accessed as it is a private function.
/// === TestA.cs ===
...
public class TestA : MonoBehaviour
{
public void TargetFunc(int param) {
Debug.Log("calling TargetFunc with param");
}
private void TargetFunc() {
Debug.Log("calling TargetFunc without param");
}
}
/// === TestB.cs ===
...
public class TestB : TestA
{
void Start()
{
Invoke(nameof(TargetFunc), 1.0f);
}
}