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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[RELEASED] String-O-Matic - Say goodbye to magic strings

Discussion in 'Assets and Asset Store' started by Cobo3, Jan 1, 2016.

  1. Cobo3

    Cobo3

    Joined:
    Jun 16, 2013
    Posts:
    65
    Unity's policy for implementing magic strings in almost all of its systems is one the major sources of bugs and headaches, especially for amateurs. Using constant values instead of relying on magic strings heavily reduces the amount of runtime errors.

    String-O-Matic scans your project based on your needs to automatically generate constants and static classes holding references to all of those magic strings, effectively replacing soft runtime errors by robust compile errors.

    Convert error-prone code
    SOM Not Used.png
    into safe, robust code
    SOM Used.png

    Key Features:
    • Replace Unity magic strings for static classes and constants.
    • Changing magic strings in the Editor will produce compile errors that would otherwise cause undesired beahviour.
    • Comes with many built-in modules, each one addressing a different system.
    • Easily configurable based on each project needs.
    • Easy to use: you just have to click a button.
    • Easy to extend: you can create your own modules, satisfying your own project needs.
    • Fully documented =)
    • And last but not least, full source code included.
    Modules:
    • Tags
    • Layers
    • Sorting Layers
    • Input axes
    • Navigation Areas
    • Scenes --> Lists every scene name and path added to the build.
    • Audio --> Lists every mixer controller and, for each one, their exposed parameters and snaphots.
    • Mecanim--> Lists every animator's parameters, layers, states and sub state machines, recursively.
    • Resources--> Lists every object under your resources folder/s and subfolders.
    • Shaders--> Lists the shader name and it's properties for every built-in and custom shader
    Preferences.png
    Version 1.1:
    • Added SOMValueAttribute to reference String-O-Matic values from the inspector.
    • Added Sorting Layers, Navigation and Shaders modules to the free version.
    • Bug fixes.
    SOMValueAttribute.png
    Please, feel free to post any questions below or email me at antoniocogo@gmail.com: I'll be very glad to help. And, of course, I'm freely open to suggestions.

     
    Last edited: Feb 21, 2016
    one_one likes this.
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    The links are broken ....
     
  3. Cobo3

    Cobo3

    Joined:
    Jun 16, 2013
    Posts:
    65
    Hey @liortal, I have had some problems uploading it for review, but the asset is now live and completely working =)
     
    Last edited: Jan 22, 2016
  4. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    we can get acces on inspector ?
     
  5. Cobo3

    Cobo3

    Joined:
    Jun 16, 2013
    Posts:
    65
    Do you mean like having a field in some script that takes a value from String-O-Matic (the same way you do with tags)?
    Well, I don't have anything like that, but that would be a really interesting feature to add. I'll work on that and I'll let you know of my progress =)
     
  6. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    Yes it's can give powerfull mecanim workflow
     
  7. Cobo3

    Cobo3

    Joined:
    Jun 16, 2013
    Posts:
    65
    Check this out!

    Update 1.1
    • Added SOMValueAttribute to reference String-O-Matic values from the inspector.

      You just have to decorate some string with SOMValueAttribute like this: upload_2016-1-22_10-3-10.png

      And you are ready to inspect it:
      upload_2016-1-22_10-5-5.png
      This efficiently adds a layer of abstraction to the system, and eases the debugging of things like mecanim.
      Thanks @kilik128 for the awesome suggestion =D

    • The Resources Module now adds a constant holding the path to each folder. Now Resources.LoadAll can be used in conjunction with String-O-Matic ^^
    • Some more minor bug fixes.

    The package is pending review. I will post again when it gets accepted.
     
  8. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    year Awesome ! thanks you too be open to suggestion =D
    can't wait for try
     
  9. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    little confuse on first use

    using SOM;

    give

    Assets/FlightScript.cs(4,7): error CS0246: The type or namespace name `SOM' could not be found. Are you missing a using directive or an assembly reference?


    and refrest give me :
    SOM.SOMManager.RefreshMenu () (at Assets/StringOMatic/Editor/SOMManager.cs:174)SOM.SOMManager.RefreshAll (Boolean forceUpdate) (at Assets/StringOMatic/Editor/SOMManager.cs:57)SOM.SOMManager.Refresh (Int32 index, Boolean save) (at Assets/StringOMatic/Editor/SOMManager.cs:81)SOM.SOMShadersModule.Refresh () (at Assets/StringOMatic/Editor/Modules/SOMShadersModule.cs:357)SOM.SOMShadersModule.AddShader (System.String name, System.String parent, Boolean isBuiltIn) (at Assets/StringOMatic/Editor/Modules/SOMShadersModule.cs:413)SOM.SOMXmlHandler.AddConstant (System.String path, System.String name, System.String value) (at Assets/StringOMatic/Editor/SOMXmlHandler.cs:161)ConstantAlreadyExistsException: The module at path 'Shaders.Shader Forge.Lerpbyhauteur' already has the constant 'name'


    don't found any exemple script




    Edit after Import in new projet

    i have make Animator.controler add some parameter and state when SOM.refresh the animator is cleared layers is now empty and no more parameter i don't know if it's bug or what

    but it's working is when projet is save before make refresh
     
    Last edited: Feb 1, 2016
  10. Cobo3

    Cobo3

    Joined:
    Jun 16, 2013
    Posts:
    65
    @kilik128 the SOM namespace is only available (and needed) when extending String-O-Matic functionality. Otherwise, you just have to access the class StringOMatic directly, which is in the global namespace.

    As for the ShaderForge problem, that is quite an unusual error. Maybe it's because of how Shader Forge works. I could try to fix it if I had some more information or the files.

    And I don't really understand the problem about layers and Animator controller. Maybe a more detailed explanation would help.

    Also, make sure to update to the latest version on the Asset Store.
     
  11. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    Hi there,
    I just downloaded and imported String-O-Matic free to check it out.
    Once it was installed and I attempt to refresh I get the following Error:
    Screen Shot 2016-02-16 at 9.25.20 PM.png
    Here are the specs on my Machine:
    Screen Shot 2016-02-16 at 9.26.29 PM.png
    Im running Unity 5.3.0f4

    Thanks,
    John
     
  12. Cobo3

    Cobo3

    Joined:
    Jun 16, 2013
    Posts:
    65
    Hey @JohnRossitter,

    Wow, that was a very serious bug on my part that was only present in the free version of SOM.
    The new, fixed version is pending review.

    Thanks for pointing that out
     
    JohnRossitter likes this.
  13. Oriam

    Oriam

    Joined:
    Nov 11, 2012
    Posts:
    23
    Hi @Cobo3 ,

    What platforms are you supporting? I'm guessing that the magic happens in editor only (when the StringOMatic.cs is generated), and it can be used in any platform, but I am not sure (I still haven't read the documentation).

    Thanks in advance.
     
  14. Cobo3

    Cobo3

    Joined:
    Jun 16, 2013
    Posts:
    65
    That's exactly it, @Oriam. StringOMatic.cs is generated with just the click of a button and then you are ready to use it in any platform you want
     
  15. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
  16. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    new question for exemple
    if i got resources A of folder B selected in inspector
    in code i want select resources B of folder B how i writh this ?
    thnak's
     
  17. Larzarus

    Larzarus

    Joined:
    Jun 4, 2016
    Posts:
    27
    Looks like SOM (free) has XML reader/writer issues with Unity 2018.3.9f1 and needs some update love. ;)