I have two GameObject arrays with same length. I am trying to copy same values of array1 to array2.
I tried using system.Array.copy(Array1,Array2,4) and also tried Array1= Array2
but not working.
These two arrays are holding 4 buttons each with child text. I want show 4 answers that are assigned to these buttons and copy same answers to another 4 buttons at the same time. Something like dual player.
Can anyone please help?
public class DuelMode : MonoBehaviour{
public static DuelMode instance;
// these are the question values a and b
private int a, b, a1, b1;
//the variable for answer value
[HideInInspector] public int answer;
//varible whihc will assign ans to any one of the 4 answer button
private int locationOfAnswer;
//ref to the button
public GameObject[] ansButtons;
private GameObject[] ansButtonsDuel;
//ref to image symbol so player can know which operation is to be done
public Image mathSymbolObject;
//ref to all the symbol sprites whihc will be used in above image
public Sprite[] mathSymbols;
//get the tag of button
public string tagOfButton;
//ref to text in scene where we will assign a and b values of question
public Text valueA, valueB, valueA1, valueB1;
void Awake()
{
MakeInstance();
}
//method whihc make this object instance
void MakeInstance()
{
if (instance == null)
{
instance = this;
}
}
//at start we need to do few basic setups
void Start()
{
//we put the location value in tag of button variable
tagOfButton = locationOfAnswer.ToString();
MathsProblem();
}
//this method keeps the track of mode
// Update is called once per frame
void Update()
{
tagOfButton = locationOfAnswer.ToString();
}
//Below code is for maths calculation
public void MathsProblem()
{
bool roundActive = true;
}
//this methode perform Multiplication process
void MultiplicationMethod()
{
bool reloop;
bool[] numbers = new bool[301];
b = b1 = Random.Range(1, 10);
locationOfAnswer = Random.Range(0, ansButtons.Length);
answer = a * b;
numbers[answer] = true;
if (valueA != null && valueB != null && valueA1 != null && valueB1 != null)
{
valueA.text = a.ToString();
valueB.text = b.ToString();
valueA1.text = a.ToString();
valueB1.text = b.ToString();
}
mathSymbolObject.sprite = mathSymbols[0];
for (int i = 0; i < ansButtons.Length; i++)
{
if (i == locationOfAnswer)
{
ansButtons[i].GetComponentInChildren<Text>().text = "" + answer;
}
else
{
// the below code make sure that all the values assigned to the ans button are within the range
if (a * b <= 100)
{
ansButtons[i].GetComponentInChildren<Text>().text = "" + Random.Range(1, 101);
}
else if (a * b <= 200 & a * b > 100)
{
ansButtons[i].GetComponentInChildren<Text>().text = "" + Random.Range(101, 201);
}
else if (a * b <= 300 & a * b > 200)
{
ansButtons[i].GetComponentInChildren<Text>().text = "" + Random.Range(201, 301);
}
else if (a * b <= 400 & a * b > 300)
{
ansButtons[i].GetComponentInChildren<Text>().text = "" + Random.Range(301, 401);
}
while (ansButtons[i].GetComponentInChildren<Text>().text == "" + answer)
{
ansButtons[i].GetComponentInChildren<Text>().text = "" + Random.Range(1, 401);
}
}
}
}
}