當前位置: 首頁>>代碼示例>>C#>>正文


C# Animator.GetHashCode方法代碼示例

本文整理匯總了C#中Animator.GetHashCode方法的典型用法代碼示例。如果您正苦於以下問題:C# Animator.GetHashCode方法的具體用法?C# Animator.GetHashCode怎麽用?C# Animator.GetHashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Animator的用法示例。


在下文中一共展示了Animator.GetHashCode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetEvents

	public static MecanimEvent[] GetEvents(Dictionary<int, Dictionary<int, Dictionary<int, List<MecanimEvent>>>> contextLoadedData,
	                                       Dictionary<int, Dictionary<int, AnimatorStateInfo>> contextLastStates,
	                                       int animatorControllerId, Animator animator)
	{
		List<MecanimEvent> allEvents = new List<MecanimEvent>();
		
		int animatorHash = animator.GetHashCode();
		if (!contextLastStates.ContainsKey(animatorHash))
			contextLastStates[animatorHash] = new Dictionary<int, AnimatorStateInfo>();
		
		int layerCount = animator.layerCount;
		
		Dictionary<int, AnimatorStateInfo> lastLayerState = contextLastStates[animatorHash];
		
		for (int layer = 0; layer < layerCount; layer++) {
			if (!lastLayerState.ContainsKey(layer)) {
				lastLayerState[layer] = new AnimatorStateInfo();
			}
			
			AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(layer);
			
			int lastLoop = (int)lastLayerState[layer].normalizedTime;
			int currLoop = (int)stateInfo.normalizedTime;
			float lastNormalizedTime = lastLayerState[layer].normalizedTime - lastLoop;
			float currNormalizedTime = stateInfo.normalizedTime - currLoop;
			
			if (lastLayerState[layer].fullPathHash == stateInfo.fullPathHash) {
				if (stateInfo.loop == true) {
					if (lastLoop == currLoop) {
						allEvents.AddRange(CollectEvents(contextLoadedData, animator, animatorControllerId, layer, stateInfo.fullPathHash, stateInfo.tagHash, lastNormalizedTime, currNormalizedTime));
					}
					else {
						allEvents.AddRange(CollectEvents(contextLoadedData, animator, animatorControllerId, layer, stateInfo.fullPathHash, stateInfo.tagHash, lastNormalizedTime, 1.00001f));
						allEvents.AddRange(CollectEvents(contextLoadedData, animator, animatorControllerId, layer, stateInfo.fullPathHash, stateInfo.tagHash, 0.0f, currNormalizedTime));
					}
				}
				else {
					float start = Mathf.Clamp01(lastLayerState[layer].normalizedTime);
					float end = Mathf.Clamp01(stateInfo.normalizedTime);
					
					if (lastLoop == 0 && currLoop == 0) {
						if (start != end)
							allEvents.AddRange(CollectEvents(contextLoadedData, animator, animatorControllerId, layer, stateInfo.fullPathHash, stateInfo.tagHash, start, end));
					}
					else if (lastLoop == 0 && currLoop > 0) {
						allEvents.AddRange(CollectEvents(contextLoadedData, animator, animatorControllerId, layer, lastLayerState[layer].fullPathHash, lastLayerState[layer].tagHash, start, 1.00001f));
					}
					else {
						
					}
				}
			}
			else {
				
				allEvents.AddRange(CollectEvents(contextLoadedData, animator, animatorControllerId, layer, stateInfo.fullPathHash, stateInfo.tagHash, 0.0f, currNormalizedTime));
				
				if (!lastLayerState[layer].loop) {
					allEvents.AddRange(CollectEvents(contextLoadedData, animator, animatorControllerId, layer, lastLayerState[layer].fullPathHash, lastLayerState[layer].tagHash, lastNormalizedTime, 1.00001f, true));
				}
			}
			
			lastLayerState[layer] = stateInfo;
		}
		
		return allEvents.ToArray();
	}
開發者ID:fakestuff,項目名稱:MecanimEventSystem,代碼行數:66,代碼來源:MecanimEventManager.cs


注:本文中的Animator.GetHashCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。