- Home /
Question by
Abhi94 · Jun 11, 2015 at 10:41 AM ·
scripting problemboolaccess
I want to access bool component of my one script in another script but i am not able to do , please help me its urgent
these are my two scripts (onClick1 has that bool element) using UnityEngine; using System.Collections; using UnityEngine.UI;
public class onClick1 : MonoBehaviour {
public bool hello;
public Text ScoreText;
public int Count = 10;
public void SayHello( bool hello ) {
if (GetComponent<Image>().color == GameObject.FindGameObjectWithTag("DisplayButton").GetComponent<Image>().color)
{
hello = true;
ScoreText.text = "SCORE: " + Count;
Debug.Log("Hello");
}
}
}
this is other script from which i want to access it ( i have tried to access it in void update but it is not working)
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class DisplayColor : MonoBehaviour {
public Button[] buttons;
void Start () {
GetComponent<Image>().color = buttons[Random.Range(0, buttons.Length - 1)].image.color;
}
void update() {
if (hello = true) {
GetComponent<Image>().color = buttons[Random.Range(0, buttons.Length - 1)].image.color;
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613200849im_/https://answers.unity.com/themes/thub/images/avi.jpg)