private void OnEnable() { this.EffectInfoAsset = target as EffectInfoAsset; this.effectorTypeProp = serializedObject.FindProperty("effectorType"); this.EffectUnitInfosProp = serializedObject.FindProperty("EffectUnitInfos"); this.EffectUnitInfoList = new ReorderableList(serializedObject, EffectUnitInfosProp, true, true, true, true); this.EffectUnitInfoList.elementHeight = 2 * EditorGUIUtility.singleLineHeight; this.EffectUnitInfoList.drawElementCallback = (rect, index, a, b) => { var prop = EffectUnitInfosProp.GetArrayElementAtIndex(index); EditorGUI.PropertyField(rect, prop); }; this.EffectUnitInfoList.drawHeaderCallback = (rect) => EditorGUI.LabelField(rect, "特效列表"); this.EffectUnitInfoList.onSelectCallback = (list) => selectIndex = EffectUnitInfoList.index; EffectUnitInfoList.onAddDropdownCallback = (rect, list) => { var menu = new GenericMenu(); var enumIndex = -1; foreach (var value in EnumUtil.GetValues <EffectType>()) { enumIndex++; menu.AddItem(new GUIContent(((EffectType)value).ToString()), false, OnAddUnitCallBack, enumIndex); } menu.ShowAsContext(); }; }
/// <summary> /// 播放攻击特效 /// </summary> /// <param name="effectInfoAsset"></param> public void PlayAttackEffects(EffectInfoAsset effectInfoAsset) { effectInfoAsset?.Play(this, null); }