I want to be able to change the color of my UI image in my canvas from a script located on another object.
something along the lines of …
var image: GUI;
image.GUI.color(1,1,1);
just can’t seem to find something to make it work
change the color on this image using JS
[33785-screen+shot+2014-10-16+at+1.33.51+pm.png|33785]
GetComponent(Image).color = x
Import the UnityEngine.UI namespace first, or else specify UnityEngine.UI.Image.
I dont know about js but try to convert to js
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class StarColor : MonoBehaviour
{
public Color A = Color.magenta;
public Color B = Color.blue;
public float speed = 1.0f;
private Image col;
//SpriteRenderer spriteRenderer;
void Start ()
{
col = gameObject.GetComponent<Image> ();
//spriteRenderer = GetComponent<SpriteRenderer> ();
}
void Update ()
{
col.color = Color.Lerp (A, B, Mathf.PingPong (Time.time * speed, 1.0f));
}
}
Blockquote