Example #1
0
    void AddLog(string text)
    {
        AfficheLogConsole instance = Instantiate(LogSample.gameObject, ContentViewport).GetComponent <AfficheLogConsole>();

        instance.gameObject.SetActive(true);
        instance.SetLog(text);
        RectTransform InstanceTransform = instance.GetComponent <RectTransform>();

        InstanceTransform.anchoredPosition = new Vector2(10, -InstanceTransform.sizeDelta.y / 2 + lastPosition);
        ContentViewport.sizeDelta          = new Vector2(ContentViewport.sizeDelta.x, -lastPosition + InstanceTransform.sizeDelta.y);
        lastPosition -= InstanceTransform.sizeDelta.y;
        LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent <RectTransform>());
    }
Example #2
0
    void SetLogSpecific(string Key, string TextValue)
    {
        if (specificLogc.ContainsKey(Key))
        {
            specificLogc[Key].SetLog(TextValue);
            specificLogc[Key].TitreLog.text += " Specific log \"" + Key + "\"";
            specificLogc[Key].TitreLog.color = Color.green;
        }
        else
        {
            AfficheLogConsole instance = Instantiate(LogSample.gameObject, ContentViewport).GetComponent <AfficheLogConsole>();
            instance.gameObject.SetActive(true);
            instance.SetLog(TextValue);

            instance.TitreLog.text += " Specific log \"" + Key + "\"";
            instance.TitreLog.color = Color.green;
            RectTransform InstanceTransform = instance.GetComponent <RectTransform>();
            InstanceTransform.anchoredPosition = new Vector2(10, -InstanceTransform.sizeDelta.y / 2 + lastPosition);
            ContentViewport.sizeDelta          = new Vector2(ContentViewport.sizeDelta.x, -lastPosition + InstanceTransform.sizeDelta.y);
            lastPosition -= InstanceTransform.sizeDelta.y;
            LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent <RectTransform>());
            specificLogc.Add(Key, instance);
        }
    }