コード例 #1
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUILayout.Space(8f);

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

            int       messageLength = unstableText.Message.Length;
            Transform unstTransform = unstableText.transform;

            #region Summary

            /*=================================================================================
             * If amount of unstableChar is more than messageLength, removal unstableChar at the last.
             * 만약 불안정문자의 수가 메시지의 길이보다 많다면, 제일 뒤에있는 불안정문자를 제거한다.
             *=================================================================================*/
            #endregion
            while (messageLength < unstTransform.childCount)
            {
                Undo.DestroyObjectImmediate(unstTransform.GetChild(unstTransform.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 >= unstTransform.childCount)
                {
                    Unst.RegisterCharObject(i, unstableText.Message[i], unstableText.GetTextInfo)
                    .transform.parent = unstTransform;
                }
                Undo.RecordObject(unstTransform.GetChild(i), unstableText.Message);

                unstTransform.GetChild(i).SetLetterSpace(messageLength, unstableText.LetterSpace, i);

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

                    text.text = unstableText.Message[i].ToString();
                }
            }
        }
    }
コード例 #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);
        }
    }
コード例 #3
0
    private void OnGUI()
    {
        GUILayout.Space(8f);
        mUnstable = (UnstableText)EditorGUILayout.ObjectField("Edit Target", mUnstable, typeof(UnstableText), true);
        GUILayout.Space(2f);

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

                mLetterSpace = mUnstable.LetterSpace;
                mInterval    = mUnstable.Interval;

                mFadeInfo = mUnstable.GetFadeInfo;

                mIsPrinOnebyOne = mUnstable.IsPrintOnebyOne;
            }
            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);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.Label("Fading Option", EditorStyles.boldLabel);
        GUILayout.Space(2.5f);

        GUILayout.Label("Fade Type", EditorStyles.label);
        mFadeInfo.FadeType = (FadeType)EditorGUILayout.EnumPopup(mFadeInfo.FadeType);

        GUILayout.Label("Fade Time", EditorStyles.label);
        mFadeInfo.FadeTime = EditorGUILayout.FloatField(mFadeInfo.FadeTime);

        mFadeInfo.IsUsingTimeScale =
            EditorGUILayout.Toggle("Is Using Time Scale", mFadeInfo.IsUsingTimeScale);

        mFadeInfo.IsFadedDisable =
            EditorGUILayout.Toggle("Is Faded Disable", mFadeInfo.IsFadedDisable);

        GUILayout.Space(3f);

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

            mUnstable.Setting(mMessage, mLetterSpace, mInterval);

            mUnstable.Setting(mFadeInfo);

            mUnstable.IsPrintOnebyOne = mIsPrinOnebyOne;
        }
    }