Morulus
2/1/2020 - 10:58 PM

Wait for end of frame

/* Using method InvokeOnEndOfFame you can immediate destroy and add components in edtor mode */
class InvokeOnEndOfFameClass() {
  void InvokeOnEndOfFame(Action action)
  {
      StartCoroutine(EnumerableInvokeOnEndOfFame(action));
  }
  
  IEnumerator EnumerableInvokeOnEndOfFame(Action action) {
      yield return new WaitForEndOfFrame();
      action();
  }
}