Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Modular 3D Text - Complete ingame ui sytem

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

  1. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    39

    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:
    39
    +1 help: When I set from code only the collider falling, but the Mesh not :)
     
  3. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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:
    39

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

    lacas8282

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

    lacas8282

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

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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:
    39
    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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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:
    39

    Sorry man, this is a good package, keep up the hard work!
     
    Ferdowsur 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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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
    Ferdowsur likes this.
  17. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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.
     
    Ferdowsur likes this.
  20. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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. Ferdowsur

    Ferdowsur

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

    Undume

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

    Ferdowsur

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

    shyamarama

    Joined:
    Dec 13, 2019
    Posts:
    9
    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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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:
    9
    Awesome, thanks!
     
    Ferdowsur likes this.
  31. Ferdowsur

    Ferdowsur

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

    Faizalski

    Joined:
    Oct 4, 2018
    Posts:
    25
    @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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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:
    25
    You rocks :) Thank you sir.
     
    Ferdowsur likes this.
  35. Ferdowsur

    Ferdowsur

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

    Faizalski

    Joined:
    Oct 4, 2018
    Posts:
    25
    @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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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:
    25
    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 :)
     
    Ferdowsur likes this.
  39. Ferdowsur

    Ferdowsur

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

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    368
    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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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. Ferdowsur

    Ferdowsur

    Joined:
    Feb 7, 2017
    Posts:
    175
    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. Ferdowsur

    Ferdowsur

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