Ejemplo n.º 1
0
    public void SpawnDamageCounter(Vector3 pos)
    {
        // TextMesh Pro Implementation
        GameObject go = new GameObject();

        go.name = "Damage Counter";
        go.transform.position = new Vector3(
            pos.x + Random.Range(-0.2f, 0.2f),
            pos.y + Random.Range(-0.2f, 0.2f),
            1);
        TextMeshPro textMeshPro = go.AddComponent <TextMeshPro>();

        textMeshPro.autoSizeTextContainer = true;
        textMeshPro.rectTransform.pivot   = new Vector2(0.5f, 0);

        textMeshPro.alignment     = TextAlignmentOptions.Bottom;
        textMeshPro.font          = font;
        textMeshPro.fontSize      = damageCounterSize;
        textMeshPro.enableKerning = false;

        textMeshPro.color = damageCounterColour;
        textMeshPro.text  = damage.ToString();

        // Spawn Floating Text
        floatingText_Script = go.AddComponent <TextMeshProFloatingText>();
        go.AddComponent <DamageCounter>();
        floatingText_Script.SpawnType = 0;
        Destroy(floatingText_Script.m_floatingText, 2.0f);
    }
Ejemplo n.º 2
0
    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  = "!";


                // 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.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;
            }
        }
    }
Ejemplo n.º 3
0
    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 = "!";

                // 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.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;
            }
        }
    }