Search Unity

Modular 3D Text - Complete ingame ui sytem

Discussion in 'Assets and Asset Store' started by FerdowsurAsif, Feb 4, 2020.

  1. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    138

    Can you help me more?

    Here is the code:


    //1

    using System.Collections;
    using UnityEngine;

    namespace MText
    {
    [CreateAssetMenu(menuName = "Modular 3d Text/Modules/My Physics")]
    public class MText_Module_MyPhysics : MText_Module
    {

    public VariableHolder[] variableHolders;

    public override IEnumerator ModuleRoutine(GameObject obj, VariableHolder[] variableHolders)
    {
    yield return new WaitForSeconds(variableHolders[0].floatValue);

    this.variableHolders = variableHolders;

    if (obj)
    {
    if (obj.GetComponent<MeshFilter>())
    {
    if (!obj.GetComponent<Rigidbody>())
    obj.AddComponent<Rigidbody>();


    if (!obj.GetComponent<BoxCollider>())
    obj.AddComponent<BoxCollider>();

    //if (variableHolders[7].physicMaterialValue) obj.GetComponent<BoxCollider>().material = variableHolders[7].physicMaterialValue;
    var c = obj.GetComponent<BoxCollider>();
    c.center = Vector3.zero; //this was a BUG here

    var rb = obj.GetComponent<Rigidbody>();
    rb.useGravity = variableHolders[1].boolValue;

    bool freezeXPosition = variableHolders[2].boolValue;
    bool freezeYPosition = variableHolders[3].boolValue;
    bool freezeZPosition = variableHolders[4].boolValue;
    bool freezeXRotation = variableHolders[5].boolValue;
    bool freezeYRotation = variableHolders[6].boolValue;
    bool freezeZRotation = variableHolders[7].boolValue;

    if (freezeXPosition) rb.constraints |= RigidbodyConstraints.FreezePositionX;
    if (freezeYPosition) rb.constraints |= RigidbodyConstraints.FreezePositionY;
    if (freezeZPosition) rb.constraints |= RigidbodyConstraints.FreezePositionZ;

    if (freezeXRotation) rb.constraints |= RigidbodyConstraints.FreezeRotationX;
    if (freezeYRotation) rb.constraints |= RigidbodyConstraints.FreezeRotationY;
    if (freezeZRotation) rb.constraints |= RigidbodyConstraints.FreezeRotationZ;

    var mText_Module_MyPhysics_OnCollision = obj.GetComponent<MText_Module_MyPhysics_OnCollision>();
    if (mText_Module_MyPhysics_OnCollision == null) {
    mText_Module_MyPhysics_OnCollision = obj.AddComponent<MText_Module_MyPhysics_OnCollision>();
    }

    mText_Module_MyPhysics_OnCollision.Set(this, obj);
    }
    }
    }

    public override string VariableWarnings(VariableHolder[] variableHolders)
    {
    return null;
    }
    }

    public class MText_Module_MyPhysics_OnCollision : MonoBehaviour {

    private MText_Module_MyPhysics _module;
    private GameObject _go;

    public void Set(MText_Module_MyPhysics module, GameObject go) {
    _module = module;
    _go = go;
    }

    private void OnCollisionEnter(Collision other) {
    if (other.gameObject.CompareTag("Player")) {
    Debug.Log("OnCollisionEnter " + other.gameObject);
    _module.variableHolders[1].boolValue = true;
    StartCoroutine(_module.ModuleRoutine(_go, _module.variableHolders));
    }
    }
    }
    }




    //2
    using System.Collections;
    using UnityEngine;
    using MText;

    namespace _MyScripts.UI
    {
    public class ApplyCustomPhisycsModuleOnText3D : MonoBehaviour
    {
    public Modular3DText modular3DText = null;
    public Transform textHolder = null;
    public MText_Module module = null;

    private void Start() {
    StartCoroutine(ApplyModules());
    }

    public void ResetTransform()
    {
    textHolder.localPosition = Vector3.zero;
    textHolder.localRotation = Quaternion.identity;

    var rb = textHolder.gameObject.GetComponent<Rigidbody>();
    if (rb)
    {
    rb.velocity = Vector3.zero;
    rb.angularVelocity = Vector3.zero;
    }
    }

    IEnumerator ApplyModules()
    {
    if (gameObject.activeInHierarchy)
    {
    yield return null;

    if (module)
    StartCoroutine(module.ModuleRoutine(textHolder.gameObject, modular3DText.addingModules[0].variableHolders));
    }
    }
    }
    }

    +1: I found a BUG, when collider center not was 0,0,0 I can't see the collider at all. It was something like 1300, 20, 2121

    So the above code not working at all. When I press in the editor the in modules to "useGravity true" it is working, but the same from code not working. Can you help me why?
     
  2. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    138
    +1 help: When I set from code only the collider falling, but the Mesh not :)
     
  3. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Hi,
    Can you show how your modified Add Physics module looks in the inspector.
    upload_2022-9-8_14-33-18.png
     
  4. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    138

    upload_2022-9-8_10-37-17.png
     
  5. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    138
    upload_2022-9-8_10-38-1.png
     
  6. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    138
    By the way the modified "My" icon is not the same as your default ones.
     
  7. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Hi,
    Please enclose you code in Code tag for easier readability.
    upload_2022-9-8_15-44-57.png

    Don't declare variableHolders here.
    Code (CSharp):
    1. public class MText_Module_MyPhysics : MText_Module
    2. {
    3.  
    4. public VariableHolder[] variableHolders; //remove this
    Note related to the problem but I suggest renaming the file before modifying to make sure updates don't overwrite your changes.
     

    Attached Files:

  8. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Hi,
    If you are having issues with writing here in code tag to format it, can you send me the files to asifno13@gmail.com.
    Sorry, I have a hard time reading like this.
     
  9. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    138
    Ok now it is working, but found more BUGS.

    When I make a PREFAB from the word, then there is some issue, and not working at all, only the collider falling down, after.

    When I unpack the prefab completely, the same is the issue.

    When I unpack and on advanced settings call "re-apply modules" than, TADAMM, working...
     
  10. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Hi,
    Neither of the things being described are bugs. I am not claiming in any sense the asset is bug free, i work alone, i often miss stuff. I just pushed another bugfix today.
    But modifying a script and that not working isn't really the assets bug. I just wanted to clarify. Apologies if that sounded aggressive.

    Is the characters in your prefab already created?

    Adding modules by default only apply to the the new characters being added runtime.

    The other two instances where it would apply to is,
    earlier made characters is if the characters were single mesh before and runtime they're recreated.
    Or, the reapply module setting.
     
  11. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    138

    Sorry man, this is a good package, keep up the hard work!
     
    FerdowsurAsif likes this.
  12. Dragon-Magic-Studio

    Dragon-Magic-Studio

    Joined:
    Jun 30, 2015
    Posts:
    12
    About the new input system its not documented how it supposed to be implemented.
    Also there is no similar support for the 3D menu like the unity gui has, it lack regular input like gamepad for example as it seems to have only raycast.
    Would be nice to clear this part up as the new unity input system is pretty much a standard nowadays.
    Also some demo scenes form previous versions been removed,the ones that all kind of menu designs.
     
  13. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Thank you for very much the feedback. It helps me know on which side I should prioritize. I will start working on a tutorial for the input system asap.

    Raycast input works by default.
    There is a button that will set up the input system according to whether you have the new input system or the default one on your UI element. It isn't turned on by default since key controls aren't always needed.
    upload_2022-9-8_20-9-47.png

    It works using the Player Input component.
    upload_2022-9-8_20-13-42.png

    You can modify the Input Action Asset to fit your need.
    It should support gameplay inputs as I copied Unity's built-in one.
    I have had it tested for controllers by one person but didn't test it myself. Please let me know if that isn't working as intended.
    upload_2022-9-8_20-18-5.png



    I don't think I removed demo scenes. I will take a look again just to be sure. Scene number 7 is the one with menu designs.
    upload_2022-9-8_20-22-9.png

    I hope this was helpful. Feel free to contact me again if you have any further queries. Always happy to help
     
  14. Dragon-Magic-Studio

    Dragon-Magic-Studio

    Joined:
    Jun 30, 2015
    Posts:
    12
    Thanks, yes sample 7 seems to be the one i was looking for, send you still an email as i got an error when i try to create my own font.
    Was reworking the menu which was form an older version, the button text was corrupt so i tried to recreate the text meshes however it gives an error that i posted in the mail to you.

    Its nice that it works with player input, however I am not using the playerinput form unity but wrote my own, so thats gonna take a while to figure out. ;)
     
  15. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    I have replied to the mail. Please do a fresh reinstall with the latest version (I just pushed today).

    Ah, yes, I do understand the pain of PlayerInput, I felt it too with my project. I have asked around for an alternative from other publishers. But couldn't find anything better. I had this solution ready for a while but didn't want to implement it.

    Let me know if you got any suggestions on how an asset should better support the new input system. Been updating the asset since February 2020 and not planning on stopping anytime soon.
     
  16. Dragon-Magic-Studio

    Dragon-Magic-Studio

    Joined:
    Jun 30, 2015
    Posts:
    12
    I was more thinking about a menu manager where you could also just drag your input asset and select your mapping like player input.
    But instead of controlling a player controlling the menu by adding a list of buttons and do callbacks on buttons based on their event click hover and unselected as in general there are only 3 states buttons be in, the playerinput lacks callbacks to each button or maybe im wrong about this ?
    Just an idea. ;)

    Update, after upgrading to 3.0.2 the bug been fixed.
    besides that i might have found something that is useful in the demo 7 it has the script called "MText_InputSystemController" , it might just be the one i was looking for.
     
    Last edited: Sep 9, 2022
    FerdowsurAsif likes this.
  17. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Thanks for the suggestion. I will try to add something that makes it easier to swap input action assets.

    I think these are the callbacks you are looking for.
    upload_2022-9-9_11-31-56.png

    Yes, the inputSystemController is needed for the asset to work. It should automatically be added if you click the UpdateInputSystem button. I will look into if for some reason that isn't being added.
     
  18. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    I couldn't think of anything else except input action asset swapper for the menu manager atm. Added it to my TODO list.
    So, I am making a default values editor with the optional ability to apply the settings to everything in the scene.

    upload_2022-9-9_12-10-31.png
     
  19. Dragon-Magic-Studio

    Dragon-Magic-Studio

    Joined:
    Jun 30, 2015
    Posts:
    12
    Looks great, I would suggest to make the change between old unity input system and the new input system not in one script but rather split up as it makes scripts much longer and i do think most ppl nowadays will use the new input system anyways.
    So in my opinion the old input system should become more legacy and not the main focus.
    Im not really using unity events and drop and drag windows as I prefer to use just C# events/actions instead.
    So my input system has just a c# class that i will refer to when needed.
    Not a huge fan of drag and drop in the inspector as it kinda easy to make mistakes and hard to trace back compared to code.
    Now there are just a lots of #IF statements for the new input system which i would like to remove in my projects jsut to keep the codebase cleaner.
    Looking forward what you come up with in future, i got some quick hack written too hook into the List script, that seems to be working out for now.
     
    FerdowsurAsif likes this.
  20. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Thanks for the suggestions.
    I don't have any data to back it up but from the contact I have with customers, a lot of people seem to be using the legacy input system. I think it's due to YouTube tutorials introducing unity with the legacy one since they were created earlier.

    I eventually plan on splitting up the code for the input systems . + that would make it easier to handle updates.
    I want users to be able to easily add and remove what they need in the asset.
    Similar to being able to completely remove the Folder outside the Plugin Folder.
     
  21. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Version 3.1.0
    • Default settings window
    • List, Button code variable renaming for better consistency among the codebase according to a suggestion by a user.
    • Included material names have been appended with "MText_" according to suggestions.
    • Bugfix: The default input action asset is now correctly assigned.
     
  22. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    I am curious to see what games/products people are using my asset for.
    If anyone is comfortable in sharing, I would love to see your work.

    Please post them here or email me at asifno13@gmail.com
     
  23. Undume

    Undume

    Joined:
    Jun 2, 2016
    Posts:
    14
    Is it the word spacing working in v3?
    Btw, niiice asset, I am implementing korean, japanese and chinese with your asset and works perfectly.
     
  24. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Ah, my bad. It isn't working.
    Found the fix. Pushing it now. upload_2022-9-12_23-27-26.png
    Shouldn't take more than 15min.
    Edit: It's live.

    Thanks! Glad to hear that. Let me know if I can help with anything.
     
    Last edited: Sep 12, 2022
  25. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Version 3.1.2
    • Bugfix: Wordspacing on text working again.
     
  26. Undume

    Undume

    Joined:
    Jun 2, 2016
    Posts:
    14
    Wow thanks!
     
    FerdowsurAsif likes this.
  27. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    My pleasure
     
  28. shyamarama

    shyamarama

    Joined:
    Dec 13, 2019
    Posts:
    12
    Hi,
    My project is using both input systems right now, and the new update is giving me the following compile error:

    Assets/Plugins/Tiny Giant Studio/Modular 3D Text/Scripts/Input/MText_InputSystemController.cs(54,21): error CS0246: The type or namespace name 'StandardInput' could not be found (are you missing a using directive or an assembly reference?)

    It does work when new input system only is applied in the project settings. Is there a way to use the asset with both input systems?

    Thanks Screen Shot 2022-09-13 at 11.59.52 AM.png
     
  29. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Sorry about the bug.
    Found the issue. Fixed it.
    Pushing it. Hopefully will be live on the asset store within 15ish min.
     
    shyamarama likes this.
  30. shyamarama

    shyamarama

    Joined:
    Dec 13, 2019
    Posts:
    12
    Awesome, thanks!
     
    FerdowsurAsif likes this.
  31. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    My pleasure!
     
    shyamarama likes this.
  32. Faizalski

    Faizalski

    Joined:
    Oct 4, 2018
    Posts:
    27
    @Ferdowsur
    Does this asset support WebGL build? I tried to build it and got the following error
    Code (CSharp):
    1. Assets\Plugins\Tiny Giant Studio\Modular 3D Text\Scripts\MText_GetCharacterObject.cs(5,13): error CS0234: The type or namespace name 'FontCreation' does not exist in the namespace 'MText' (are you missing an assembly reference?)
    I can build for regular PC build successfully.

    Thank you
     
  33. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Hi,
    Sorry about the error.Pushing the fix.
    Should be live within 15 ish min. My upload speed is super slow even just for 80MB.

    Edit: The fix is live.
     
    Last edited: Sep 14, 2022
  34. Faizalski

    Faizalski

    Joined:
    Oct 4, 2018
    Posts:
    27
    You rocks :) Thank you sir.
     
    FerdowsurAsif likes this.
  35. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Happy to help!
    Don't hesitate to contact me again if you need anything.
     
  36. Faizalski

    Faizalski

    Joined:
    Oct 4, 2018
    Posts:
    27
    @Ferdowsur
    Looks like the new build had eradicated the namespace error but now it started to show some other error message :(
    The following are the new ones:

    Code (CSharp):
    1. An asset is marked with HideFlags.DontSave but is included in the build:
    2. Asset: 'Assets/Plugins/Tiny Giant Studio/Modular 3D Text/Resources/Modular 3D Text/M3D Font.png'
    3. Asset name: M3D Font
    4. (You are probably referencing internal Unity data in your build.)
    5. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    6.  
    7. An asset is marked with HideFlags.DontSave but is included in the build:
    8. Asset: 'Assets/Plugins/Tiny Giant Studio/Modular 3D Text/Resources/Modular 3D Text/M3D.png'
    9. Asset name: M3D
    10. (You are probably referencing internal Unity data in your build.)
    11. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    12.  
    13. Assertion failed on expression: 'm_LockCount == 0'
    14. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    15.  
    16.  
    17.  
     
  37. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    For now, you can delete these two files and build. They are used just as icons on scriptable objects.

    I am not sure why they are causing build errors. It's not causing any errors for me. I think it's probably import settings. I am looking into it.
     
  38. Faizalski

    Faizalski

    Joined:
    Oct 4, 2018
    Posts:
    27
    I changed the texture type for both image from "Editor GUI and LEgacy GUI" into "Sprite (2D and UI)". ANd it build without any issues :)
     
    FerdowsurAsif likes this.
  39. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Many thanks!
    I will mark them the same and push a new update.
     
  40. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    Hello,
    I just imported 3.1.7 and most of the materials are pink.
    What do I need to do to correct this?
    Thank you.

    I thought I would leave this here.
    I went through the URP upgrade materials menu option.
    Most of the colors in the scenes are white now but in the project window / materials the materials show correctly.
    Do you have any suggestions?
     
    Last edited: Oct 3, 2022
  41. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Hi,
    Sorry for the problem. I am currently working on a solution to automatically import a separate sample scene package with the correct values if URP is detected,

    It sounds like the light intensity is too high for URP. I think I set it to 2.5 for all the sample scenes.
    Please lower the Directional light intensity.
    If you don't see the directional light in the scene hierarchy,

    upload_2022-10-3_13-57-34.png and click mark visible
    upload_2022-10-3_13-57-47.png

    or

    Update the asset to the latest version.
     
    Last edited: Oct 3, 2022
  42. sunsi12138

    sunsi12138

    Joined:
    Apr 14, 2020
    Posts:
    23
    Hello, I fell into a problem that it seems that the 3d ui dont work in mobile, the code in
    MText_UI_RaycastSelector:
    if (Mouse.current.leftButton.wasPressedThisFrame) only supports mouse on pc,
    I recommend use input callback rather than do ui interact check in update
     
  43. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Sorry for the problem. Looks like a big oversight. I have a bandaid fix ready. If you want it, please send me an email at asifno13@gmail .

    I am working on splitting the Raycast selector into two scripts. One will handle the logic and the other will just take input. This will make it easier to modify for future work and for users to make their own with the least amount of work.
    The input callback will coexist with the much slower update check on the separate script as an alternative.
    Hopefully, I can push an update with this within 6/7 days.
     
  44. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Version 3.1.8
    • Bugfix: Touch with the new input system fixed for raycast selector script.
     
  45. trustpivot

    trustpivot

    Joined:
    Sep 29, 2017
    Posts:
    18
    Hey Ferdowsur, this is a great product! I'm having fun with everything and it is serving me well.

    I am pretty novice at Unity and I wanted to run this by you: I am wanting to label world items with the modular 3d text and just combine meshes (using mesh combiner assets) into the object that is labeled. I don't really need the text to change, but it helps me speedily get what I want done by doing it this way. There could be better ways I guess but so far this works great. You see any potential performance issues by me doing that, for say, a few thousand modular 3D text objects in a given scene?

    Also, I read through the manual, settings, and this forum but did not see any way to disable the editor gizmos - any suggestions on how to do that? Since I have a ton of labels I have to disable the gameobjects to see what I'm doing in the scene view!
     
  46. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Hi,
    Glad to hear that!

    There shouldn't be any special issues with rendering 3d texts. They will work the same as any other meshes.

    If you don't need to change the text, you can even remove the asset's script components from the game object. Just keep the mesh renderer and mesh filter. Then your combiner asset can handle it.


    On the scene, you can select Gizmos, then tick/untick to enable/disable the gizmos.
    upload_2022-12-24_10-22-50.png


    I hope this answered all your questions. Feel free to ask more. ALWAYS happy to help!
     
    trustpivot likes this.
  47. trustpivot

    trustpivot

    Joined:
    Sep 29, 2017
    Posts:
    18
    Very helpful, thanks a lot!
     
    FerdowsurAsif likes this.
  48. KCFindstr

    KCFindstr

    Joined:
    Dec 2, 2019
    Posts:
    3
    Thanks for making this great asset! I'm wondering if there's a way to control the number of triangles / vertices used by the 3D texts?
     
  49. FerdowsurAsif

    FerdowsurAsif

    Joined:
    Feb 7, 2017
    Posts:
    287
    Hi,
    Thank you for the compliment.

    Unfortunately, there is no way to control the triangles count that it comes up with. It tries to create with a low amount of vertices at first and gradually the number goes up with the complexity of each character.

    A time-consuming way exists to optimize it though. Export the characters to a 3D Model editor like Blender, optimize it, then import it back into Unity. You can replace the old file or manually assign the new character models by selecting the Font file.
     
  50. midwinter86

    midwinter86

    Joined:
    Mar 29, 2022
    Posts:
    4
    I seem to be having issues with the assembly references. I've followed the docs but I'm getting this error:
    The type or namespace name 'LayoutElement' could not be found (are you missing a using directive or an assembly reference?)

    This is coming from this file Assets\Plugins\Tiny Giant Studio\Modular 3D Text\Scripts\MText_GetCharacterObject.cs

    I'm a bit of a dotnet noob so I'm sure its something that I'm doing wrong with the references