Inheritance: UnityEngine.MonoBehaviour
コード例 #1
0
		/// <summary>
		/// This will create a main thread manager if one is not already created
		/// </summary>
		public static void Create()
		{
			if (!ReferenceEquals(Instance, null))
				return;

			Instance = new GameObject("MAIN_THREAD_MANAGER").AddComponent<MainThreadManager>();
			DontDestroyOnLoad(Instance.gameObject);
		}
コード例 #2
0
		// Setup the singleton in the Awake
		private void Awake()
		{
			// If an instance already exists then delete this copy
			if (!ReferenceEquals(Instance, null))
			{
				Destroy(gameObject);
				return;
			}

			// Assign the static reference to this object
			Instance = this;

			// This object should move through scenes
			DontDestroyOnLoad(gameObject);
		}
コード例 #3
0
ファイル: NetWorkerKiller.cs プロジェクト: Morgasm/ironarmada
        /// <summary>
        /// This will create the Networker Killer if it hasn't been created already
        /// </summary>
        public static void Create()
        {
            if (!ReferenceEquals(instance, null))
            {
                return;
            }

            if (Threading.ThreadManagement.IsMainThread)
            {
                instance = new GameObject("NetWorker Authority").AddComponent <NetWorkerKiller>();
                DontDestroyOnLoad(instance.gameObject);
            }
            else
            {
                MainThreadManager.Run(() =>
                {
                    instance = new GameObject("NetWorker Authority").AddComponent <NetWorkerKiller>();
                    DontDestroyOnLoad(instance.gameObject);
                });
            }
        }