-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGenerateFont.cs
More file actions
33 lines (28 loc) · 1 KB
/
GenerateFont.cs
File metadata and controls
33 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GenerateFont : MonoBehaviour {
GameObject damageCanvas;
Text damageText;
int criticalHit;
void Start(){
damageCanvas = Resources.Load("DamageCanvas", typeof(GameObject)) as GameObject;
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Space)){
criticalHit = Random.Range(1,10);
damageText = damageCanvas.transform.Find("DamageText").gameObject.GetComponent<Text>();
if (criticalHit == 1){
damageText.color = Color.red;
damageCanvas.transform.localScale = new Vector3(3f, 3f, 3f);
}
else{
damageText.color = Color.white;
damageCanvas.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
}
Instantiate(damageCanvas, transform);
}
}
}