You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.2 KiB
59 lines
2.2 KiB
using System.Collections.Generic; |
|
using System.Linq; |
|
using UnityEditor; |
|
using UnityEngine; |
|
|
|
[CustomEditor(typeof(ArmActionFrame))] |
|
public class ArmActionFrameEditor : Editor |
|
{ |
|
public override void OnInspectorGUI() |
|
{ |
|
ArmActionFrame ma = (ArmActionFrame)target; |
|
EditorGUILayout.Space(); |
|
ma.action = (ActionType)EditorGUILayout.EnumPopup("举臂行为", ma.action); |
|
EditorGUILayout.Space(); |
|
#region 获取帧数据 |
|
ArmAction amaMgr = ma.GetComponentInParent<ArmAction>(); |
|
if (amaMgr==null) |
|
{ |
|
return; |
|
} |
|
List<ArmActionFrame> list = amaMgr.GetComponentsInChildren<ArmActionFrame>().ToList(); |
|
List<int> sizes = new List<int>(); |
|
List<string> names = new List<string>(); |
|
for (int i = 0; i < list.Count; i++) |
|
{ |
|
sizes.Add(i); |
|
names.Add(i.ToString()); |
|
} |
|
#endregion |
|
ma.FrameIndex = EditorGUILayout.IntPopup("帧序列", ma.FrameIndex,names.ToArray(),sizes.ToArray()); |
|
EditorGUILayout.Space(); |
|
bool allowSceneObjects = !EditorUtility.IsPersistent(target); |
|
EditorGUILayout.Space(); |
|
switch (ma.action) |
|
{ |
|
case ActionType.RotateToTarget: |
|
break; |
|
case ActionType.RotateToTargetVertacal: |
|
ma.IsOpposite = EditorGUILayout.Toggle("模型轴向错误",ma.IsOpposite); |
|
EditorGUILayout.Space(); |
|
break; |
|
case ActionType.RotateToTargetHorizatal: |
|
ma.IsOpposite = EditorGUILayout.Toggle("模型轴向错误", ma.IsOpposite); |
|
EditorGUILayout.Space(); |
|
break; |
|
case ActionType.TranlateToForward: |
|
ma.ArmLenthOffset = EditorGUILayout.IntSlider("手臂长度偏移", ma.ArmLenthOffset, 0, 50); |
|
break; |
|
case ActionType.RotateVertacalWithDistance: |
|
ma.Distance = EditorGUILayout.IntSlider("手臂高度偏移", ma.Distance, 0, 50); |
|
EditorGUILayout.Space(); |
|
break; |
|
} |
|
if (GUI.changed) |
|
{ |
|
EditorUtility.SetDirty(target); |
|
} |
|
} |
|
}
|
|
|