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 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 :: blazor button onclick parameter 
Csharp :: c# rename file add 
Csharp :: button action asp net 
Csharp :: lump in neck under jaw 
Csharp :: c# 2-dimensional array sort 
Csharp :: how to join array indexes with comma in c# 
Csharp :: convert string to array c# 
Csharp :: How to read a XML on C# 
Csharp :: includes method C# 
Csharp :: readonly vs const c# 
Csharp :: unique id c# 
Csharp :: unity up arrow input 
Csharp :: unity detect any key 
Csharp :: How can you learn C# on your own 
Csharp :: C# convert iformfile to stream 
Csharp :: bootstrap modal 
Csharp :: how to get the position of a camera in unity 
Csharp :: unity change particle system sorting layer via script 
Csharp :: mathf.clamp unity 
Csharp :: how to close and reopen an app in c# 
Csharp :: create char array c# 
Csharp :: how to make a specific scene load only on game start in unity 
Csharp :: unity point between two positions 
Csharp :: c# compile code at runtime 
Csharp :: c# get value from textbox 
Csharp :: c# dictionary initializer 
Csharp :: how to print dictionary in c# 
Csharp :: how to print hello world in c# 
Csharp :: Open another form with C# Winforms 
Csharp :: c# environment variables 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =