public void Event(string text, STMTextInfo info)
    {
        split = text.Split(',');
        //if exactly two strings and first is the rt tag...
        if (split.Length == 2 && split[0] == "rt")
        {
            //create a new STM, and assign the remaining text to it
            tempStm = new GameObject().AddComponent <SuperTextMesh>();
            tempStm.t.SetParent(this.transform);             //parent it to this
            tempStm.t.name = split[1];
            //center above letter
            tmpPos.x = info.Middle.x;
            tmpPos.y = info.pos.y + info.size + verticalOffset;
            tempStm.t.localPosition = tmpPos;

            tempStm.size  = rubyTextSize;
            tempStm.font  = stm.font;
            tempStm.color = stm.color;

            tempStm.anchor    = TextAnchor.LowerCenter;
            tempStm.alignment = SuperTextMesh.Alignment.Center;      //center above letter
            tempStm.autoWrap  = info.RelativeWidth;                  //max width is letter width
            tempStm.bestFit   = SuperTextMesh.BestFitMode.OverLimit; //shrink to fit if it goes over

            tempStm.text = split[1];

            rubyText.Add(tempStm);             //add to list
        }
    }
예제 #2
0
    //public string seperator = "=";
    //public string audioTag = "a";
    public void DoEvent(string s, STMTextInfo info)      //the string from the event, index of the letter in the string, world position of this letter, position of bottom-left corner
    //To get specific parts of a letter, if this script is on the same gameObject as the text mesh. (for position)
    //Vector3 myPos = info.pos + transform.position;
    //Vector3 centerPos = info.Middle + transform.position;
    //Vector2 letterSize = new Vector2(info.TopRightVert.x - info.pos.x, info.TopRightVert.y - info.pos.y);
    {
        Vector3 pos    = info.Middle + transform.position;
        Vector3 rawPos = info.BottomLeftVert + transform.position;

        /*
         * string myTag = audioTag + seperator;
         * if(myTag.Length <= s.Length && s.Substring(0,myTag.Length) == myTag){ //first two characters are "a="?
         *      string playString = "mySound";
         *      if(myTag.Length + playString.Length <= s.Length && s.Substring(audioTag.Length + seperator.Length, playString.Length) == playString){
         *              Debug.Log("Playing sound!");
         *      }else{
         *              Debug.Log("Unknown audio event!");
         *      }
         */
        if (s == "printpos")
        {
            Debug.Log(rawPos);                                                     //print the position of this letter.
            Debug.DrawLine(rawPos, rawPos + Vector3.down, Color.red, 5.0f, false); //draw a line from the corner of this letter, down
        }
        else if (s == "link")
        {
            Vector3       cornerPos = info.pos + transform.position + new Vector3((info.TopRightVert.x - info.pos.x) / 2f, info.size / 2f, 0f); //align to row
            STMSampleLink newLink   = Instantiate(link, cornerPos, link.transform.rotation) as STMSampleLink;                                   //create line position
            newLink.linkName             = "Custom Link Address!";                                                                              //change the string
            newLink.transform.localScale = new Vector3(info.size, info.size, 0.5f);                                                             //just make it square
            allLinks.Add(newLink);                                                                                                              //remember, so it can be destroyed
        }
        else if (s.Length >= 2 && s.Substring(0, 2) == "bg")
        {
            Vector3        cornerPos = info.pos + transform.position + new Vector3((info.TopRightVert.x - info.pos.x) / 2f, info.size / 2f, 0.2f); //align to row
            SpriteRenderer newBG     = Instantiate(bgPrefab, cornerPos, bgPrefab.transform.rotation) as SpriteRenderer;                            //create line position
            newBG.color = Color.red;                                                                                                               //change the color
            newBG.transform.localScale = new Vector3(info.size, info.size, 0.5f);                                                                  //just make it square
            allBGs.Add(newBG);                                                                                                                     //remember, so it can be destroyed
        }
        else if (s == "confetti")
        {
            Instantiate(confetti, pos, confetti.transform.rotation);           //spawn a prefab at the letter's location
        }
        else if (s == "playSound")
        {
            Debug.Log("Playing sound!");
            au.PlayOneShot(myClip, 1f);            //alt way of playing clips, for example
        }
        else
        {
            Debug.Log("Unknown event: '" + s + "'");
        }
    }
예제 #3
0
 void Update()
 {
     if (stm != null &&                                   //if there's a defined text mesh...
         stm.info.Count > 0 &&                            //and it has textinfo to follow...
         stm.latestNumber > -1 &&                         //and it's either drawing or done drawing...
         stm.hyphenedText[stm.latestNumber] != '\n')      //ignore line breaks
     {
         STMTextInfo myInfo = stm.info[stm.latestNumber]; //all info for this one character...
         //put the caret in the right place!
         transform.localPosition = myInfo.pos + myInfo.Advance(stm.characterSpacing, stm.quality) + offset;
     }
 }
