Skip to content

Instantly share code, notes, and snippets.

@pmarinr
Created October 22, 2014 13:38
Show Gist options
  • Save pmarinr/5d54ab73087858c5d548 to your computer and use it in GitHub Desktop.
Save pmarinr/5d54ab73087858c5d548 to your computer and use it in GitHub Desktop.
Cambia el spritesheet de una animación
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