예제 #1
0
    //Generate New 3D Text
    public void GenerateText()
    {
        //Debug.Log ("GenerateText Called");

        ResetText();         //reset before generating new text

        //check all letters
        for (int ctr = 0; ctr <= Text.Length - 1; ctr++)
        {
            //Debug.Log ("Text Length" + Text.Length);
            //Debug.Log ("ctr"+ctr);

            //dealing with linebreaks "\n"
            if (Text[ctr].ToString().ToCharArray()[0] == "\n"[0])
            {
                //Debug.Log ("\\n detected");
                CharXLocation  = 0;
                CharYLocation -= LineSpacing;
                continue;
            }

            string childObjectName = Text[ctr].ToString();


            if (childObjectName != " ")
            {
                GameObject LetterToShow;

                if (childObjectName == "/")
                {
                    LetterToShow = transform.Find("_Alphabets/" + "slash").gameObject;                   //special case for "/" since it cannot be used for obj name in fbx
                }
                else if (childObjectName == ".")
                {
                    LetterToShow = transform.Find("_Alphabets/" + "period").gameObject;                   //special case for "." - naming issue
                }
                else
                {
                    LetterToShow = transform.Find("_Alphabets/" + childObjectName).gameObject;
                }

                //Debug.Log(LetterToShow);

                AddLetter(LetterToShow);

                //find the width of the letter used
                Mesh   mesh   = LetterToShow.GetComponent <MeshFilter>().sharedMesh;
                Bounds bounds = mesh.bounds;
                CharXLocation += bounds.size.x;
                //Debug.Log (bounds.size.x*ObjScale.x);
            }
            else
            {
                CharXLocation += SpaceWidth;
            }
        }

#if !UNITY_3_4 && !UNITY_3_5
        //disable child objects inside _Alphabets
        transform.Find("_Alphabets").gameObject.SetActive(false);
#else
        //disable child objects inside _Alphabets
        transform.Find("_Alphabets").gameObject.SetActiveRecursively(false);
#endif
    }
예제 #2
0
    public void GenerateText()
    {
        // Clear the text first
        ResetText();

        // Check input field for non-empty string
        if (InputController.Text.Length > 0)
        {
            this.Text = InputController.Text;
        }

        // check all letters
        for (int ctr = 0; ctr <= Text.Length - 1; ctr++)
        {
            // dealing with linebreaks "\n"
            if (Text[ctr].ToString().ToCharArray()[0] == "\n"[0])
            {
                charXLocation  = 0;
                charYLocation -= LineSpacing;
                continue;
            }

            string childObjectName = Text[ctr].ToString();


            if (childObjectName != " ")
            {
                GameObject LetterToShow;

                if (childObjectName == "/")
                {
                    LetterToShow = transform.Find("_Alphabets/" + "slash").gameObject; //special case for "/" since it cannot be used for obj name in fbx
                }
                else if (childObjectName == ".")
                {
                    LetterToShow = transform.Find("_Alphabets/" + "period").gameObject; //special case for "." - naming issue
                }
                else
                {
                    LetterToShow = transform.Find("_Alphabets/" + childObjectName).gameObject;
                }

                AddLetter(LetterToShow);

                // find the width of the letter used
                Mesh   mesh   = LetterToShow.GetComponent <MeshFilter>().sharedMesh;
                Bounds bounds = mesh.bounds;
                charXLocation += (bounds.size.x);
                // handle edge case
                if (childObjectName == "I" || childObjectName == "i" || childObjectName == "l")
                {
                    charXLocation += 5f;
                }
            }
            else
            {
                charXLocation += SpaceWidth;
            }
        }

        // Calculates bounds
        SetMaxCharPos();
    }