Example #1
0
    public void AddMessageToPhone(bool isComment)
    {
        ShowNotification();

        GameObject bar = null;

        if (isComment)
        {
            bar = (GameObject)Instantiate(CommentBarPrefab, Vector3.zero, Quaternion.identity);
        }
        else
        {
            bar = (GameObject)Instantiate(MessageBarPrefab, Vector3.zero, Quaternion.identity);
        }


        bar.transform.SetParent(MessageContainer.transform);

        bar.transform.localEulerAngles = Vector3.zero;
        bar.transform.localScale       = Vector3.one;

        RectTransform     rect = bar.GetComponent <RectTransform>();
        MessageProperties prop = bar.GetComponent <MessageProperties>();

        rect.localPosition = new Vector3(0, -24.4f, 0);

        if (isComment)
        {
            hasComment = true;

            if (AllComments.Count > 0)
            {
                prop.SetText(AllComments[commentIndex].MyMessage, AllComments[commentIndex].myHeight, null);
            }
        }
        else
        {
            if (AllScriptables.Count > 0)
            {
                prop.SetText(AllScriptables[messageIndex].MyMessage, AllScriptables[messageIndex].myHeight, AllScriptables[messageIndex].Profile);
            }
        }

        if (AllMessages.Count > 0)
        {
            foreach (MessageProperties message in AllMessages)
            {
                message.gameObject.GetComponent <RectTransform>().localPosition = new Vector3(0, message.gameObject.GetComponent <RectTransform>().localPosition.y + bar.GetComponent <MessageProperties>().MessageHeight, 0);
            }
        }

        AllMessages.Add(prop);

        phoneIndex++;

        if (!isComment)
        {
            messageIndex++;
            hasComment = false;
        }
        else
        {
            commentIndex++;
        }
    }