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
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
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.
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.
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.
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.
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.
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.
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:
GradientColorKey[] colorKeys = new GradientColorKey[2];
colorKeys[0] = new GradientColorKey(color, 0f);
colorKeys[1] = new GradientColorKey(color, 1f);
GradientAlphaKey[] alphaKeys = new GradientAlphaKey[8];
for (int i = 0; i < 8; ++i) {
var time = i / (float)(8 - 1);
alphaKeys[i] = new GradientAlphaKey(Mathf.Sin(time * Mathf.PI), time);
}
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.)
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.