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(); if (amaMgr==null) { return; } List list = amaMgr.GetComponentsInChildren().ToList(); List sizes = new List(); List names = new List(); 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); } } }