How to access multiple components of a component at once?

**I want my function to pick texture and color of the same RawImage from the random array of RawImages. But i can’t seem to do that .

I have tried accessing both texture and color separately but due it i get color from another RawImage and texture from another . So please kindly help me.**

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class DisplayColor7 : MonoBehaviour {


	public RawImage[] buttons;
	public RawImage DeadPool;

	public	void Start () {
		
		
		changeColor ();
		
		
	}
	
	
	public	void changeColor() {
	

		GetComponent<RawImage>().texture&Color = buttons [Random.Range (0, buttons.Length - 1)].texture&Color; 

		
		//DeadPool = this. buttons [Random.Range (0, buttons.Length - 1)];
	
		//DeadPool = new RawImage(buttons [Random.Range (0, buttons.Length - 1)].mainTexture);

 }
}

You should store the random button and the RawImage component as variables and assign to the texture and color on two separate lines. It seems like you might want to check out the Unity documentation on variables to figure this out. https://unity3d.com/learn/tutorials/modules/beginner/scripting/variables-and-functions

Hello!

If I correctly understand you, you want to take the Texture and Color of DeadPool from buttons.

To achieve this your can do like that:

	public class DisplayColor7 : MonoBehaviour
	{
		public RawImage[]	buttons;
		public RawImage		DeadPool;

		public void	Start()
		{
			changeColor();
		}

		public void	changeColor()
		{
			int	randomValue = Random.Range(0, buttons.Length - 1);

            DeadPool.color = buttons[randomValue].color;
            DeadPool.texture = buttons[randomValue].texture;
		}
	}