예제 #1
0
    /*
     */
    void Update()
    {
        SkeletonData skeletonData = (skeletonDataAsset != null) ? skeletonDataAsset.GetSkeletonData() : null;

        if (skeletonData == null)
        {
            Clear();
            return;
        }

        if (skeleton == null || skeleton.Data != skeletonData)
        {
            Initialize();
        }

        UpdateAnimation();
        UpdateSkeleton();
        UpdateCache();
        UpdateMesh();
    }
예제 #2
0
    void Update()
    {
        SkeletonData skeletonData = skeletonDataAsset == null ? null : skeletonDataAsset.GetSkeletonData();

        if (skeletonData == null)
        {
            Clear();
            return;
        }

        if (skeleton == null || skeleton.Data != skeletonData)
        {
            Initialize();
        }

        skeleton.UpdateWorldTransform();

        UpdateCache();
        UpdateMesh();
    }
예제 #3
0
    /*
     */
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        tk2dSpineSkeletonDataAsset asset = target as tk2dSpineSkeletonDataAsset;

        EditorGUIUtility.LookLikeInspector();
        sprites = EditorGUILayout.ObjectField("Sprites", sprites, typeof(tk2dSpriteCollection), false) as tk2dSpriteCollection;

        if (sprites != null)
        {
            SerializedProperty spritesData = serializedObject.FindProperty("spritesData");
            spritesData.objectReferenceValue = sprites.spriteCollection;

            SerializedProperty normalGenerationMode = serializedObject.FindProperty("normalGenerationMode");
            normalGenerationMode.enumValueIndex = (int)sprites.normalGenerationMode;
        }
        else
        {
            SerializedProperty spritesData = serializedObject.FindProperty("spritesData");
            spritesData.objectReferenceValue = null;

            SerializedProperty normalGenerationMode = serializedObject.FindProperty("normalGenerationMode");
            normalGenerationMode.enumValueIndex = (int)tk2dSpriteCollection.NormalGenerationMode.None;
        }

        EditorGUILayout.PropertyField(skeletonJSON);

        SkeletonData skeletonData = asset.GetSkeletonData();

        if (skeletonData != null)
        {
            showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
            if (showAnimationStateData)
            {
                String[] animations = new String[skeletonData.Animations.Count];
                for (int i = 0; i < animations.Length; i++)
                {
                    animations[i] = skeletonData.Animations[i].Name;
                }

                for (int i = 0; i < fromAnimation.arraySize; i++)
                {
                    SerializedProperty from         = fromAnimation.GetArrayElementAtIndex(i);
                    SerializedProperty to           = toAnimation.GetArrayElementAtIndex(i);
                    SerializedProperty durationProp = duration.GetArrayElementAtIndex(i);

                    EditorGUILayout.BeginHorizontal();

                    from.stringValue        = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, from.stringValue), 0), animations)];
                    to.stringValue          = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, to.stringValue), 0), animations)];
                    durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue);

                    if (GUILayout.Button("Delete"))
                    {
                        duration.DeleteArrayElementAtIndex(i);
                        toAnimation.DeleteArrayElementAtIndex(i);
                        fromAnimation.DeleteArrayElementAtIndex(i);
                    }

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();

                if (GUILayout.Button("Add Mix"))
                {
                    duration.arraySize++;
                    toAnimation.arraySize++;
                    fromAnimation.arraySize++;
                }

                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();
            }
        }

        serializedObject.ApplyModifiedProperties();
    }