Question by 
               Spatenfrosch70 · Jan 01, 2018 at 08:21 PM · 
                spriteimagechange  
              
 
              How I can change the sprite of the image because the code doesn't work?
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class videotesttest : MonoBehaviour {
 private float bildRate;
 private float nextBild;
 private int counter;
 public int maxSpriteAnzahl;
 public Image pic;
 void Start()
 {
     bildRate = 0.0333333f;
     pic = GetComponent<Image>();
 }
 void Update()
 {
     if (Time.time > nextBild)
     {
         nextBild = Time.time + bildRate;
         counter++;
         spriteAufrufen();
         Debug.Log(counter);
     }
     if (counter >= maxSpriteAnzahl)
     {
         counter = 0;
     }
 }
 void spriteAufrufen()
 {
     if (counter == 1)
     {
         Sprite sprit = Resources.Load("Resources/1") as Sprite;
         pic.sprite = sprit;
         
     }
     if (counter == 2)
     {
         Sprite sprit = Resources.Load("Resources/2") as Sprite;
         pic.sprite = sprit;
         
     }
 }
 
               } thx for your help!!! :-D
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Sprites are invisible when passed between scenes 1 Answer
Trouble getting created sprite to set. 0 Answers
Glowing 2D items 0 Answers
Image Sprite is defaulting when GO is SetActive 1 Answer
How do I scale icons independently? 0 Answers