Пример #1
0
    public void CreateLabel()
    {
        //GameObject mObj = LuaHelper.CreateInstance("Assets/GameModules/Chat/Prefabs/GameObject.prefab");
        //mObj.transform.parent = scrollViewRoot;// LuaHelper.GetActiveCanvasParent();
        //MixedLabel mixedLabel = mObj.GetComponent<MixedLabel>();

        MixedLabel mixedLabel = MixedLabelGlobal.CreateMixedLabel();

        System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
        sw.Start();

        mixedLabel.Init(
            displayStrings[currentDisplayStringIndex % displayStrings.Length],
            contentWidth,
            new TextSettings()
        {
            textColor = Color.black, hyperDefaultColor = Color.blue, hyperHoverColor = Color.red, hyperPressColor = Color.green
        },
            (x) => { Debug.LogFormat("Number {0} hyper link is clicked", x); },
            (x) => { Debug.LogFormat("Number {0} hyper link is clicked", x); });
        mixedLabel.transform.parent = scrollViewRoot;
        mixedLabel.GetComponent <RectTransform>().anchoredPosition = new Vector3(20, currentYPos, 0); //20 is the horizontal padding
        mMixedLabels.Add(mixedLabel);
        currentYPos -= mixedLabel.totalHeight + 20;                                                   //20 is vertical padding
        currentDisplayStringIndex++;

        scrollViewRoot.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, -currentYPos);
        sw.Stop();
        Debug.LogFormat("request time = {0}", sw.Elapsed.TotalMilliseconds);
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        MixedLabelGlobal.Init(
            Application.dataPath + "/../AssetBundles/StandaloneWindows/emoji",
            new ChatFactory(this));
        mMixedLabels = new List <MixedLabel>();

        scrollViewRoot.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0);
    }