- Home /
Question by
KristianGrytdal · Aug 03, 2016 at 06:38 AM ·
c#script.sceneimageinputfield
Making an image appear from a different script
Hey, I need to make an image appear when the CompareGuesses gets activated. This script is on a InputField on a scene called "ArmyOfTwo" and when the person answers correctly an image needs to become visible on a scene called "Level 1" The image on scene "Level 1" is called ArmyOfTwoImage. Can anybody help my with making the script that is needed? Thanks in advance :) using UnityEngine; using System.Collections; using UnityEngine.UI; using UnityEngine.SceneManagement;
public class ArmyOfTwo: MonoBehaviour {
private string gameName;
private int countGuess;
[SerializeField]
private InputField input;
[SerializeField]
private Text text;
void Awake(){
gameName = "army of two";
text.text = "Guess The Name Of The Game";
}
public void GetInput(string guess){
CompareGuesses(guess);
input.text = "";
}
public void CompareGuesses (string guess){
if (guess == gameName) {
text.text = "You Guessed Correctly";
SceneManager.LoadScene("Level 1");
} else if (guess != gameName) {
text.text = "Wrong!";
} else if (guess != gameName) {
text.text = "Wrong!";
}
}
}
Comment