Im really new and looking at some examples of an array are kind of confusing.
Im making a simple deck of cards. I have all card images in an array. Now for each element of the array is it possible to store in the same array the suit and card value of each element in the array.
Example
Element 0 = a picture of Ace of Spades
How can I add in the Suit Spades and value of 1 to that element specifically.
There are several ways to achieve this.
Example 1 - Two Arrays
Have two arrays, one purposed to each value.
public class Example : MonoBehaviour {
public Texture2D[] cardTextures = { };
public int[] cardValues = { };
public void Start() {
if (cardTextures.Length != cardValues.Length)
Debug.LogError("Length of card texture and value arrays are mismatched!");
for (int i = 0; i < cardTextures.Length; ++i) {
Texture2D texture = cardTextures[i];
int value = cardValues[i];
Debug.Log(string.Format("Card {0} has value {1} and texture '{2}'.", i + 1, value, texture.name));
}
}
}
Example 2 - Custom Class
Produce an array of a custom class rather than individual values.
// Card.cs
using System;
using UnityEngine;
[Serializable]
public sealed class Card {
public Texture2D texture;
public int value;
}
// Example.cs
using UnityEngine;
public class Example : MonoBehaviour {
public Card[] cards = { };
public void Start() {
int counter = 1;
foreach (var card in cards) {
Debug.Log(string.Format("Card {0} has value {1} and texture '{2}'.", counter, vard.value, card.texture.name));
++counter;
}
}
}
Example 3 - Prefab for Each Card
Same as previous, but create one prefab for each card.
// Card.cs
using UnityEngine;
public class Card : MonoBehaviour {
public Texture2D texture;
public int value;
}
// Example.cs
using UnityEngine;
public class Example : MonoBehaviour {
public Card[] cards = { };
public void Start() {
int counter = 1;
foreach (var card in cards) {
Debug.Log(string.Format("Card {0} has value {1} and texture '{2}'.", counter, vard.value, card.texture.name));
++counter;
}
}
}
I hope that this helps 
Thank you very much im using Example 2.