Git Product home page Git Product logo

mesheffectfortextmeshpro's Introduction

MeshEffectForTextMeshPro

NOTE: This project is experimental.

NOTE: This project will be integrated to UIEffect.

MeshEffectForTextMeshPro provide visual effect components for TextMeshPro in Unity.

PRs Welcome

<< Description | WebGL Demo | Download | Usage | Example of using | Development Note | Change log >>

What's new? See changelog

Do you want to receive notifications for new releases? Watch this repo





Description

Do you like TextMeshPro? I’m lovin’ it:)

As you know, TextMeshPro, the ultimate text solution, is one of the greatest assets in Unity.
It is more beautiful than the standard TextMesh and Text, it is highly functional and free.

One of the big mystery of TextMeshPro is that "typical mesh effects (vertex effects) for uGUI can not be used for TextMeshPro".
Since TextMeshPro does not call IMeshModifier interface, TextMeshPro ignores the typical mesh effects.
The mesh effects of TextMeshPro (eg VertexJitter, VertexColorCycler etc) are very unique in their implementation and can only be used for TextMeshPro...

I think that an easy way to implement a common mesh effect is necessary.

This project provides a base class for mesh effect.
It works well not only for standard Graphic components (Image, RawImage, Text, etc.) but also for TextMeshPro and TextMeshProUGUI.
Just change your mesh effect a few places, it will support TextMeshPro!

Let's decorate your TextMeshPro with effects!

Features

  • Works well not only for standard Graphic components (Image, RawImage, Text, etc.) but also for TextMeshPro and TextMeshProUGUI.
  • Support multiple fonts.
  • There is no useless allocation.
  • Good performance.
  • You can implement MeshEffect with VertexHelper or Mesh.
  • Easily make your mesh effect support TextMeshPro. See detail
  • If your project does not use TMPro, add "NOT_USE_TMPRO" symbol. Or uncomment the first line of BaseMeshEffect.cs.
//#define NOT_USE_TMPRO // If your project does not use TMPro, uncomment this line.





Demo

WebGL Demo





Usage

  1. Download MeshEffectForTextMeshPro.unitypackage from Releases.
  2. Import the package into your Unity project. Select Import Package > Custom Package from the Assets menu.
  3. Add any effect component to TextMeshPro from Add Component in inspector or Component > MeshEffectForTextMeshPro > ... menu.
  4. Adjust the parameters of the effect as you like, in inspector.
  5. If your project does not use TMPro, add "NOT_USE_TMPRO" symbol. Or uncomment the first line of BaseMeshEffect.cs.
//#define NOT_USE_TMPRO // If your project does not use TMPro, uncomment this line.
  1. Enjoy!
Requirement
  • Unity 5.5+ (including Unity 2019.x)
  • TextMeshPro v1.0.0+





Development Note

Make your mesh effect supports TextMeshPro

  1. Change the base class from BaseMeshEffect to Coffee.UIExtensions.BaseMeshEffect.
// Before
public class YourMeshEffect : BaseMeshEffect
or
public class YourMeshEffect : MonoBehavior, IMeshModifier

// After
public class YourMeshEffect : Coffee.UIExtensions.BaseMeshEffect
  1. If you are using specific methods, override it properly.
  • OnEnable, OnDisable, LateUpdate, OnDidApplyAnimationProperties, OnValidate, ModifyMesh.
  • Call base.xxx except ModifyMesh.
// Before
void OnEnable ()
{
    ...
}
void OnDisable ()
{
    ...
}
...
void ModifyMesh (VertexHelper vh)
{
    ...
}

// After
protected override void OnEnable ()
{
    base.OnEnable();
    ...
}
void OnDisable ()
{
    base.OnDisable();
    ...
}
...
public override void ModifyMesh (VertexHelper vh)
{
    //base.ModifyMesh(vh);  <- ModifyMesh's base method is unnecessary.
    ...
}
  1. Change graphic.SetVerticesDirty to SetVerticesDirty
// Before
public bool horizontal { get { return this.m_Horizontal; } set { this.m_Horizontal = value; graphic.SetVerticesDirty(); } }

// After
public bool horizontal { get { return this.m_Horizontal; } set { this.m_Horizontal = value; SetVerticesDirty(); } }
  1. If there are compile errors, remove them.





License

  • MIT
  • © UTJ/UCL

Author

mob-sakai

See Also

mesheffectfortextmeshpro's People

Contributors

mob-sakai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mesheffectfortextmeshpro's Issues

MeshEffect doesn't work with Layout system

I am using this library for the Outline 8 shadow effect on a TextMesh Pro Text object. The resulting shadow is sharper and looks better on pixel fonts than the default TextMesh Pro outline.

But I'm finding that it doesn't work well with the Unity layout system.
If TextMesh Pro text objects are part of a layout or have a ContentSizeFitter on them, At certain times, especially if you call:
LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
You get an error like this:

Mesh.vertices is too small. The supplied vertex array has less vertices than are referenced by the triangles array. UnityEngine.Mesh:set_vertices(Vector3[]) TMPro.TextMeshPro:GenerateTextMesh() (at Library/PackageCache/[email protected]/Scripts/Runtime/TMPro_Private.cs:3796) TMPro.TextMeshPro:CalculateLayoutInputVertical() (at Library/PackageCache/[email protected]/Scripts/Runtime/TextMeshPro.cs:534) UnityEngine.Canvas:SendWillRenderCanvases()

Any idea what might be causing this?

Thank you!

It simply doesn't do anything on textmeshpro

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Environment (please complete the following information):

  • Platform: [e.g. Editor(Windows/Mac), Standalone(Windows/Mac), iOS, Android, WebGL]
  • Unity: [e.g. 2018.2.8f1]
  • TMProEffect: [e.g. v1.0.0]

Additional context
Add any other context, screenshots or gif animations about the bug here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.