Example #1
0
    public static MovableObject CreateMovableChar(int index, char letter, MovCharInfo cInfo)
    {
        string name = $"Character[{index}]";

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

        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 MovableObject movable))
        {
            movable.Setting(cInfo.waitFrame, cInfo.vibration, cInfo.rotation, cInfo.movableStyle);

            return(movable);
        }
        return(null);
    }
Example #2
0
    public void Setting(MovCharInfo movCInfo)
    {
        WaitFrame = movCInfo.waitFrame;

        Style = movCInfo.movableStyle;

        Rotation  = movCInfo.rotation;
        Vibration = movCInfo.vibration;

        if (gameObject.TryGetComponent(out Text text))
        {
            text.color = movCInfo.color;
            text.font  = movCInfo.font;

            text.fontStyle = movCInfo.fontStyle;
            text.fontSize  = movCInfo.fontSize;
        }
    }
Example #3
0
    private void Create()
    {
        MovableText unstableText = Movable.CreateMovableText(mName, mCanvas, mPosition);

        MovCharInfo unstCInfo
            = new MovCharInfo(mColor, mFontStyle, mFont, new MovableObject(mWaitFrame, mRotation, mVibration, mUnstable), mFontSize);

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

        for (int i = 0; i < mMessage.Length; i++)
        {
            MovableObject createChar = Movable.CreateMovableChar(i, mMessage[i], unstCInfo);

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