Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.97 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class SpriteSwitcher : MonoBehaviour {
  6.     SkeletonRenderer skeletonRenderer;
  7.  
  8.     [SpineSlot]
  9.     public string weaponSlot;
  10.  
  11.     [SpineSlot]
  12.     public string offhandSlot;
  13.  
  14.     [SpineSlot]
  15.     public string chestSlot;
  16.  
  17.     [SpineSkin]
  18.     public string skin;
  19.  
  20.     void Awake ()
  21.     {
  22.         skeletonRenderer = GetComponent<SkeletonRenderer>();
  23.     }
  24.  
  25.     //called any time equipment is changed to visually change sprites
  26.     public void ChangeSprite(EntityEquipment.EquipSlot equipSlot, string equipImage)
  27.     {
  28.         string image = (!string.IsNullOrEmpty(equipImage)) ? equipImage : "none";
  29.  
  30.         if (equipSlot == EntityEquipment.EquipSlot.RightHand)
  31.         {
  32.             Spine.Attachment mainhandAttachment = skeletonRenderer.skeleton.Data.AddUnitySprite(weaponSlot, ItemManager.Instance.equipmentSprites[image], skin, "Custom/SpriteAdditive");
  33.             skeletonRenderer.skeleton.SetAttachment(weaponSlot, image);
  34.         }
  35.  
  36.         if (equipSlot == EntityEquipment.EquipSlot.LeftHand)
  37.         {
  38.             Spine.Attachment offhandAttachment = skeletonRenderer.skeleton.Data.AddUnitySprite(offhandSlot, ItemManager.Instance.equipmentSprites[image], skin, "Custom/SpriteAdditive");
  39.             skeletonRenderer.skeleton.SetAttachment(offhandSlot, image);
  40.         }
  41.  
  42.         if (equipSlot == EntityEquipment.EquipSlot.Chest)
  43.         {
  44.             //Spine.Attachment chestAttachment = skeletonRenderer.skeleton.Data.AddUnitySprite(chestSlot, ItemManager.Instance.equipmentSprites[image], skin, "Custom/SpriteAdditive");
  45.             //skeletonRenderer.skeleton.SetAttachment(chestSlot, image);
  46.  
  47.             Spine.Attachment chestAttachment = skeletonRenderer.skeleton.Data.AddUnitySprite(chestSlot, ItemManager.Instance.equipmentSprites["body_red"], skin, "Custom/SpriteAdditive");
  48.             skeletonRenderer.skeleton.SetAttachment(chestSlot, "body_red");
  49.         }
  50.     }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement