Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class SpriteSwitcher : MonoBehaviour {
- SkeletonRenderer skeletonRenderer;
- [SpineSlot]
- public string weaponSlot;
- [SpineSlot]
- public string offhandSlot;
- [SpineSlot]
- public string chestSlot;
- [SpineSkin]
- public string skin;
- void Awake ()
- {
- skeletonRenderer = GetComponent<SkeletonRenderer>();
- }
- //called any time equipment is changed to visually change sprites
- public void ChangeSprite(EntityEquipment.EquipSlot equipSlot, string equipImage)
- {
- string image = (!string.IsNullOrEmpty(equipImage)) ? equipImage : "none";
- if (equipSlot == EntityEquipment.EquipSlot.RightHand)
- {
- Spine.Attachment mainhandAttachment = skeletonRenderer.skeleton.Data.AddUnitySprite(weaponSlot, ItemManager.Instance.equipmentSprites[image], skin, "Custom/SpriteAdditive");
- skeletonRenderer.skeleton.SetAttachment(weaponSlot, image);
- }
- if (equipSlot == EntityEquipment.EquipSlot.LeftHand)
- {
- Spine.Attachment offhandAttachment = skeletonRenderer.skeleton.Data.AddUnitySprite(offhandSlot, ItemManager.Instance.equipmentSprites[image], skin, "Custom/SpriteAdditive");
- skeletonRenderer.skeleton.SetAttachment(offhandSlot, image);
- }
- if (equipSlot == EntityEquipment.EquipSlot.Chest)
- {
- //Spine.Attachment chestAttachment = skeletonRenderer.skeleton.Data.AddUnitySprite(chestSlot, ItemManager.Instance.equipmentSprites[image], skin, "Custom/SpriteAdditive");
- //skeletonRenderer.skeleton.SetAttachment(chestSlot, image);
- Spine.Attachment chestAttachment = skeletonRenderer.skeleton.Data.AddUnitySprite(chestSlot, ItemManager.Instance.equipmentSprites["body_red"], skin, "Custom/SpriteAdditive");
- skeletonRenderer.skeleton.SetAttachment(chestSlot, "body_red");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement