Search Unity

[Released] Wire Builder - easy to use wire creation

Discussion in 'Assets and Asset Store' started by StaggartCreations, Sep 12, 2019.

  1. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262



    An editor tool to create suspended electricity or telephone wires. Built around an intuitive "click & drag" scene-view editor.

    Connectors can be added to GameObjects (eg. utility poles) to form a group. In turn, wires can be connected between connectors.

    Features:
    • Preset-based wire type settings
    • Per-wire adjustable sagging
    • Adjustable wire resolution per meter
    • LineRenderer or MeshRenderer wire generation
    • Animated wire shader (Standard/URP)
    • Compatible with 2D view
    Vegetation Studio tree and object removal underneath wires

    Notes:
    • Wires have a centered pivot so will work with World Streamer or other grid systems
    • Tag and Layer can be set for generated wires
    • Includes Amplify Shader Editor and URP Shader Graph functions for the shader animation effect.

    Limitations:
    • Wires have no collision or physics interaction
    • No editing cannot be done at runtime, this is an editor-only tool

     
    Last edited: Nov 2, 2019
    Mark_01 and one_one like this.
  2. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    That's pretty cool! Is runtime support planned at some point?
     
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    Thanks! I don't have any intention to add this, as the scope is limited to an editor tool ;)
     
  4. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Aw, that's too bad. Is it making extensive use of some unity editor API then?
     
  5. igor250697

    igor250697

    Joined:
    Oct 5, 2018
    Posts:
    3
    Hi, why I can’t buy your product in Asset Store? Found 404
     
  6. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    Thank you for your interest, but its still pending review. This typically takes 4 weeks, so puts it somewhere halfway October ;)
     
  7. igor250697

    igor250697

    Joined:
    Oct 5, 2018
    Posts:
    3
    and for what price will you sell?
     
  8. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    This is also noted in the first post ;) It is currently set at $15.
     
    Mark_01 likes this.
  9. igor250697

    igor250697

    Joined:
    Oct 5, 2018
    Posts:
    3
    Is it possible with this tool to draw wires in real time directly in the game. Or just on stage unity
     
  10. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    The editor side calls on several functions in the static WireManager class, which is a non-editor class. This was done so a runtime API could still be possible, the group, connector and wire components are MonoBehaviours in any event.

    I've added code comments to all the static functions. Which allow you to create/update/destroy group, connectors and wire objects. This includes generating a wire between two connectors. So runtime wire creation should be possible using this.

    All the functionality as seen in the GIFS, for the dragging interaction is still editor-only, simply because it's written for the scene view. Anyone looking to have such interaction in-game would have to recreate this ;)
     
    Mark_01 likes this.
  11. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
  12. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    wow result look amazing
     
  13. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    350
    Hallo, is it possible somehow to have more options regarding the sagging? Trying to drag the lines up and down in the editor is somehow very limited, because as soon as the cursor hits the border I can't make the sagging more extreme anymore.
     
  14. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    Thanks for the feedback, the controls for the sagging is something I couldn't get quite right, so the reach is limited.

    What I can do is exposed the "sagging amount" parameter on the Wire component. This way it can be set there, with whatever value desired. I've just submitted an update which includes this, should be available within a few days.
     
    Last edited: Nov 2, 2019
    ratking likes this.
  15. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    350
    Thank you!

    I'd have some more feedback if you don't mind:
    - Pressing Ctrl+Z after changing the sagging amount via the gizmo doesn't change it back.
    - It should be possible to "clean up" a connector if the user (i.e. me) accidentally deleted a wire via the delete key. I had some really hard to track bugs because apparently there wasn't any hint anywhere that told me that the connector had faulty (missing) wires.
    - Is there some documentation on how to create wires at runtime via code? Is this possible at all? Would be great for procedurally created levels.

    Kind regards,
    ratking
     
  16. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    1. This is true, when an Undo is performed, the value is restored, but the wire isn't (immediately) regenerated afterwards. There is apparently a way to detect this, so I can probably make this work.
    2. Whenever the wire editor is fired up, all the components are validated and missing references are removed. I assume if you're deleting a wire object outside of the editor, this is desired behavior.
    3. The WireManager class has several functions for creating and managing wires. As side from function comments, this is undocumented and unadvertised because run time generation hasn't been tested. But the editor calls on many of these functions as well.
     
  17. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    350
    Thanks for the reply. I didn't know that I had to fire up the wire editor again to remove the missing references, good to know. And I will have a deeper look at the WireManager class.

    Another thing I noticed is that my wires had a very noticeable break in the middle (mostly noticeable in motion, when having a bit of a stronger wind). In order to fix this I changed the generation of the gradient keys in the method NewWindData() in WireGenerator.cs to this:

    Code (CSharp):
    1.             GradientColorKey[] colorKeys = new GradientColorKey[2];
    2.             colorKeys[0] = new GradientColorKey(color, 0f);
    3.             colorKeys[1] = new GradientColorKey(color, 1f);
    4.             GradientAlphaKey[] alphaKeys = new GradientAlphaKey[8];
    5.             for (int i = 0; i < 8; ++i) {
    6.                 var time = i / (float)(8 - 1);
    7.                 alphaKeys[i] = new GradientAlphaKey(Mathf.Sin(time * Mathf.PI), time);
    8.             }
    9.  
    10.             g.SetKeys(colorKeys, alphaKeys);
    This way the linear interpolation isn't so striking anymore, maybe you want to adopt this. (It's still kinda visible though, maybe an AnimationCurve would be a better idea anyway.)
     
  18. osss

    osss

    Joined:
    Jan 20, 2014
    Posts:
    27
    HDRP is actually compatible, just recreate the HDRP shadergraph and connect nodes by refer URP shadergraph.
     
  19. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    Thanks! This actually does look a little better, when viewed from above the curvature is a bit smoother.

    Submitted v.1.0.2

    Changed:
    - Wire sagging is now restored when Undo is performed
    - Slight improvement to wind animation (takes effect upon modifying a wire type preset)

    Fixed:
    - GUI not positioning correctly on some devices, causing GUI elements to appear off-screen (possibly DPI related)
     
  20. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    Working a wire strip feature, which can be configured per wire type. I personally need this to create bunting, but it could also be used for 2D jungle vines.



    Support for a custom mesh (lightbulbs?), rather than a quad seems possible, but I'll try this further down the line. Still need to figure how align the bottom of the mesh to the wire as well (edit: fixed!). Wind also needs to match the wire, I'm aiming to add some noise towards the bottom of the strip, so the individual flags appear to move as well.

    Note: The strip mesh will be combined with the wire mesh, so will share the same material. I'll expose a UV tile/offset parameter for the wire and strip mesh, so a texture atlas can be used. Using two materials is too costly in the long run, as this would net 2 draw calls per wire.
     
    Last edited: Dec 23, 2019
  21. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634


    Hi, does this need two points to work, or can you have hanging rope, wires etc?

    Which is useful for say a busted bridge, with ropes hanging or say the telephone pole with broken hanging wires. Is this possible with such tool out of the box that is.?
     
  22. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    Yes, a wire must always have a start and end point. I've dabbled with the idea to detach a wire, and have it dangle, but this has implications for a lot of functionality. Something I'll look into in the future :)
     
    recon0303 likes this.
  23. GlitchInTheMatrix

    GlitchInTheMatrix

    Joined:
    Apr 12, 2010
    Posts:
    285
    Hi, I love that update! great work!
    Is able already in the package? Thank
     
  24. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    Not yet, I honestly forgot about haha. I had some troubles with applying gravity to the meshes, so things like lanterns attached to a wire would appear to hang. Meanwhile I've learned a few new tricks, so I'll have to revisit it at some point ;)
     
  25. GlitchInTheMatrix

    GlitchInTheMatrix

    Joined:
    Apr 12, 2010
    Posts:
    285
    Sounds like something very cool to have in this system! Hope you can make time to integrate in the actual system, is so easy to use and work so well that can't wait to see what is coming :)
     
  26. TimeWalk-org

    TimeWalk-org

    Joined:
    Nov 3, 2014
    Posts:
    38
    Any trick to getting the "Edit Wires" button to appear? I installed the package in 2 different Unity Windows 2020.1.b10 projects. In one, the Edit Wires button appears (when I click on a WB prefab with the scripts attached). In the other, it never appears. Anything I should check? I know that it's untested with 2020, but it does work perfectly in one project and not the other. I have pressed CTRL, of course, but nothing happens. I see no errors in the console, and the package does seem to be correctly installed (e.g. the menu Component/Wire Network works fine).
     
    Last edited: Jun 7, 2020
  27. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    Strange, the button is prompted whenever any of the WireBuilder components are visible in the inspector. In the project, where it doesn't appear, do you have more than one scene-view tab open? Or both the scene- and game view by any chance? Are these projects on the same computer, or two different ones?
     
  28. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Line rendering is better for performance?
     
  29. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    In some respect yes, it will generally use fewer triangles, since the mesh is basically a camera-oriented strip, rather than a tube. The only downside is that lighting isn't as pretty, and LineRenderers cannot be combined into a single mesh using external tools like Mesh Combine Studio, etc.
     
  30. Harjawalda

    Harjawalda

    Joined:
    Sep 1, 2018
    Posts:
    15
    Is there a way to create a continuous cable with multiple pivot points? I keep getting disjoints and hand editing the pivot points per mm is agonizing, inefficient and inaccurate.
     
  31. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    There's no such functionality, since wires are always created between two individual connectors.
     
  32. Ochoytnik

    Ochoytnik

    Joined:
    May 10, 2015
    Posts:
    1
    I just bought this ten minutes ago I was having trouble getting the edit wires button to appear and it was honestly pretty annoying. In the Scene view Unity puts a component editor tools panel in the bottom right hand corner of the scene view. The button to edit the wire is behind this! To get to it I had to toggle the little crossed tools icon (hide or show the component editor tools panel) on the scene view off.

    I am still using unity 2020.1.1f1 so it's possible things have changed. I hope this helps someone!
     
  33. RaoulWB

    RaoulWB

    Joined:
    Feb 9, 2014
    Posts:
    14
    Hello! I'm considering to buy this asset, is this feature still planned?
     
  34. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    Can't say that it is, to be frank. I was never able to work through some hurdles regarding flawless mesh generation.
     
  35. RaoulWB

    RaoulWB

    Joined:
    Feb 9, 2014
    Posts:
    14
    That does sound a bit complex to get right. Rather, something similar like placing X amount of prefabs along a wire?
     
  36. Julinoleum

    Julinoleum

    Joined:
    Aug 31, 2011
    Posts:
    40
    Hello, when the Pole mesh has a collision and you try to duplicate the group, the gameObject has problem to stay on the ground. Is there anything I can do for that other than not using the duplicate feature? I can also deactivate the collider when Im in a placement phase but it's not what I'd expect
     
    Last edited: Oct 13, 2021
  37. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    192
    @StaggartCreations hey, is this asset still supported? I'm looking to add it to my project which is Unity 2022.2 beta. Whilst there is the official unity spline system, it doesn't have all the bells and whistles here. My only other question was is it possible for me to add a mesh collider to the wires?
     
  38. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    It is! There is no option to add a Mesh Collider component to the generated wires. You can however add this functionality in the "ValidateComponents" function (line 114) in the WireGenerator class:

    Code (CSharp):
    1. //Swap out components for Line and Mesh rendering
    2. private static void ValidateComponents(Wire wire)
    3. {
    4.     if (wire.wireType.geometryType == WireType.GeometryType.Line)
    5.     {
    6.         if (wire.lineRenderer == false)
    7.         {
    8.             wire.lineRenderer = wire.gameObject.AddComponent<LineRenderer>();
    9.             wire.lineRenderer.hideFlags = HideFlags.None;
    10.         }
    11.  
    12.         if (wire.meshRenderer) GameObject.DestroyImmediate(wire.meshRenderer);
    13.         if (wire.meshFilter) GameObject.DestroyImmediate(wire.meshFilter);
    14.  
    15.         wire.mesh = null;
    16.     }
    17.  
    18.     if (wire.wireType.geometryType == WireType.GeometryType.Mesh)
    19.     {
    20.         if (wire.meshRenderer == false) wire.meshRenderer = wire.gameObject.AddComponent<MeshRenderer>();
    21.         if (wire.meshFilter == false) wire.meshFilter = wire.gameObject.AddComponent<MeshFilter>();
    22.  
    23.         if (wire.lineRenderer) GameObject.DestroyImmediate(wire.lineRenderer);
    24.      
    25.         //Add a mesh collider
    26.         MeshCollider collider = wire.GetComponent<MeshCollider>();
    27.         if (collider == false) collider = wire.gameObject.AddComponent<MeshCollider>();
    28.         collider.sharedMesh = wire.meshFilter.sharedMesh;
    29.     }
    30. }
     
  39. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    192
    Gotcha, thank you! Another thing that can be a bit cumbersome is that if you have gizmos turned OFF in the scene view and move an object with a Connector Group component, the attached wires do not follow it. Would be great if that could be fixed!

    Other than that, amazing asset. Nice work.
     
    StaggartCreations likes this.
  40. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    Ah yes, that is indeed the case. Though undesirable, the wire editing tool runs on the scene view UI update loop. Hence if Gizmo's are disabled, none of the code executes anymore.
     
    fendercodes likes this.
  41. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    192
    @StaggartCreations The URP shadergraph shader for the swaying is great. Do you think it can be adapted so that a portion of the rope is "pulled" in the direction of my player characters hand? As if being held. Any pointers on how to do that would be appreciated! I'm pretty new to vertex displacement.
     
  42. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    With some experimentation and tinker, I bet that should pan out. You'll want to use the vertex colors baked into the wire mesh, particular to ensure the ends (attachment points) don't get pulled towards the player. Which kind of data is stored in which color channel is outlined at the bottom of this page.
     
  43. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    350
    After coming back to this asset I a few years later still find that the wires, when swaying around, look broken in the middle, especially when I set the SwayStrength to a value higher than 1 (why is it clamped to 1 in the shader anyway?).
    The solution that looks the best to me is getting rid of the Gradient when creating the vertex colors of the wire, and directly calculating Mathf.Sin(Mathf.PI * wireSamplePoint) for the alpha, instead of using wire.windData.Evaluate(wireSamplePoint). If you want I can send you my changed WireGenerator.cs.
     
  44. GamePyro-com

    GamePyro-com

    Joined:
    Jul 28, 2018
    Posts:
    197
  45. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    I don't know the exact ins and outs of that particular asset, but if it works with a start & end point for a wire it may be possible to combine the two tools. This would require code modifications of course.
     
  46. unity_T5LF0HZ-OYv3KQ

    unity_T5LF0HZ-OYv3KQ

    Joined:
    Jan 10, 2021
    Posts:
    1
    I had a similar issue with 'Edit Wires' not showing at all in 2020.1.16f1 and finally just opened a second Scene tab and it shows in the second tab but no luck getting to show in the initial tab.
     
  47. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,262
    In the scene-view Gizmos need to be enabled, otherwise the UI has no way to present itself.