internal void DrawWindowContent(int windowID)
        {
            MovableText     movableTextInfo = movableTexts[FindMovableTextIndex(windowID)];
            ParagraphLayout layout          = ParagraphLayout.Create(movableTextInfo);

            if (!string.IsNullOrEmpty(movableTextInfo.title))
            {
                GUIStyle titleStyle = new GUIStyle();
                titleStyle.normal.textColor = Color.white;
                GUI.Label(layout.titleRect, new GUIContent(movableTextInfo.title), titleStyle);
            }

            float verticalPosition = kWindowMargin + 18;

            for (int line = 0; line < movableTextInfo.lines.Count; ++line)
            {
                (string text, Color color) = movableTextInfo.lines[line];

                GUIStyle style = new GUIStyle();
                style.normal.textColor = color;
                style.border.left      = 0;
                GUI.Label(new Rect(new Vector2(kWindowMargin, verticalPosition), layout.lineSizes[line]), text, style);

                verticalPosition += layout.lineSizes[line].y;
            }

            GUI.DragWindow(new Rect(0, 0, Screen.width, Screen.height));
        }
Ejemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUILayout.Space(8f);

        if (!EditorApplication.isPlaying &&
            GUILayout.Button("Apply to changed", GUILayout.Height(25f)))
        {
            MovableText movableText = target as MovableText;

            int       messageLength = movableText.Message.Length;
            Transform movTransform  = movableText.transform;

            #region Summary

            /*=================================================================================
             * If amount of unstableChar is more than messageLength, removal unstableChar at the last.
             * 만약 불안정문자의 수가 메시지의 길이보다 많다면, 제일 뒤에있는 불안정문자를 제거한다.
             *=================================================================================*/
            #endregion
            while (messageLength < movTransform.childCount)
            {
                Undo.DestroyObjectImmediate(movTransform.GetChild(movTransform.childCount - 1).gameObject);
            }
            #region Summary

            /*=================================================================================
             * Rearrange unstableChar based on length of changed message and change the each unstableChar by changed message.
             * 변경된 메시지에따라 불안정문자를 재배치하고, 각 불안정문자들이 나타내는 글자를 변경한다.
             *=================================================================================*/
            #endregion
            for (int i = 0; i < messageLength; i++)
            {
                if (i >= movTransform.childCount)
                {
                    Movable.CreateMovableChar(i, movableText.Message[i], movableText.GetTextInfo)
                    .transform.parent = movTransform;
                }

                Undo.RecordObject(movTransform.GetChild(i), movableText.Message);

                if (movableText.transform.GetChild(i).TryGetComponent(out MovableObject movable))
                {
                    movable.Setting(movableText.GetTextInfo);
                }
                movTransform.GetChild(i).SetLetterSpace(messageLength, movableText.LetterSpace, i);

                if (movTransform.GetChild(i).TryGetComponent(out Text text))
                {
                    Undo.RecordObject(text, "Apply to changed text");

                    text.text = movableText.Message[i].ToString();
                }
            }
        }
    }
        internal void DrawTextWindow(int windowIdentifier)
        {
            MovableText movableText = movableTexts[windowIdentifier];

            if (movableText.lines.Count == 0)
            {
                return;
            }

            ParagraphLayout layout = ParagraphLayout.Create(movableText);

            GUI.color = Color.white;

            movableText.rect = GUI.Window(movableText.identifier, layout.rect, DrawWindowContent, new GUIContent());
            movableTexts[windowIdentifier] = movableText;
        }
Ejemplo n.º 4
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);
        }
    }
Ejemplo n.º 5
0
    private void OnGUI()
    {
        GUILayout.Space(8f);
        mUnstable = (MovableText)EditorGUILayout.ObjectField("Edit Target", mUnstable, typeof(MovableText), true);
        GUILayout.Space(2f);

        if (GUILayout.Button("Extraction"))
        {
            if (mUnstable != null)
            {
                mMessage = mUnstable.Message;

                mLetterSpace = mUnstable.LetterSpace;
            }
            else
            {
                Debug.Log("You should be selection to edit target!");
            }
        }
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.Label("Print-out Option", EditorStyles.boldLabel);
        GUILayout.Space(2.5f);

        GUILayout.Label("Message", EditorStyles.label);
        mMessage = EditorGUI.TextField(new Rect(2.5f, 102f, EditorGUIUtility.currentViewWidth - 7f, 18f), mMessage);
        GUILayout.Space(21f);

        GUILayout.Label("Letter Space", EditorStyles.label);
        mLetterSpace = EditorGUILayout.FloatField(mLetterSpace);

        GUILayout.Label("Interval", EditorStyles.label);
        mInterval = EditorGUILayout.FloatField(mInterval);

        mIsPrinOnebyOne = EditorGUILayout.Toggle("Print-OnebyOne", mIsPrinOnebyOne);

        GUILayout.Space(3f);

        if (GUILayout.Button("Apply") && mUnstable != null)
        {
            Undo.RecordObject(mUnstable, "Apply");

            mUnstable.Setting(mMessage, mLetterSpace);
        }
    }
        public static ParagraphLayout Create(MovableText movableText)
        {
            string[] lines = movableText.lines.Select(line => line.Item1).ToArray();

            Rect rect = movableText.rect;

            rect.size = Vector2.zero;
            Rect           titleRect = Rect.zero;
            List <Vector2> lineSizes = new List <Vector2>();

            if (!string.IsNullOrEmpty(movableText.title))
            {
                titleRect.size = GUI.skin.label.CalcSize(new GUIContent(movableText.title));
                rect.width     = titleRect.width;
            }

            foreach (string line in lines)
            {
                var textSize = GUI.skin.label.CalcSize(new GUIContent(line));
                lineSizes.Add(textSize);

                rect.width  = math.max(rect.width, textSize.x);
                rect.height = rect.height + textSize.y;
            }

            rect.xMax = rect.xMax + 2.0f * TextDrawerBehavior.kWindowMargin;
            rect.yMax = rect.yMax + 2.0f * TextDrawerBehavior.kWindowMargin + TextDrawerBehavior.Skin.window.border.top;

            titleRect.x = (rect.width - titleRect.width) * 0.5f;
            titleRect.y = TextDrawerBehavior.kTitleVerticalMargin;

            return(new ParagraphLayout()
            {
                rect = rect,
                titleRect = titleRect,
                lineSizes = lineSizes.ToArray()
            });
        }
Ejemplo n.º 7
0
 public Command(MovableBitmap buttonBitmap, string key)
 {
     _buttonBitmap = buttonBitmap;
     _key          = key;
     _buttonText   = new MovableText(key, TEXT_SIZE);
 }