yyl
4 天以前 8d77144cfb756529507dc6927dcdcfd9f4a30750
Main/Utility/Extension.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using Spine;
using Spine.Unity;
public static class Extension
{
@@ -74,4 +76,61 @@
            }
        }
    }
    public static bool IsSpine(this string _resName)
    {
        if (string.IsNullOrEmpty(_resName))
        {
            return false;
        }
        return _resName.Contains("SkeletonData");
    }
    public static bool IsVideo(this string _resName)
    {
        if (string.IsNullOrEmpty(_resName))
        {
            return false;
        }
        return _resName.EndsWith(".mp4");
    }
    public static bool ContainsMotion(this Spine.Skeleton skeleton, string motionName)
    {
        if (skeleton == null || string.IsNullOrEmpty(motionName))
        {
            return false;
        }
        for (int i = 0; i < skeleton.Data.Animations.Count; i++)
        {
            if (skeleton.Data.Animations.Items[i].Name.ToLower() == motionName.ToLower())
            {
                return true;
            }
        }
        return false;
    }
    public static Spine.Animation GetSpineAnimation(this Spine.Skeleton skeleton, string motionName)
    {
        if (skeleton == null || string.IsNullOrEmpty(motionName))
        {
            return null;
        }
        for (int i = 0; i < skeleton.Data.Animations.Count; i++)
        {
            if (skeleton.Data.Animations.Items[i].Name.ToLower() == motionName.ToLower())
            {
                return skeleton.Data.Animations.Items[i];
            }
        }
        return null;
    }
}