Answers for "how to use setcolor unity"

C#
4

unity c# change color of gameobject

using UnityEngine; 
using System.Collections; 

public class collisionpill : MonoBehaviour 
{      
  	public Color mycolor;       
  	
  	void OnCollisionEnter(Collision other) 
    {         
        if (other.transform.tag == "Pill") 
        {             
        	gameObject.GetComponent<Renderer>().material.color = mycolor;
        }    
    }
}
Posted by: Guest on June-27-2020
0

change olour in unity script

SpriteRenderer sr;

void Start()
{
	sr = GetComponent<SpriteRenderer>();
}
void Update()
{
	//This is a simple way of adding color
	sr.color = Color.red;
	//This is a more specific way of adding color
    sr.color = new Color(0/*Red*/,0/*Green*/,0/*Blue*/)
}
Posted by: Guest on July-24-2020
0

new color unity

Color color = new Color(red,green,blue,alpha)//Alpha 0 is transparent
Posted by: Guest on November-14-2020

Code answers related to "how to use setcolor unity"

C# Answers by Framework

Browse Popular Code Answers by Language