void Start() { //Set the static variables WorldSpaceCanvas = GameObject.Find("WorldSpaceCanvas"); ScreenSpaceCanvas = GameObject.Find("ScreenSpaceCanvas"); Floatingtext = PopUpText; OnScreenFloatingText = onScreenFloatingText; OnScreenDamage = onScreenDamage; }
// Use this for initialization void Start() { mainCamera = FindObjectOfType <MainCamera>(); screenMessage = FindObjectOfType <OnScreenText>(); hungerBar = FindObjectOfType <HungerBar>(); inspectionButtons = GameObject.FindGameObjectsWithTag("InspectionButton"); HideInspectionOptions(); mushroomCountText = GameObject.FindGameObjectWithTag("MushroomCountText").GetComponent <Text>(); levelInfo = FindObjectOfType <CurrentLevelInfo>(); desiredMushroom = levelInfo.desiredMushroom; levelInfo.mushroomCount = 0; levelInfo.pickedMushrooms = new Dictionary <MushroomScript.MushroomName, int>(); }
//A function which displays text one screen public static void DisplayTextOnScreen(string Text) { OnScreenText floatingtext = Instantiate(OnScreenFloatingText); //GameObject floatingtext = Instantiate(OnScreenFloatingText) as GameObject; //Instantiate the floating damage text at target location and give it a rotation of caster. floatingtext.transform.SetParent(ScreenSpaceCanvas.transform, false); //damagetext.transform.position = DamagedObj.transform.position; floatingtext.transform.position = new Vector3(floatingtext.transform.position.x * 1.3f, floatingtext.transform.position.y * 0.4f, floatingtext.transform.position.z); floatingtext.GetComponent <OnScreenText>().DisplayText(Text); //Pass the damaget to the popup damge script attatced to floatingdamagetext gameobject. }