void Start() { for (int i = 0; i < NumberOfNPC; i++) { if (SpawnType == 0) { // TextMesh Pro Implementation //go.transform.localScale = new Vector3(2, 2, 2); GameObject go = new GameObject(); //"NPC " + i); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f)); //go.transform.position = new Vector3(0, 1.01f, 0); //go.renderer.castShadows = false; //go.renderer.receiveShadows = false; //go.transform.rotation = Quaternion.Euler(0, Random.Range(0, 360), 0); TextMeshPro textMeshPro = go.AddComponent<TextMeshPro>(); TextContainer textContainer = go.GetComponent<TextContainer>(); //textMeshPro.FontAsset = Resources.Load("Fonts & Materials/ARIAL SDF 16", typeof(TextMeshProFont)) as TextMeshProFont; //textMeshPro.anchor = AnchorPositions.Bottom; //textContainer.anchorPosition = TextContainerAnchors.Bottom; textContainer.isAutoFitting = false; textMeshPro.alignment = TextAlignmentOptions.Bottom; textMeshPro.fontSize = 96; textMeshPro.color = new Color32(255, 255, 0, 255); textMeshPro.text = "!"; //textMeshPro.extraPadding = true; // Spawn Floating Text floatingText_Script = go.AddComponent<TextMeshProFloatingText>(); floatingText_Script.SpawnType = 0; } else { // TextMesh Implementation GameObject go = new GameObject(); //"NPC " + i); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f)); //go.transform.position = new Vector3(0, 1.01f, 0); TextMesh textMesh = go.AddComponent<TextMesh>(); textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font; textMesh.GetComponent<Renderer>().sharedMaterial = textMesh.font.material; textMesh.anchor = TextAnchor.LowerCenter; textMesh.fontSize = 96; textMesh.color = new Color32(255, 255, 0, 255); textMesh.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent<TextMeshProFloatingText>(); floatingText_Script.SpawnType = 1; } } }
void Start() { for (int i = 0; i < NumberOfNPC; i++) { if (SpawnType == 0) { // TextMesh Pro Implementation //go.transform.localScale = new Vector3(2, 2, 2); GameObject go = new GameObject(); //"NPC " + i); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f)); //go.transform.position = new Vector3(0, 1.01f, 0); //go.renderer.castShadows = false; //go.renderer.receiveShadows = false; //go.transform.rotation = Quaternion.Euler(0, Random.Range(0, 360), 0); TextMeshPro textMeshPro = go.AddComponent <TextMeshPro>(); TextContainer textContainer = go.GetComponent <TextContainer>(); //textMeshPro.FontAsset = Resources.Load("Fonts & Materials/ARIAL SDF 16", typeof(TextMeshProFont)) as TextMeshProFont; //textMeshPro.anchor = AnchorPositions.Bottom; //textContainer.anchorPosition = TextContainerAnchors.Bottom; textContainer.isAutoFitting = false; textMeshPro.alignment = TextAlignmentOptions.Bottom; textMeshPro.fontSize = 96; textMeshPro.color = new Color32(255, 255, 0, 255); textMeshPro.text = "!"; //textMeshPro.extraPadding = true; // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 0; } else { // TextMesh Implementation GameObject go = new GameObject(); //"NPC " + i); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f)); //go.transform.position = new Vector3(0, 1.01f, 0); TextMesh textMesh = go.AddComponent <TextMesh>(); textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font; textMesh.GetComponent <Renderer>().sharedMaterial = textMesh.font.material; textMesh.anchor = TextAnchor.LowerCenter; textMesh.fontSize = 96; textMesh.color = new Color32(255, 255, 0, 255); textMesh.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 1; } } }
private void Start() { for (var i = 0; i < NumberOfNPC; i++) { if (SpawnType == 0) { // TextMesh Pro Implementation //go.transform.localScale = new Vector3(2, 2, 2); var go = new GameObject(); //"NPC " + i); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.5f, Random.Range(-95f, 95f)); //go.transform.position = new Vector3(0, 1.01f, 0); //go.renderer.castShadows = false; //go.renderer.receiveShadows = false; //go.transform.rotation = Quaternion.Euler(0, Random.Range(0, 360), 0); var textMeshPro = go.AddComponent <TextMeshPro>(); //textMeshPro.FontAsset = Resources.Load("Fonts & Materials/LiberationSans SDF", typeof(TextMeshProFont)) as TextMeshProFont; //textMeshPro.anchor = AnchorPositions.Bottom; textMeshPro.fontSize = 96; textMeshPro.text = "!"; textMeshPro.color = new Color32(255, 255, 0, 255); //textMeshPro.Text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 0; } else { // TextMesh Implementation var go = new GameObject(); //"NPC " + i); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.5f, Random.Range(-95f, 95f)); //go.transform.position = new Vector3(0, 1.01f, 0); var textMesh = go.AddComponent <TextMesh>(); textMesh.GetComponent <Renderer>().sharedMaterial = TheFont.material; textMesh.font = TheFont; textMesh.anchor = TextAnchor.LowerCenter; textMesh.fontSize = 96; textMesh.color = new Color32(255, 255, 0, 255); textMesh.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 1; } } }
void Start() { for (int i = 0; i < NumberOfNPC; i++) { if (SpawnType == 0) { // TextMesh Pro Implementation //commented out code was ommited here GameObject go = new GameObject(); //"NPC " + i); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.5f, Random.Range(-95f, 95f)); //commented out code was ommited here //commented out code was ommited here //commented out code was ommited here //commented out code was ommited here TextMeshPro textMeshPro = go.AddComponent <TextMeshPro>(); //commented out code was ommited here //commented out code was ommited here textMeshPro.fontSize = 96; textMeshPro.text = "!"; textMeshPro.color = new Color32(255, 255, 0, 255); //commented out code was ommited here // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 0; } else { // TextMesh Implementation GameObject go = new GameObject(); //"NPC " + i); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.5f, Random.Range(-95f, 95f)); //commented out code was ommited here TextMesh textMesh = go.AddComponent <TextMesh>(); textMesh.GetComponent <Renderer>().sharedMaterial = TheFont.material; textMesh.font = TheFont; textMesh.anchor = TextAnchor.LowerCenter; textMesh.fontSize = 96; textMesh.color = new Color32(255, 255, 0, 255); textMesh.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 1; } } }
void Start() { for (int i = 0; i < NumberOfNPC; i++) { if (SpawnType == 0) { // TextMesh Pro Implementation GameObject go = new GameObject(); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f)); TextMeshPro textMeshPro = go.AddComponent <TextMeshPro>(); textMeshPro.autoSizeTextContainer = true; textMeshPro.rectTransform.pivot = new Vector2(0.5f, 0); textMeshPro.alignment = TextAlignmentOptions.Bottom; textMeshPro.fontSize = 96; textMeshPro.enableKerning = false; textMeshPro.color = new Color32(255, 255, 0, 255); textMeshPro.text = "!"; textMeshPro.isTextObjectScaleStatic = IsTextObjectScaleStatic; // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 0; floatingText_Script.IsTextObjectScaleStatic = IsTextObjectScaleStatic; } else if (SpawnType == 1) { // TextMesh Implementation GameObject go = new GameObject(); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f)); TextMesh textMesh = go.AddComponent <TextMesh>(); textMesh.font = Resources.Load <Font>("Fonts/ARIAL"); textMesh.GetComponent <Renderer>().sharedMaterial = textMesh.font.material; textMesh.anchor = TextAnchor.LowerCenter; textMesh.fontSize = 96; textMesh.color = new Color32(255, 255, 0, 255); textMesh.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 1; } else if (SpawnType == 2) { // Canvas WorldSpace Camera GameObject go = new GameObject(); Canvas canvas = go.AddComponent <Canvas>(); canvas.worldCamera = Camera.main; go.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); go.transform.position = new Vector3(Random.Range(-95f, 95f), 5f, Random.Range(-95f, 95f)); TextMeshProUGUI textObject = new GameObject().AddComponent <TextMeshProUGUI>(); textObject.rectTransform.SetParent(go.transform, false); textObject.color = new Color32(255, 255, 0, 255); textObject.alignment = TextAlignmentOptions.Bottom; textObject.fontSize = 96; textObject.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 0; } } }
void Start() { for (int i = 0; i < NumberOfNPC; i++) { if (SpawnType == 0) { // TextMesh Pro Implementation GameObject go = new GameObject(); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f)); TextMeshPro textMeshPro = go.AddComponent<TextMeshPro>(); TextContainer textContainer = go.GetComponent<TextContainer>(); textContainer.isAutoFitting = false; textMeshPro.alignment = TextAlignmentOptions.Bottom; textMeshPro.fontSize = 96; textMeshPro.color = new Color32(255, 255, 0, 255); textMeshPro.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent<TextMeshProFloatingText>(); floatingText_Script.SpawnType = 0; } else if (SpawnType == 1) { // TextMesh Implementation GameObject go = new GameObject(); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f)); TextMesh textMesh = go.AddComponent<TextMesh>(); textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font; textMesh.GetComponent<Renderer>().sharedMaterial = textMesh.font.material; textMesh.anchor = TextAnchor.LowerCenter; textMesh.fontSize = 96; textMesh.color = new Color32(255, 255, 0, 255); textMesh.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent<TextMeshProFloatingText>(); floatingText_Script.SpawnType = 1; } else if (SpawnType == 2) { // Canvas WorldSpace Camera GameObject go = new GameObject(); Canvas canvas = go.AddComponent<Canvas>(); canvas.worldCamera = Camera.main; go.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); go.transform.position = new Vector3(Random.Range(-95f, 95f), 5f, Random.Range(-95f, 95f)); TextMeshProUGUI textObject = new GameObject().AddComponent<TextMeshProUGUI>(); textObject.rectTransform.SetParent(go.transform, false); textObject.color = new Color32(255, 255, 0, 255); textObject.alignment = TextAlignmentOptions.Bottom; textObject.fontSize = 96; textObject.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent<TextMeshProFloatingText>(); floatingText_Script.SpawnType = 0; } } }