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 :: c# find duplicates in list of strings 
Csharp :: c# create dynamic object 
Csharp :: How to get an array of months in c# 
Csharp :: c# compile code at runtime 
Csharp :: c# get the last item in a list 
Csharp :: how to get the width of the screen C# 
Csharp :: c# 
Csharp :: c# wpf change label text color 
Csharp :: c# base64 encode 
Csharp :: c# void 
Csharp :: C# delete folder with all contents 
Csharp :: c# string array to string 
Csharp :: linux command line switch statement 
Csharp :: clear controls from panel c# 
Csharp :: c# string array contains 
Csharp :: int value from enum in C# 
Csharp :: get layermask from gameobject layer unity 
Csharp :: c# environment variables 
Csharp :: unity check if other object is colliding 
Csharp :: get any random item in array c# 
Csharp :: c# how to sort a list 
Csharp :: c# switch unity 
Csharp :: change name of gameobject 
Csharp :: asp.net c# set session timeout 
Csharp :: c# byte 
Csharp :: parse datetime c# 
Csharp :: c# new object without class 
Csharp :: how to use navmeshagent in unity 
Csharp :: c# mongodb update multiple fields 
Csharp :: c# space as string 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =