Пример #1
0
 /// <summary>
 /// 通过Spine生成的json,atlas文件创建角色
 /// </summary>
 /// <param name="skeletonJson">Skeleton json.</param>
 /// <param name="atlasText">Atlas text.</param>
 /// <param name="textures">Textures.</param>
 /// <param name="material">Material.</param>
 /// <param name="initialize">If set to <c>true</c> initialize.</param>
 /// <param name="skinName">Skin name.</param>
 /// <param name="animationName">Animation name.</param>
 /// <param name="loop">If set to <c>true</c> loop.</param>
 public void Create(SpineAvatarType avatarType, EquipmentObject eo, Material material, bool initialize, string name, string skinName, string animationName, bool loop, RoleEquipmentData data, Action <Avatar> createSucCallBack, Action <string> failCallBack, Action <bool> createQueueCallBack, bool isTP)
 {
     #if UNITY_ANDROID
     GameManager.Instance.StartCoroutine(Create(avatarType, eo, SkeletonDataAsset.CreateRuntimeInstance(eo.equipmentJsonAsset, AtlasAsset.CreateRuntimeInstance(eo.equipmentTxtAsset, eo.equipmentTexture_Alpha, eo.equipmentTexture_RGB, material, initialize, true), initialize), name, animationName, skinName, loop, data, createSucCallBack, failCallBack, createQueueCallBack, isTP));
     #elif UNITY_IPHONE || UNITY_EDITOR
     GameManager.Instance.StartCoroutine(Create(avatarType, eo, SkeletonDataAsset.CreateRuntimeInstance(eo.equipmentJsonAsset, AtlasAsset.CreateRuntimeInstance(eo.equipmentTxtAsset, new Texture2D[] { eo.equipmentTexture }, material, initialize), initialize), name, animationName, skinName, loop, data, createSucCallBack, failCallBack, createQueueCallBack, isTP));
     #endif
 }
Пример #2
0
    //创建
    public void CreateAvatar(RoleEquipmentData equipmentData, SpineAvatarType type, string animationName, bool animationLoop, bool isTexturePackage, Action <Avatar> createSucCallBack = null, Action <bool> wearSucCallBack = null, Action <string> failCallBack = null)
    {
        AvatarData data = new AvatarData();

        data.spineAvatarType = type;
        if (null == equipmentData)
        {
            data.plastomerId = "88888888";
        }
        else
        {
            data.plastomerId = equipmentData.RolePlastomerId;
        }
        data.avatarName        = type.ToString();
        data.avatarSkinName    = SpineConstValue.defaultSkinName;
        data.animationName     = animationName;
        data.animationLoop     = animationLoop;
        data.isTexturePackage  = isTexturePackage;
        data.equipmentData     = equipmentData;
        data.createSucCallBack = createSucCallBack;
        data.wearSucCallBack   = wearSucCallBack;
        data.failCallBack      = failCallBack;
        CreateAvatar(data);
    }
Пример #3
0
 public SpineAvatar(RoleEquipmentData equipmentData, SkeletonAnimation skeletonAnimation, Dictionary <int, List <string> > slotAttachmentDic, RoleAnaimationData animationData, CombineTextureData combineTextureData, SpineAvatarType avatarType, Object avatarObject, string roleJsonStr) : base(equipmentData, skeletonAnimation, slotAttachmentDic, animationData, combineTextureData)
 {
     this.avatarObject = avatarObject;
     this.avatarType   = avatarType;
 }
 /// <summary>
 /// 创建角色
 /// </summary>
 /// <param name="skeletonJson">Skeleton json.</param>
 /// <param name="atlasText">Atlas text.</param>
 /// <param name="textures">Textures.</param>
 /// <param name="material">Material.</param>
 /// <param name="initialize">If set to <c>true</c> initialize.</param>
 /// <param name="skinName">Skin name.</param>
 /// <param name="animationName">Animation name.</param>
 /// <param name="loop">If set to <c>true</c> loop.</param>
 /// <param name="pos">Position.</param>
 /// <param name="successfulCallBack">Successful call back.</param>
 /// <param name="failCallBack">Fail call back.</param>
 public void SpineCreateRole(SpineAvatarType avatarType, RoleEquipmentItem equipmentItem, Material material, bool initialize, string name, string skinName, string animationName, bool loop, RoleEquipmentData data, Action <Avatar> createSucCallBack, Action <string> failCallBack, Action <bool> createQueueCallBack, bool isTP)
 {
     SpineChangeDataLogic.Instance.GetRoleEquipmentObject(equipmentItem, (UnityEngine.Object o) => {
         spineChangeCoreLogic.Create(avatarType, o as EquipmentObject, material, initialize, name, skinName, animationName, loop, data, createSucCallBack, failCallBack, createQueueCallBack, isTP);
     });
 }
