Created
October 22, 2014 13:38
-
-
Save pmarinr/5d54ab73087858c5d548 to your computer and use it in GitHub Desktop.
Cambia el spritesheet de una animación
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System; | |
public class ReSkinAnimation : MonoBehaviour { | |
public string spriteName; | |
// Update is called once per frame | |
void LateUpdate () { | |
var subSprites = Resources.LoadAll<Sprite>("Characters/"+spriteName); | |
Debug.Log ("Characters/"+spriteName); | |
foreach (var renderer in GetComponentsInChildren<SpriteRenderer>()){ | |
string sname = renderer.sprite.name; | |
var newSprite = Array.Find(subSprites, item => item.name == sname); | |
if(newSprite) | |
renderer.sprite = newSprite; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment