示例#1
0
    public UILabel mLabel;               //文本框

    /// <summary>
    /// 设置数据并显示
    /// </summary>
    /// <param name="data">聊天数据</param>
    /// <param name="pos">坐标,世界坐标</param>
    /// <param name="call">回调</param>
    public void SetData(SendReceiveGameChat data, Vector3 pos, eChatTextDirectionType dType)
    {
        //设置位置
        transform.position = pos;
        gameObject.SetActive(true);
        eGameChatContentType _type = (eGameChatContentType)data.chatType;

        if (_type == eGameChatContentType.Chat)//普通文字
        {
            mLabel.text = data.content;
        }
        else if (_type == eGameChatContentType.TexTVoice)//文字语音
        {
            List <ConfigDada> conList = ConfigManager.GetConfigs <TSTGameTxtChatConfig>();
            ConfigDada        conData = conList.Find(o => o.conIndex == data.faceIndex.ToString());
            if (conData == null)
            {
                return;
            }
            TSTGameTxtChatConfig con = conData as TSTGameTxtChatConfig;
            mLabel.text = con.name;

            string voice = data.sex == 1 ? con.soundNameman : con.soundNamewoman;
            SoundProcess.PlaySound("ChatSound/" + voice);
        }
        mBg.width = 20 + mLabel.width;//设置背景长度
        DelayRun(2, () =>
        {
            gameObject.SetActive(false);
        });
    }
示例#2
0
    /// <summary>
    /// 获取聊天位置
    /// </summary>
    /// <param name="chattype">聊天类型</param>
    /// <returns></returns>
    public Vector3 GetChatPos(eGameChatContentType chattype)
    {
        switch (chattype)
        {
        case eGameChatContentType.HDFace:
            return(mHudongRoot.position);

        case eGameChatContentType.TexTVoice:
            return(mTextRoot.position);

        case eGameChatContentType.Voice:
            return(mVoiceRoot.position);
        }
        return(transform.position);
    }
示例#3
0
    /// <summary>
    /// 文字聊天,文字语音,语音,表情
    /// </summary>
    /// <param name="pos">位置,世界坐标</param>
    /// <param name="_type">类型</param>
    /// <param name="data">数据</param>
    public void AddOneChat(Vector3 pos, eChatTextDirectionType _type, SendReceiveGameChat data)
    {
        eGameChatContentType chatType = (eGameChatContentType)data.chatType;

        switch (chatType)
        {
        case eGameChatContentType.Chat:      //文字
        case eGameChatContentType.TexTVoice: //文字语音
            AddOneText(pos, _type, data);
            break;

        case eGameChatContentType.Face:    //表情
            AddOneFace(pos, _type, data);
            break;

        case eGameChatContentType.Voice:    //语音
            AddOneVoice(pos, _type, data);
            break;
        }
    }