Exemple #1
0
        static void ConvertToTextFX()
        {
            GameObject        activeGO   = Selection.activeGameObject;
            TextMeshPro       tmpText    = activeGO.GetComponent <TextMeshPro> ();
            TextFxTextMeshPro textfxUGUI = activeGO.GetComponent <TextFxTextMeshPro> ();

            if (textfxUGUI != null)
            {
                return;
            }

            GameObject tempObject = new GameObject("temp");

            textfxUGUI = tempObject.AddComponent <TextFxTextMeshPro>();

            TextFxTextMeshPro.CopyComponent(tmpText, textfxUGUI);

            DestroyImmediate(tmpText);

            TextFxTextMeshPro newUGUIEffect = activeGO.AddComponent <TextFxTextMeshPro> ();

            TextFxTextMeshPro.CopyComponent(textfxUGUI, newUGUIEffect);

            DestroyImmediate(tempObject);

            // Forces the mesh to be redrawn, taking into account the material settings.
            newUGUIEffect.Reset();

            Debug.Log(activeGO.name + "'s TextMeshPro component converted into a TextFxTextMeshPro component");
        }
Exemple #2
0
        static public void CreateTextMeshProInstance(MenuCommand command)
        {
            GameObject go = new GameObject(NEW_INSTANCE_NAME_TMP);

            TextFxTextMeshPro textMeshPro = go.AddComponent <TextFxTextMeshPro>();

            textMeshPro.text      = "Sample text";
            textMeshPro.alignment = TextAlignmentOptions.TopLeft;
            textMeshPro.rectTransform.sizeDelta = new Vector2(20, 5);

            Undo.RegisterCreatedObjectUndo((Object)go, "Create " + go.name);

            GameObject contextObject = command != null ? command.context as GameObject : null;

            if (contextObject != null)
            {
                GameObjectUtility.SetParentAndAlign(go, contextObject);
                Undo.SetTransformParent(go.transform, contextObject.transform, "Parent " + go.name);
            }

            Selection.activeGameObject = go;
        }