Hey!
Ill say in advance that you can answer with references to MSDN or something like that, there is just so much information around that I am confused
I tested this ridiculous code(dont mind its just stupid bc i needed smth heavy):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Example : MonoBehaviour
{
public int[] firstArray;
public int[] secondArray;
private void OnEnable()
{
Example1();
}
private void Example1()
{
Example2();
Debug.Log($"Array Length: {secondArray.Length}");
}
private void Example2()
{
for (int i = 0; i < 1000; i++)
{
firstArray = new int[i+1];
Debug.Log($"Current iteration is {i}");
}
Example3();
}
private void Example3()
{
int j = 1;
for (int i = 0; i < firstArray.Length; i++)
{
if (i%2 == 0)
{
secondArray = new int[j];
j++;
}
}
}
}
As far as I understand in C# the code is executed sequentially Example1() → Example2() → Example3() → Debug.Log(from Example1()). And it works regardless of complexity of “nested” methods. Do I understand this concept correctly?
I also had a question: if I’m doing something like this:
private void Example1()
{
exampleInstance.someUnityEvent.Invoke();
exampleInstance.gameObject.SetActive(false);
}
Will all events subscribed to UnityEvent or specified in the inspector be able to be called?
One last question: do events in UnityEvent always run from top to bottom? After all, it would make much more sense for me to put SetActive(false) directly in the inspector after previous calls
Thank you so much and sorry for such silly questions!