A game about forced loneliness, made by TACStudios
at master 75 lines 2.5 kB view raw
1using System; 2using System.Collections.Generic; 3using UnityEngine; 4 5namespace Unity.Jobs 6{ 7 /// <summary> 8 /// Used by automatically generated code. Do not use in projects. 9 /// </summary> 10 public class EarlyInitHelpers 11 { 12 /// <summary> 13 /// Used by automatically generated code. Do not use in projects. 14 /// Delegate used for early initialization 15 /// </summary> 16 public delegate void EarlyInitFunction(); 17 18 private static List<EarlyInitFunction> s_PendingDelegates; 19 20 static EarlyInitHelpers() 21 { 22 FlushEarlyInits(); 23 } 24 25 /// <summary> 26 /// Used by automatically generated code. Do not use in projects. 27 /// Calls all EarlyInit delegates and clears the invocation list 28 /// </summary> 29 public static void FlushEarlyInits() 30 { 31 while (s_PendingDelegates != null) 32 { 33 var oldList = s_PendingDelegates; 34 s_PendingDelegates = null; 35 36 for (int i = 0; i < oldList.Count; ++i) 37 { 38 try 39 { 40 oldList[i](); 41 } 42 catch (Exception ex) 43 { 44 Debug.LogException(ex); 45 } 46 } 47 } 48 } 49 50 /// <summary> 51 /// Used by automatically generated code. Do not use in projects. 52 /// Adds an EarlyInit helper function to invocation list. 53 /// </summary> 54 /// <param name="func">EarlyInitFunction add to early call list</param> 55 public static void AddEarlyInitFunction(EarlyInitFunction func) 56 { 57 if (s_PendingDelegates == null) 58 s_PendingDelegates = new List<EarlyInitFunction>(); 59 60 s_PendingDelegates.Add(func); 61 } 62 63 /// <summary> 64 /// Used by automatically generated code. Do not use in projects. 65 /// This methods is called when JobReflectionData cannot be created during EarlyInit. 66 /// </summary> 67 /// <param name="ex">Exception type to throw</param> 68 public static void JobReflectionDataCreationFailed(Exception ex) 69 { 70 Debug.LogError($"Failed to create job reflection data. Please refer to callstack of exception for information on which job could not produce its reflection data."); 71 Debug.LogException(ex); 72 } 73 } 74 75}