예제 #4
0
    public STMTextInfo(STMTextInfo clone)
    {
        this.ch        = clone.ch;
        this.pos       = clone.pos;
        this.offset    = clone.offset;
        this.line      = clone.line;
        this.rawIndex  = clone.rawIndex;
        this.indent    = clone.indent;
        this.ev        = new List <string>(clone.ev);
        this.ev2       = new List <string>(clone.ev2);
        this.colorData = clone.colorData;
        //this.colorData = ScriptableObject.CreateInstance<STMColorData>();
//		this.colorData.color = clone.colorData.color;
        this.gradientData = clone.gradientData;
        this.textureData  = clone.textureData;
        this.size         = clone.size;
        //this.delayData = ScriptableObject.CreateInstance<STMDelayData>();
//		this.delayData.count = clone.delayData.count;
        this.delayData  = clone.delayData;
        this.waveData   = clone.waveData;
        this.jitterData = clone.jitterData;
        this.alignment  = clone.alignment;

        this.readTime     = clone.readTime;
        this.unreadTime   = clone.unreadTime;
        this.drawAnimData = clone.drawAnimData;

        //this.clipsFolderName = clone.clipsFolderName;
        this.audioClipData     = clone.audioClipData;
        this.stopPreviousSound = clone.stopPreviousSound;
        this.pitchMode         = clone.pitchMode;
        this.overridePitch     = clone.overridePitch;
        this.minPitch          = clone.minPitch;
        this.maxPitch          = clone.maxPitch;
        this.speedReadPitch    = clone.speedReadPitch;
        this.readDelay         = clone.readDelay;
        this.drawOrder         = clone.drawOrder;

        //this.submeshNumber = clone.submeshNumber;
        this.fontData      = clone.fontData;
        this.quadData      = clone.quadData;
        this.isQuad        = clone.isQuad;
        this.materialData  = clone.materialData;
        this.soundClipData = clone.soundClipData;

        this.quadIndex = clone.quadIndex;
    }
예제 #5
0
 public STMTextInfo(STMTextInfo clone, CharacterInfo ch) : this(clone){ //clone everything but character. used for auto hyphens
     this.ch       = ch;
     this.quadData = null;                                              //yeah or else it gets weird. it's gonna be a hyphen/space so whatever!!
 }
예제 #6
0
    public void SetValues(STMTextInfo clone)
    {
        this.ch       = clone.ch;
        this.pos      = clone.pos;
        this.offset.x = clone.offset.x;
        this.offset.y = clone.offset.y;
        this.offset.z = clone.offset.z;
        this.line     = clone.line;
        this.rawIndex = clone.rawIndex;
        this.indent   = clone.indent;

        if (clone.ev.Count > 0)        //this check saves a TON of time... but im sure there's an even better way? can it just be set directly...?
        {
            this.ev = new List <string>(clone.ev);
        }
        if (clone.ev2.Count > 0)
        {
            this.ev2 = new List <string>(clone.ev2);
        }

        //yeah... does this cause errors? events are just strings so i dont see why... hm
        //this.ev = clone.ev;
        //this.ev2 = clone.ev2;


        this.colorData = clone.colorData;
        //this.colorData = ScriptableObject.CreateInstance<STMColorData>();
//		this.colorData.color = clone.colorData.color;
        this.gradientData = clone.gradientData;
        this.textureData  = clone.textureData;
        this.size         = clone.size;
        //this.delayData = ScriptableObject.CreateInstance<STMDelayData>();
//		this.delayData.count = clone.delayData.count;
        this.delayData  = clone.delayData;
        this.waveData   = clone.waveData;
        this.jitterData = clone.jitterData;
        this.alignment  = clone.alignment;

        this.readTime     = clone.readTime;
        this.unreadTime   = clone.unreadTime;
        this.drawAnimData = clone.drawAnimData;

        //this.clipsFolderName = clone.clipsFolderName;
        this.audioClipData     = clone.audioClipData;
        this.stopPreviousSound = clone.stopPreviousSound;
        this.pitchMode         = clone.pitchMode;
        this.overridePitch     = clone.overridePitch;
        this.minPitch          = clone.minPitch;
        this.maxPitch          = clone.maxPitch;
        this.speedReadPitch    = clone.speedReadPitch;
        this.readDelay         = clone.readDelay;
        this.drawOrder         = clone.drawOrder;

        //this.submeshNumber = clone.submeshNumber;
        this.fontData      = clone.fontData;
        this.quadData      = clone.quadData;
        this.isQuad        = clone.isQuad;
        this.materialData  = clone.materialData;
        this.soundClipData = clone.soundClipData;

        this.quadIndex = clone.quadIndex;

        this.submeshChange = clone.submeshChange;
        this.invoked       = false;
    }
예제 #7
0
 public STMTextInfo(STMTextInfo clone)
 {
     SetValues(clone);
 }