动画控制器修改
This commit is contained in:
parent
c2fb1cb94e
commit
cfda861017
File diff suppressed because one or more lines are too long
@ -16,51 +16,51 @@ namespace Ether
|
||||
{
|
||||
public class ActionEvent : UnityEvent
|
||||
{
|
||||
private int count = 0;
|
||||
public int Count { get => count; }
|
||||
public int Count { get; private set; } = 0;
|
||||
|
||||
public object EventData { get; private set; }
|
||||
|
||||
public new void AddListener(UnityAction call)
|
||||
{
|
||||
base.AddListener(call);
|
||||
count++;
|
||||
Count++;
|
||||
}
|
||||
|
||||
public new void RemoveListener(UnityAction call)
|
||||
{
|
||||
base.RemoveListener(call);
|
||||
count--;
|
||||
Count--;
|
||||
}
|
||||
|
||||
public new void RemoveAllListeners()
|
||||
{
|
||||
base.RemoveAllListeners();
|
||||
count = 0;
|
||||
Count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public class ActionEvent<T> : UnityEvent<T>
|
||||
{
|
||||
private int count = 0;
|
||||
public int Count { get => count; }
|
||||
public int Count { get; private set; } = 0;
|
||||
|
||||
public object EventData { get; private set; }
|
||||
|
||||
public new void AddListener(UnityAction<T> call)
|
||||
{
|
||||
base.AddListener(call);
|
||||
count++;
|
||||
Count++;
|
||||
}
|
||||
|
||||
public new void RemoveListener(UnityAction<T> call)
|
||||
{
|
||||
base.RemoveListener(call);
|
||||
count--;
|
||||
Count--;
|
||||
}
|
||||
|
||||
public new void RemoveAllListeners()
|
||||
{
|
||||
base.RemoveAllListeners();
|
||||
count = 0;
|
||||
Count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityTimer;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Ether
|
||||
{
|
||||
@ -32,7 +33,36 @@ namespace Ether
|
||||
[PropertySpace(10)]
|
||||
[ShowInInspector]
|
||||
[DictionaryDrawerSettings(KeyLabel = "名称", ValueLabel = "动画资源")]
|
||||
public Dictionary<string, AnimationSet> allAnimationSet = new Dictionary<string, AnimationSet>();
|
||||
[OnValueChanged("OnValueChanged")]
|
||||
public Dictionary<string, Object> allAnimationSet = new Dictionary<string, Object>();
|
||||
|
||||
private void OnValueChanged()
|
||||
{
|
||||
// 这里可以添加逻辑来处理值变化,例如清理无效条目
|
||||
List<string> keysToRemove = new List<string>();
|
||||
foreach (var pair in allAnimationSet)
|
||||
{
|
||||
if (!IsAllowedType(pair.Value))
|
||||
{
|
||||
keysToRemove.Add(pair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var key in keysToRemove)
|
||||
{
|
||||
allAnimationSet.Remove(key);
|
||||
Debug.LogError("添加的类型只能是AnimationClip或者AnimationSet");
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsAllowedType(object value)
|
||||
{
|
||||
if (value is AnimationClip or AnimationSet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Animator animator { get; set; }
|
||||
public AnimancerComponent animancer { get; private set; }
|
||||
@ -68,9 +98,14 @@ namespace Ether
|
||||
|
||||
public void PlayAnim(string name)
|
||||
{
|
||||
if (allAnimationSet.TryGetValue(name, out AnimationSet animationSet))
|
||||
if (allAnimationSet.TryGetValue(name, out Object animation))
|
||||
{
|
||||
AnimationClip clip = animationSet.GetClip();
|
||||
AnimationClip clip = animation switch
|
||||
{
|
||||
AnimationSet animationSet => animationSet.GetClip(),
|
||||
AnimationClip animationClip => animationClip,
|
||||
_ => null
|
||||
};
|
||||
|
||||
PlayAnim(clip);
|
||||
}
|
||||
@ -78,18 +113,28 @@ namespace Ether
|
||||
|
||||
public void PlayAnim(string name, Vector2 direction)
|
||||
{
|
||||
if (allAnimationSet.TryGetValue(name, out AnimationSet animationSet))
|
||||
if (allAnimationSet.TryGetValue(name, out Object animation))
|
||||
{
|
||||
AnimationClip clip = animationSet.GetClip(direction);
|
||||
AnimationClip clip = animation switch
|
||||
{
|
||||
AnimationSet animationSet => animationSet.GetClip(direction),
|
||||
AnimationClip animationClip => animationClip,
|
||||
_ => null
|
||||
};
|
||||
PlayAnim(clip);
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayAnim(string name, Action endCallback)
|
||||
{
|
||||
if (allAnimationSet.TryGetValue(name, out AnimationSet animationSet))
|
||||
if (allAnimationSet.TryGetValue(name, out Object animation))
|
||||
{
|
||||
AnimationClip clip = animationSet.GetClip();
|
||||
AnimationClip clip = animation switch
|
||||
{
|
||||
AnimationSet animationSet => animationSet.GetClip(),
|
||||
AnimationClip animationClip => animationClip,
|
||||
_ => null
|
||||
};
|
||||
|
||||
PlayAnim(clip);
|
||||
}
|
||||
@ -109,9 +154,14 @@ namespace Ether
|
||||
{
|
||||
if (isPlayDisable)
|
||||
{
|
||||
if (allAnimationSet.TryGetValue(disablePlayAnim, out AnimationSet animationSet))
|
||||
if (allAnimationSet.TryGetValue(disablePlayAnim, out Object animation))
|
||||
{
|
||||
AnimationClip clip = animationSet.GetClip();
|
||||
AnimationClip clip = animation switch
|
||||
{
|
||||
AnimationSet animationSet => animationSet.GetClip(),
|
||||
AnimationClip animationClip => animationClip,
|
||||
_ => null
|
||||
};
|
||||
|
||||
if (clip)
|
||||
{
|
||||
|
@ -250,13 +250,6 @@ namespace Ether
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
|
||||
Dictionary<string, Delegate> eventCache = new Dictionary<string, Delegate>();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
//========================================= 事件工具 ============================================
|
||||
|
||||
#region 按钮事件
|
||||
|
@ -16,7 +16,7 @@ MonoBehaviour:
|
||||
_AutoClose: 1
|
||||
_SceneLighting: 0
|
||||
_ShowSkybox: 0
|
||||
_SceneEnvironment: {fileID: 0}
|
||||
_SceneEnvironment: {fileID: 50561091006429229, guid: 75ada8b3f8b88804d856489d214b820e, type: 3}
|
||||
_Models: []
|
||||
_AnimationTimeFields:
|
||||
showApproximations: 1
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,62 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 700ee77955080b443b2b2d565d9f383c, type: 3}
|
||||
m_Name: LoginFrameHide
|
||||
m_EditorClassIdentifier:
|
||||
serializationData:
|
||||
SerializedFormat: 2
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects:
|
||||
- {fileID: 7400000, guid: 380ce507f72f7334da36a555e8d5d1ab, type: 2}
|
||||
SerializedBytesString:
|
||||
Prefab: {fileID: 0}
|
||||
PrefabModificationsReferencedUnityObjects: []
|
||||
PrefabModifications: []
|
||||
SerializationNodes:
|
||||
- Name: animationClips
|
||||
Entry: 7
|
||||
Data: 0|System.Collections.Generic.Dictionary`2[[Ether.AnimationSetType, Ether],[UnityEngine.AnimationClip,
|
||||
UnityEngine.AnimationModule]], mscorlib
|
||||
- Name: comparer
|
||||
Entry: 7
|
||||
Data: 1|System.Collections.Generic.EnumEqualityComparer`1[[Ether.AnimationSetType,
|
||||
Ether]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 3
|
||||
Data: 0
|
||||
- Name: $v
|
||||
Entry: 10
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d1f120691afb9a4f86607a0e5de4b20
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,62 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 700ee77955080b443b2b2d565d9f383c, type: 3}
|
||||
m_Name: LoginFrameShow
|
||||
m_EditorClassIdentifier:
|
||||
serializationData:
|
||||
SerializedFormat: 2
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects:
|
||||
- {fileID: 7400000, guid: 7e179fd10ed3d8643883c98de0a5fe62, type: 2}
|
||||
SerializedBytesString:
|
||||
Prefab: {fileID: 0}
|
||||
PrefabModificationsReferencedUnityObjects: []
|
||||
PrefabModifications: []
|
||||
SerializationNodes:
|
||||
- Name: animationClips
|
||||
Entry: 7
|
||||
Data: 0|System.Collections.Generic.Dictionary`2[[Ether.AnimationSetType, Ether],[UnityEngine.AnimationClip,
|
||||
UnityEngine.AnimationModule]], mscorlib
|
||||
- Name: comparer
|
||||
Entry: 7
|
||||
Data: 1|System.Collections.Generic.EnumEqualityComparer`1[[Ether.AnimationSetType,
|
||||
Ether]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 3
|
||||
Data: 0
|
||||
- Name: $v
|
||||
Entry: 10
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 720ee3502774a404384f52fa209b733d
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -10,7 +10,6 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 3300074689851355942}
|
||||
- component: {fileID: 2280105451091296656}
|
||||
- component: {fileID: 5034661416622006822}
|
||||
m_Layer: 0
|
||||
m_Name: LoginFrame
|
||||
m_TagString: Untagged
|
||||
@ -55,8 +54,8 @@ MonoBehaviour:
|
||||
SerializedFormat: 2
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects:
|
||||
- {fileID: 11400000, guid: 720ee3502774a404384f52fa209b733d, type: 2}
|
||||
- {fileID: 11400000, guid: 5d1f120691afb9a4f86607a0e5de4b20, type: 2}
|
||||
- {fileID: 7400000, guid: 7e179fd10ed3d8643883c98de0a5fe62, type: 2}
|
||||
- {fileID: 7400000, guid: 380ce507f72f7334da36a555e8d5d1ab, type: 2}
|
||||
SerializedBytesString:
|
||||
Prefab: {fileID: 0}
|
||||
PrefabModificationsReferencedUnityObjects: []
|
||||
@ -64,8 +63,8 @@ MonoBehaviour:
|
||||
SerializationNodes:
|
||||
- Name: allAnimationSet
|
||||
Entry: 7
|
||||
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[Ether.AnimationSet,
|
||||
Ether]], mscorlib
|
||||
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UnityEngine.Object,
|
||||
UnityEngine.CoreModule]], mscorlib
|
||||
- Name: comparer
|
||||
Entry: 7
|
||||
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
|
||||
@ -110,27 +109,6 @@ MonoBehaviour:
|
||||
enablePlayAnim: Show
|
||||
isPlayDisable: 1
|
||||
disablePlayAnim: Hide
|
||||
--- !u!95 &5034661416622006822
|
||||
Animator:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 50561091006429229}
|
||||
m_Enabled: 1
|
||||
m_Avatar: {fileID: 0}
|
||||
m_Controller: {fileID: 0}
|
||||
m_CullingMode: 0
|
||||
m_UpdateMode: 0
|
||||
m_ApplyRootMotion: 0
|
||||
m_LinearVelocityBlending: 0
|
||||
m_StabilizeFeet: 0
|
||||
m_WarningMessage:
|
||||
m_HasTransformHierarchy: 1
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorStateOnDisable: 0
|
||||
m_WriteDefaultValuesOnDisable: 0
|
||||
--- !u!1 &2081265740414986783
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -199,8 +177,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: "\u7EE7\u7EED\u6E38\u620F"
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 119ac0c1caf7d39459dc86c2ea61b87b, type: 2}
|
||||
m_sharedMaterial: {fileID: -626746769071358210, guid: 119ac0c1caf7d39459dc86c2ea61b87b, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 5260a5b886a7afb42923003dcf1df014, type: 2}
|
||||
m_sharedMaterial: {fileID: 7042218265555741552, guid: 5260a5b886a7afb42923003dcf1df014, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
@ -366,8 +344,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: "\u8BBE\u7F6E"
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 119ac0c1caf7d39459dc86c2ea61b87b, type: 2}
|
||||
m_sharedMaterial: {fileID: -626746769071358210, guid: 119ac0c1caf7d39459dc86c2ea61b87b, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 5260a5b886a7afb42923003dcf1df014, type: 2}
|
||||
m_sharedMaterial: {fileID: 7042218265555741552, guid: 5260a5b886a7afb42923003dcf1df014, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
@ -608,8 +586,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: "\u65B0\u7684\u6E38\u620F"
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 119ac0c1caf7d39459dc86c2ea61b87b, type: 2}
|
||||
m_sharedMaterial: {fileID: -626746769071358210, guid: 119ac0c1caf7d39459dc86c2ea61b87b, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 5260a5b886a7afb42923003dcf1df014, type: 2}
|
||||
m_sharedMaterial: {fileID: 7042218265555741552, guid: 5260a5b886a7afb42923003dcf1df014, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
@ -775,8 +753,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: "\u79BB\u5F00"
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 119ac0c1caf7d39459dc86c2ea61b87b, type: 2}
|
||||
m_sharedMaterial: {fileID: -626746769071358210, guid: 119ac0c1caf7d39459dc86c2ea61b87b, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 5260a5b886a7afb42923003dcf1df014, type: 2}
|
||||
m_sharedMaterial: {fileID: 7042218265555741552, guid: 5260a5b886a7afb42923003dcf1df014, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
|
Loading…
Reference in New Issue
Block a user