summaryrefslogtreecommitdiff
path: root/WorldlineKeepers/Assets/ThirdParty/StringUtil/DoubleVString.cs
blob: 5d9c6e80874d3f8655d637bbf26d72a27ea530e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


/// <summary>
/// 给UI.Text使用的double buffer string
/// </summary>
public class DoubleVString
{   
    private int index;
    private VString stringA;
    private VString stringB;

    public DoubleVString(int maxCount)
    {
        stringA = new VString(maxCount);
        stringB = new VString(maxCount);
    }
    
    public VString GetCurrentVString()
    {
        return (index % 2) == 0 ? stringA : stringB;
    }
    
    public VString GetNextVString()
    {
        return (index % 2) == 0 ? stringB : stringA;
    }


    //交换current 和Next string对象
    public void SwapVString()
    {
        index = (index + 1) % 2;
    }
}