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 :: parse strings into words C# 
Csharp :: make 2D object move at constant speed unity 
Csharp :: c# debug writeline 
Csharp :: linq query in c# 
Csharp :: unity detect a touch on ui element 
Csharp :: unity render to texture2d 
Csharp :: c# get all classes derived from type 
Csharp :: asp.net core 6 autofac 
Csharp :: unity2d movement 
Csharp :: c# type of string 
Csharp :: initialize a char array java 
Csharp :: unity getcomponent 
Csharp :: c# normalize value 
Csharp :: c# arrow 
Csharp :: c# get witdh of matrix 
Csharp :: razor concatonate inline 
Csharp :: asp net img src path from database 
Csharp :: listview imagelist c# 
Csharp :: get min date in list c# 
Csharp :: add qtwidgets to cmake file 
Csharp :: C# program lambda Func 
Csharp :: print c# 
Csharp :: C# Find first thing on a list 
Csharp :: c# access substring 
Csharp :: context.Response.Body read stream .net 
Csharp :: c# record 
Csharp :: Screen.lockcursor unity 
Csharp :: c# loop 2 time tables 
Csharp :: #dictionery in c 
Csharp :: how to fill model enum with bradio button asp razor 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =