// Use this for initialization void Start() { gameLogic = new MakeNumber (); //Load the Sound audioSource = GetComponent<AudioSource>(); buttonSound = Resources.Load ("twoTone2") as AudioClip; if( audioSource == null || buttonSound == null ){ Debug.LogError("GameMasterBehavior could not load audio"); } //Find the Text GameObject textGameObject = GameObject.Find ("ChosenNumberText"); chosenText = textGameObject.GetComponent<Text> (); if (chosenText == null) { Debug.LogError("GameMasterBehavior is not attached to an Output text"); } //Find the lowerLimit Text GameObject lowerTextGameObject = GameObject.Find ("LowerNumberText"); lowerText = lowerTextGameObject.GetComponent<Text> (); if (lowerText == null) { Debug.LogError("GameMasterBehavior is not attached to an Output text"); } //Find the upperLimit Text GameObject upperTextGameObject = GameObject.Find ("UpperNumberText"); upperText = upperTextGameObject.GetComponent<Text> (); if (upperText == null) { Debug.LogError("GameMasterBehavior is not attached to an Output text"); } //Find the Button GameObject buttonGameObject = GameObject.Find ("GuessButton"); guessButton = buttonGameObject.GetComponent<Button> (); if (guessButton == null) { Debug.LogError("GameMasterBehavior is not attached to a button"); } //Add the event handler guessButton.onClick.AddListener (guessAction); //Find the Slider GameObject sliderGameObject = GameObject.Find ("GuessSlider"); slider = sliderGameObject.GetComponent<Slider> (); if (slider == null) { Debug.LogError("GameMasterBehavior is not attached to a slider"); } gameInitialize (); }
// Use this for initialization void Start() { gameLogic = new MakeNumber(); //Load the Sound audioSource = GetComponent <AudioSource>(); buttonSound = Resources.Load("twoTone2") as AudioClip; if (audioSource == null || buttonSound == null) { Debug.LogError("GameMasterBehavior could not load audio"); } //Find the Text GameObject textGameObject = GameObject.Find("ChosenNumberText"); chosenText = textGameObject.GetComponent <Text> (); if (chosenText == null) { Debug.LogError("GameMasterBehavior is not attached to an Output text"); } //Find the lowerLimit Text GameObject lowerTextGameObject = GameObject.Find("LowerNumberText"); lowerText = lowerTextGameObject.GetComponent <Text> (); if (lowerText == null) { Debug.LogError("GameMasterBehavior is not attached to an Output text"); } //Find the upperLimit Text GameObject upperTextGameObject = GameObject.Find("UpperNumberText"); upperText = upperTextGameObject.GetComponent <Text> (); if (upperText == null) { Debug.LogError("GameMasterBehavior is not attached to an Output text"); } //Find the Button GameObject buttonGameObject = GameObject.Find("GuessButton"); guessButton = buttonGameObject.GetComponent <Button> (); if (guessButton == null) { Debug.LogError("GameMasterBehavior is not attached to a button"); } //Add the event handler guessButton.onClick.AddListener(guessAction); //Find the Slider GameObject sliderGameObject = GameObject.Find("GuessSlider"); slider = sliderGameObject.GetComponent <Slider> (); if (slider == null) { Debug.LogError("GameMasterBehavior is not attached to a slider"); } gameInitialize(); }