Search
 
SCRIPT & CODE EXAMPLE
 

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;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: format phone number in c# .net 
Csharp :: unity why is there no transform.left 
Csharp :: 3(x-4)-2(3x+4)=4(3-x)+5x+4 
Csharp :: ping with c# 
Csharp :: onafterrender blazor 
Csharp :: unity instantiate empty gameobject 
Csharp :: newline in button wpf 
Csharp :: c# base64 decode 
Csharp :: C# save pdf stream to file 
Csharp :: c# mysql query 
Csharp :: c# difference between break and continue 
Csharp :: check animation end unity 
Csharp :: create asset menu unity 
Csharp :: c# main method 
Csharp :: get remainder of number c# 
Csharp :: get host ip address asp.net core 
Csharp :: c# datediff minutes 
Csharp :: keyboard input unity 
Csharp :: Add float value to ui text in unity 
Csharp :: unity c# set list to set active true 
Csharp :: how to update a project to cross target .net core 
Csharp :: why vue cli do not refresh auto in local host 
Csharp :: c# winforms tooltip 
Csharp :: find many object with tag unity 
Csharp :: convert request.form to dictionary c# 
Csharp :: how to compare 2 date time in asp.net core 3.1 
Csharp :: removing illlegal char from filename 
Csharp :: c# object initialization can be simplified 
Csharp :: c# loading assembly at runtime 
Csharp :: c# start process and wait for exit code 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =