Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity change color of sprite in script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class setColor : MonoBehaviour
{
     SpriteRenderer sprite;
     
     //this will easilly make u choose the color u want
     public Color newColor;
     
    void Start()
    {
        sprite = GetComponentInChildren<SpriteRenderer>();
        sprite.color = newColor; 
    }
}
Comment

how to change the color of a sprite in unity

//option 1
GetComponent<spriteRenderer>().color = Color.red

//option 2
sprite.color = new Color (R, G, B, A);
Comment

change sprite color unity

sprite.color = new Color (1, 0, 0, 1); 
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to loop over array in c# 
Csharp :: httppostedfilebase in .net core 3.1 
Csharp :: all month in array 
Csharp :: https port 
Csharp :: how to copy last element in list c# 
Csharp :: unity getcomponent not working on ui 
Csharp :: c# get all the column names from datagridview 
Csharp :: c# to binary 
Csharp :: read folder c# 
Csharp :: crop bitmap image c# 
Csharp :: c# size of enum 
Csharp :: how to make an object move in unity 
Csharp :: accessing form controls from another class c# 
Csharp :: return json from controller c# 
Csharp :: c# socket connect timeout 
Csharp :: how to clone somthing unity 
Csharp :: list removeall unity 
Csharp :: c# ftp file download 
Csharp :: escape double quotes c# 
Csharp :: c# mathf.ceiling 
Csharp :: system.io.directorynotfoundexception c# 
Csharp :: c# jobject to string 
Csharp :: unity how to move an object 
Csharp :: wpf c# select folder path 
Csharp :: add all elements in a list c# 
Csharp :: c# check lenght 
Csharp :: c# xor byte array 
Csharp :: c# add to array 
Csharp :: c# list audio devices 
Csharp :: C# add two numbers using a method 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =