private void InitData() { try { _help = target as AnimatorHelp; if (string.IsNullOrEmpty(_help.name)) { Debug.Log("Help脚本名称为空"); } else { string[] data = _help.name.Split('#'); string aniName = data[0]; int nameHash = int.Parse(data[1]); _help.Controller = AnimatorToolWindow.HelpControllers.FirstOrDefault(u => u != null && u.name == aniName); if (_help.Controller == null) { Debug.LogError("未找到对应状态机 名称为:" + aniName); } else { var states = _help.Controller.GetAllAnimatorStates(); _help.AnimatorState = states.FirstOrDefault(u => u.nameHash == nameHash); } } } catch (Exception) { Debug.LogError("类型转换出错"); throw; } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (new EditorGUI.PropertyScope(position, label, property)) { AnimatorHelp help = property.serializedObject.targetObject as AnimatorHelp; if (help != null) { foreach (ParaEnum value in Enum.GetValues(typeof(ParaEnum))) { if (help.GetSelectedData(value)) { var para = property.FindPropertyRelative(value.ToString()); EditorGUILayout.PropertyField(para); } } } } }