public string[] GetAnimationNames() { HashSet <string> animationNames = new HashSet <string>(); for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; string[] childAnimationNames = childAnimator.GetAnimationNames(); foreach (string childAnimationName in childAnimationNames) { animationNames.Add(childAnimationName); } } string[] stringArray = new string[animationNames.Count]; animationNames.CopyTo(stringArray); return(stringArray); }
public override void OnInspectorGUI() { SerializedProperty animationIdProperty = serializedObject.FindProperty("_animationName"); SpineAnimator animator = EditorHelper.GetLastInspectedSpineAnimator(); if (animator != null) { string[] animationNames = animator.GetAnimationNames(); int currentIndex = -1; for (int i = 0; i < animationNames.Length; i++) { if (animationNames[i] == animationIdProperty.stringValue) { currentIndex = i; break; } } int index = EditorGUILayout.Popup("Animation", currentIndex == -1 ? 0 : currentIndex, animationNames); if (currentIndex != index) { animationIdProperty.stringValue = animationNames[index]; serializedObject.ApplyModifiedProperties(); if (Application.isPlaying) { ((SpineAnimatorStateBehaviour)target).ForceUpdate(); } } } else { GUI.enabled = false; EditorGUILayout.PropertyField(animationIdProperty); GUI.enabled = true; } }