Beispiel #1
0
    // 替换图文字
    private string SetEmoji(string text, FillEmoji fillEmoji)
    {
        string result      = "";
        bool   isChangeRow = false;
        int    spaceNum    = 0;
        int    rowNum      = 1;
        int    length      = text.Length;
        string faceName    = "";

        if (length <= 0)
        {
            return(result);
        }

        //每一行的sprite
        sprites = new List <GameObject>();
        // 每一行的起点文字索引,以及对应的换行量
        rowDict.Clear();
        rowList.Clear();

        // 当前插入换行符的位置
        rowListIndex = 0;
        picIndex     = SetRealRowList(text, -1);

        for (int i = 0; i < length; i++)
        {
            isChangeRow = false;

            // 判断是否是emoji
            int  lastIndex = i;
            bool isReplace = ReplaceEmojiText(ref text, ref i, ref rowNum, ref spaceNum, ref isChangeRow, ref faceName);
            if (isReplace)
            {
                // 图片换行
                if (isChangeRow)
                {
                    sprites.Clear();
                }
                // 绘制图片
                if (fillEmoji != null)
                {
                    fillEmoji(faceName);
                }
            }
            // 文字换行
            if (!isChangeRow)
            {
                if (i >= nextRow)
                {
                    SetChangeRow(ref rowNum, sprites);
                    rowListIndex++;
                    lastRow          = rowList[rowListIndex];
                    nextRow          = GetNextRowIndex();
                    rowDict[lastRow] = 0;
                }
            }

            length = text.Length;
        }
        result = text;

        return(result);
    }
Beispiel #2
0
	// 替换图文字
	private string SetEmoji(string text, FillEmoji fillEmoji) {
		string result = "";
		bool isChangeRow = false;
		int spaceNum = 0;
		int rowNum = 1;
		int length = text.Length;
		string faceName = "";
		if (length <= 0) return result;
		
		//每一行的sprite
		sprites = new List<GameObject>();
		// 每一行的起点文字索引,以及对应的换行量
		rowDict.Clear();
		rowList.Clear();

		// 当前插入换行符的位置
		rowListIndex = 0;
		picIndex = SetRealRowList(text, -1);

		for (int i = 0; i < length; i++) {
			isChangeRow = false;

			// 判断是否是emoji
			int lastIndex = i;
			bool isReplace = ReplaceEmojiText(ref text, ref i, ref rowNum, ref spaceNum, ref isChangeRow,ref faceName);
			if (isReplace) {
				// 图片换行
				if (isChangeRow) {
					sprites.Clear();
				}
				// 绘制图片
				if (fillEmoji != null) {
					fillEmoji(faceName);
				}
			}
			// 文字换行
			if (!isChangeRow) {
				if (i >= nextRow) {
					SetChangeRow(ref rowNum, sprites);
					rowListIndex++;
					lastRow = rowList[rowListIndex];
					nextRow = GetNextRowIndex();
					rowDict[lastRow] = 0;
				}
			}

			length = text.Length;
		}
		result = text;

		return result;
	}