コード例 #1
0
    internal void CreateFloatingText(string text, Color color, Transform position)
    {
        GameObject   txtOverlay   = GameObject.Instantiate(FloatingText, transform) as GameObject;
        FloatingText floatingText = txtOverlay.GetComponent <FloatingText>();

        floatingText.Initialize(color, text, position);
    }
コード例 #2
0
    public static void MakeFloatingText(string text, Vector2 location)
    {
        GameObject loadedText = Resources.Load("UI/Floating Text") as GameObject;

        GameObject activeText = Instantiate(loadedText, location, Quaternion.identity) as GameObject;

        FloatingText textScript = activeText.GetComponent <FloatingText>();

        textScript.Initialize(text, location);
    }
コード例 #3
0
ファイル: UIManager.cs プロジェクト: alexzpopov/PacMan-Unity
    private void OnFloatingTextCreator(object sender, MessageArgs args)
    {
        FloatingText go = Instantiate(textPref, args.Position, Quaternion.identity) as FloatingText;

        go.transform.SetParent(_canvasTrans);
        go.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
        go.Initialize(floatingTextSpeed, new Vector3(0, 1, 0), 3);
        go.GetComponent <Text>().text  = args.Msg;
        go.GetComponent <Text>().color = args.MsgColor;
    }
コード例 #4
0
    public static void MakeFloatingText(string text, Vector2 location)
    {
        GameObject loadedText = Resources.Load("UI/Floating Text") as GameObject;

        if (loadedText == null)
        {
            Debug.Log("Couldn't find floating test asset");
            return;
        }

        GameObject activeText = GameObject.Instantiate(loadedText, location, Quaternion.identity) as GameObject;

        FloatingText textScript = activeText.GetComponent <FloatingText>();

        textScript.Initialize(text, location);
    }
コード例 #5
0
    /************************************************************************************************/
    public FloatingText CreateFloatingText(string textValue, Transform t, int prefabIndex, int animIndex)
    {
        // Check parameter validity
        if (prefabIndex >= floatingTextPrefabs.Length)
        {
            prefabIndex = 0;
        }
        if (animIndex >= animations.Length)
        {
            animIndex = 0;
        }

        // Spawn new instance from pool. By default, it will be a parent of the controller gameobject.
        FloatingText instance = SimplePool.Spawn(floatingTextPrefabs[prefabIndex], Vector3.zero, Quaternion.identity).GetComponent <FloatingText>();

        instance.transform.SetParent(transform);

        instance.Initialize(t, textValue, animIndex);

        return(instance);
    }