Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity change sprite source image

using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;
using UnityEngine.UI;

private SpriteRenderer old_sprite_img;
public Sprite new_sprite_img;//USE INSPECTOR TO PUT THE NEW IMG SOURCE


void start()
{
  //FIND YOUR OBJECT TO CHANGE THE IMG
object_compoent = GameObject.FindWithTag("your_tag_name");


old_sprite_img = object_compoent.GetComponent<SpriteRenderer>();
old_sprite_img.sprite = new_sprite_img;
}
 
PREVIOUS NEXT
Tagged: #unity #change #sprite #source #image
ADD COMMENT
Topic
Name
9+5 =