コード例 #1
0
    public static UnstableObject RegisterCharObject(int index, char letter, UnstCInfo cInfo)
    {
        string name = $"Character[{index}]";

        GameObject newObject = new GameObject(name, typeof(RectTransform), typeof(Text), typeof(UnstableObject));

        Undo.RegisterCreatedObjectUndo(newObject, name);

        if (newObject.TryGetComponent(out Text text))
        {
            text.fontSize  = cInfo.fontSize;
            text.fontStyle = cInfo.fontStyle;

            text.color     = cInfo.color;
            text.alignment = TextAnchor.MiddleCenter;

            text.text = letter.ToString();
            text.font = cInfo.font;
        }
        if (newObject.TryGetComponent(out UnstableObject unstable))
        {
            unstable.Setting(cInfo.waitFrame, cInfo.vibration, cInfo.rotation, cInfo.unstableStyle);

            return(unstable);
        }
        return(null);
    }
コード例 #2
0
    private void Create()
    {
        UnstableText unstableText = Unst.RegisterTextObject(mName, mCanvas, mPosition);

        UnstCInfo unstCInfo
            = new UnstCInfo(mColor, mFontStyle, mFont, new UnstableObject(mWaitFrame, mRotation, mVibration, mUnstable), mFontSize);

        unstableText.Setting(mMessage, mLetterSpacing, 0f);
        unstableText.Setting(unstCInfo);

        for (int i = 0; i < mMessage.Length; i++)
        {
            UnstableObject createChar = Unst.RegisterCharObject(i, mMessage[i], unstCInfo);

            createChar.transform.parent = unstableText.transform;
            createChar.transform.SetLetterSpace(mMessage.Length, mLetterSpacing, i);
        }
    }