当前位置: 首页>>代码示例>>C#>>正文


C# Handle.Cancel方法代码示例

本文整理汇总了C#中Handle.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# Handle.Cancel方法的具体用法?C# Handle.Cancel怎么用?C# Handle.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Handle的用法示例。


在下文中一共展示了Handle.Cancel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Schedule

	/// <summary>
	/// the 'Schedule' method sets everything in order for the
	/// timer event to be fired. it also creates a hidden
	/// gameobject upon the first time called (for purposes of
	/// running the Update loop and drawing editor debug info)
	/// </summary>
	private static void Schedule(float time, Callback func, ArgCallback argFunc, object args, Handle timerHandle, int iterations, float interval)
	{

		if (func == null && argFunc == null)
		{
			UnityEngine.Debug.LogError("Error: (vp_Timer) Aborted event because function is null.");
			return;
		}

		// setup main gameobject
		if (m_MainObject == null)
		{
			m_MainObject = new GameObject("Timers");
			m_MainObject.AddComponent<vp_Timer>();
			UnityEngine.Object.DontDestroyOnLoad(m_MainObject);

#if (UNITY_EDITOR && !DEBUG)
				m_MainObject.gameObject.hideFlags = HideFlags.HideInHierarchy;
#endif
		}

		// force healthy time values
		time = Mathf.Max(0.0f, time);
		iterations = Mathf.Max(0, iterations);
		interval = (interval == -1.0f) ? time : Mathf.Max(0.0f, interval);

		// recycle an event - or create a new one if the pool is empty
		m_NewEvent = null;
		if (m_Pool.Count > 0)
		{
			m_NewEvent = m_Pool[0];
			m_Pool.Remove(m_NewEvent);
		}
		else
			m_NewEvent = new Event();

		// iterate the event counter and store the id for this event
		vp_Timer.m_EventCount++;
		m_NewEvent.Id = vp_Timer.m_EventCount;

		// set up the event with its function, arguments and times
		if (func != null)
			m_NewEvent.Function = func;
		else if (argFunc != null)
		{
			m_NewEvent.ArgFunction = argFunc;
			m_NewEvent.Arguments = args;
		}
		m_NewEvent.StartTime = Time.time;
		m_NewEvent.DueTime = Time.time + time;
		m_NewEvent.Iterations = iterations;
		m_NewEvent.Interval = interval;
		m_NewEvent.LifeTime = 0.0f;
		m_NewEvent.Paused = false;

		// add event to the Active list
		vp_Timer.m_Active.Add(m_NewEvent);

		// if a timer handle was provided, associate it to this event,
		// but first cancel any already active event using the same
		// handle: there can be only one ...
		if (timerHandle != null)
		{
			if (timerHandle.Active)
				timerHandle.Cancel();
			// setting the 'Id' property associates this handle with
			// the currently active event with the corresponding id
			timerHandle.Id = m_NewEvent.Id;
		}

#if (UNITY_EDITOR && DEBUG)
		m_NewEvent.StoreCallingMethod();
		EditorRefresh();
#endif

	}
开发者ID:PlayHopeless,项目名称:game,代码行数:82,代码来源:vp_Timer.cs


注:本文中的Handle.Cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。