public void OnMouseDown() { SkeletonComponent skeletonComponent = GetComponent <SkeletonComponent>(); skeletonComponent.animationName = "jump"; skeletonComponent.loop = false; }
public void Update() { SkeletonComponent skeletonComponent = GetComponent <SkeletonComponent>(); if (!skeletonComponent.loop && skeletonComponent.state.Time >= skeletonComponent.state.Animation.Duration - 0.25) { skeletonComponent.animationName = "walk"; skeletonComponent.loop = true; } }
override public void OnInspectorGUI() { serializedObject.Update(); SkeletonComponent component = (SkeletonComponent)target; EditorGUIUtility.LookLikeInspector(); EditorGUILayout.PropertyField(skeletonDataAsset); if (component.skeleton != null) { // Animation name. String[] animations = new String[component.skeleton.Data.Animations.Count + 1]; animations[0] = "<None>"; int animationIndex = 0; for (int i = 0; i < animations.Length - 1; i++) { String name = component.skeleton.Data.Animations[i].Name; animations[i + 1] = name; if (name == animationName.stringValue) { animationIndex = i + 1; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Animation"); EditorGUIUtility.LookLikeControls(); animationIndex = EditorGUILayout.Popup(animationIndex, animations); EditorGUIUtility.LookLikeInspector(); EditorGUILayout.EndHorizontal(); animationName.stringValue = animationIndex == 0 ? null : animations[animationIndex]; } // Animation loop. EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Loop"); loop.boolValue = EditorGUILayout.Toggle(loop.boolValue); EditorGUILayout.EndHorizontal(); EditorGUILayout.PropertyField(timeScale); if (!Application.isPlaying) { if (serializedObject.ApplyModifiedProperties() || (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") ) { component.Clear(); component.Update(); } } }
override public void OnInspectorGUI() { serializedObject.Update(); SkeletonComponent component = (SkeletonComponent)target; EditorGUIUtility.LookLikeInspector(); EditorGUILayout.PropertyField(skeletonDataAsset); if (component.skeleton != null) { // Initial skin name. String[] skins = new String[component.skeleton.Data.Skins.Count + 1]; int skinIndex = 0; for (int i = 0; i < skins.Length - 1; i++) { String name = component.skeleton.Data.Skins[i].Name; skins[i] = name; if (name == initialSkinName.stringValue) { skinIndex = i; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Initial Skin"); EditorGUIUtility.LookLikeControls(); skinIndex = EditorGUILayout.Popup(skinIndex, skins); EditorGUIUtility.LookLikeInspector(); EditorGUILayout.EndHorizontal(); initialSkinName.stringValue = skinIndex == 0 ? null : skins[skinIndex]; } EditorGUILayout.PropertyField(timeScale); EditorGUILayout.PropertyField(normals); EditorGUILayout.PropertyField(tangents); if (serializedObject.ApplyModifiedProperties() || (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") ) { if (!Application.isPlaying) { component.Clear(); component.Update(); } } }
// This is called after the animation is applied to the skeleton and can be used to adjust the bones dynamically. public void UpdateBones(SkeletonComponent skeletonAnimation) { headBone.Rotation -= 15; }
// This is called after the animation is applied to the skeleton and can be used to adjust the bones dynamically. public void UpdateBones(SkeletonComponent skeletonAnimation) { headBone.Rotation -= 15; }