Пример #5
0
        /// <summary>
        /// 通过skeletonDataAsset创建角色
        /// </summary>
        /// <returns><c>true</c>, if spine role was created, <c>false</c> otherwise.</returns>
        /// <param name="skeletonDataAsset">Skeleton data asset.</param>
        /// <param name="animationName">Animation name.</param>
        /// <param name="skinName">Skin name.</param>
        /// <param name="pos">Position.</param>
        private System.Collections.IEnumerator Create(SpineAvatarType avatarType, EquipmentObject eo, SkeletonDataAsset skeletonDataAsset, string roleGameObjectName, string animationName, string skinName, bool loop, RoleEquipmentData data, Action <Avatar> createSucCallBack, Action <string> failCallBack, Action <bool> createQueueCallBack, bool isTP)
        {
            if (skeletonDataAsset == null)
            {
                if (failCallBack != null)
                {
                    failCallBack.Invoke("<-创建角色失败->");
                }
                yield break;
            }
            GameObject roleSpine = new GameObject {
                name = roleGameObjectName
            };

            roleObject        = roleSpine;
            skeletonAnimation = SkeletonAnimation.AddToGameObject(roleSpine, skeletonDataAsset);
            skeletonAnimation.Initialize(false);
            skeletonAnimation.Skeleton.SetSkin(skinName);
            skeletonAnimation.state.SetAnimation(SpineConstValue.TrackIndex, animationName, loop);
            CreateSlotAttachmentDic(skeletonAnimation.Skeleton.Data.DefaultSkin.Attachments);
            if (null == data)
            {
                equipmentData = new RoleEquipmentData();
                equipmentData.RoleEquipmentItems = new List <RoleEquipmentItem> ();
            }
            else
            {
                equipmentData = data;
            }
            CombineTextureData combineTextureData = new CombineTextureData();

            combineTextureData.resultData = new CombineFinishedData();
            RoleAnaimationData rad = new RoleAnaimationData {
                roleJsonStr = eo.equipmentJsonAsset.text
            };
            Avatar avatar = new SpineAvatar(equipmentData, skeletonAnimation, slotAttachmentDic, rad, combineTextureData, avatarType, roleObject, eo.equipmentJsonAsset.text);

            combineTextureData.resultData.self = avatar;
            if (createSucCallBack != null)
            {
                if (null != roleSpine)
                {
                    roleSpine.SetActive(false);
                    createSucCallBack.Invoke(avatar);
                }
            }
            //初始化角色的所有服装信息
            if (equipmentData.RoleEquipmentItems.Count > 0)
            {
                if (null != combineTextureData.initRoleCoroutine)
                {
                    GameManager.Instance.StopCoroutine(combineTextureData.initRoleCoroutine);
                }
                combineTextureData.initRoleCoroutine = GameManager.Instance.StartCoroutine(InitRoleEquipment(rad, skeletonAnimation, equipmentData, combineTextureData, slotAttachmentDic, avatar.GetDestoryTextureList, roleSpine.SetActive, null, isTP));
                yield return(combineTextureData.initRoleCoroutine);
            }
            else
            {
                roleSpine.SetActive(true);
            }
            if (null != createQueueCallBack)
            {
                createQueueCallBack.Invoke(true);
            }
        }
Пример #6
0
 //创建Avatar
 private void CreateAvatar(SpineAvatarType avatarType, string equipmentId, string name, string skinName, string animationName, bool loop, RoleEquipmentData data, Action <Avatar> createSucCallBack, Action <string> failCallBack, Action <bool> createQueueCallBack, bool isTP)
 {
     SpineChangeManager.Instance.SpineCreateRole(avatarType, RoleEquipmentDataTools.CreateRoleEquipmentItemById(equipmentId), SpineChangeDataLogic.Instance.GetEquipmentMaterial(), true, name, skinName, animationName, loop, data, createSucCallBack, failCallBack, createQueueCallBack, isTP);
 }