Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Auto Fence Builder [Released]

Discussion in 'Assets and Asset Store' started by Two_Click_Tools, Oct 18, 2014.

  1. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    This does sound ideal, though I'm still looking for a good way to incorporate mouse buttons - as opposed to key commands - in to Unity’s ShortcutManagement. In the meantime, would a switch changing any Right Mouse Button requirement to, say, Middle (or other) solve any clashes?

    Going back to your opening point about references and attaching particle systems, would a separate script that enables you to attach a component to any Finished fence element (based on some criteria) add useful functionality for you?
     
  2. Jiinzu

    Jiinzu

    Joined:
    Jan 18, 2019
    Posts:
    12
    Hello, I use auto fence several times and each time it does the same thing to me I do some fencing then when I do something else auto fence does not work anymore, how to solve this problem?
     
  3. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Hi, please make sure Auto Fence Builder is selected in the hierarchy after you return from doing something else. (Also make sure you have not disabled Gizmos in the Scene view)

    Joe
     
  4. Jiinzu

    Jiinzu

    Joined:
    Jan 18, 2019
    Posts:
    12
    yes i selected fence builder
     

    Attached Files:

    Two_Click_Tools likes this.
  5. Jiinzu

    Jiinzu

    Joined:
    Jan 18, 2019
    Posts:
    12
    here
     

    Attached Files:

  6. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Thanks for the screenshots. I see the problem -- you have something named "GameObject" selected in the hierarchy, not Auto Fence Builder. Did you rename Auto Fence Builder to GameObject? Because of this, I can see some other problems have occurred. You have 3 folders named "Current Fences Folder", there should only be one.
    If possible, press 'Finish & Start New" and give the Finished fence a unique name for clarity.

    •Delete "GameObject" (If "GameObject (1)" is also an Auto Fence Builder delete this also)
    •Delete ALL 3 "Current Fences Folder"
    •Add Auto Fence Builder from the GameObject menu

    Please make sure:
    You can only have one instance of Auto Fence Builder in your hierarchy.
    When you need a new fence, "Finish & Start New" and continue with the same Auto Fence Builder
    Do not rename Auto Fence Builder

    If you would like more help with this, please contact twoclicktools@gmail.com
     
  7. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Unity Gizmos

    (the issue in the previous post was caused by Gizmos being off)

    For any new users, or those with a dark monitor, in the Unity interface it can be difficult to see if Gizmos are enabled.
    Most scene utilities/operations, including Auto Fence, require them to be on:

    Gizmos ON looks like this: “Gizmos” is light grey and you can see camera/lights icons
    Gizmos on.png

    Gizmos OFF looks like this: “Gizmos” is dark, and you can not see other icons.
    Gizmos off.png

    (it looks a little different if you use the Unity Editor Light Theme)
     
    Last edited: Dec 31, 2021
  8. TipTop3D

    TipTop3D

    Joined:
    Dec 10, 2015
    Posts:
    9
    Hello!
    Is it possible to make stepped fencing?
    For example, if you want wall/fence bricks rows on the slope to be horizontal between the posts

    Asset Store link is not correct in the first post
     
  9. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Hi, yes it is, under Rail A/B Control switch the Slope Mode to Stepped.
    You may want to switch off 'Lock Y Grounded' and lower the Rail Position Offset Y a little to compensate for the slope.

    Screenshot 2021-12-31 at 18.03.49.png

    Joe
     
    TipTop3D likes this.
  10. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Thanks
     
  11. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Hi, I'd like to use a mesh combining tool on my fences, but when I do that, there's an additional submesh included, with material ClickMarkerMat. Is there a way to prevent that from happening when I combine the fence meshes?

    thx
    Dave
     
  12. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Hi, yes sure, I can't recreate the issue at the moment so just need to check a couple of things. Can you confirm you're using the latest version of AFWB, 3.4. Which tool are you using, or have you coded the combine yourself?

    Have you tried using the built-in functionality? After Finishing a fence, select the parent folder of it and choose 'Create Merged-Mesh Copy'

    Have you disabled 'Show Controls' before doing the 'Finish & Start New'?

    Could you send a screenshot of the expanded Finished folder before you do the combine, as per below.
    finished 2.jpg



    If you'd prefer to use your own tool and the problem persists, I'll try to recreate the issue if you can give me any more details either here or at twoclicktools@gmail.com

    Thanks

    Joe
     
  13. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    268
    My workflow has multiple scenes active at once and sometimes, outside of play mode while editing, the scene that has Auto Fence Builder in it is NOT the active scene. This causes all objects that AFB creates to be in another scene. This would be fine except I think it's breaking things. My idea for a fix for this (besides me making sure that the scene with AFB in it being the active scene) is that all objects that are instantiated by AFB are done in the scene where the AFB component/gameobject exists. Do you think that sounds like a reasonable approach?

    Thanks BTW love the tool
     
  14. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Hi, I'll try doing what you described in a multi-scene workflow to get an idea what might be happening.

    What kind of breaking is happening? Do you get the same behaviour while the fence is in progress, or after you have finished it with the 'Finish & Start New'?

    The approach you mentioned sounds logical, but I'll get back to you after I try it. I take it you're on AFWB 3.4 (latest version), and what Unity version?

    Thanks

    Joe

    (btw, I'm on European time if you don't get a quick answer. You can also contact at twoclicktools@gmail.com)
     
  15. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    268
    Thanks for the quick reply Joe. What I'm noticing is that my in-progress fence disappears at times I'm not expecting it. I haven' t narrowed it down, but I think it may be as simple as that the fence gets built in a different scene than where AFB exists, so the references are broken later. Let me know if you don't see anything obvious and I'll make a test setup for you. Cheers!
     
  16. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Yes, thanks, if you could sent a minimal test project that I can just add AFWB to, that would be great... it could well be dependent on project settings which of course I might not see in my project. Are you on 2020.3 or 2021.x?

    Cheers
     
  17. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    268
    2020.3 LTS

    Glad you're still supporting this, it's a super valuable tool.
     
  18. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Thanks. One thing you could try first is to select 'Save Meshes' at the top of the AFWB Inspector. At this point all elements will be regular Game Objects with the meshes in the Assets folder, so Unity should treat them like any other.
    Up until this point the meshes would only exist in memory, and this has been known to confuse a couple of third-party assets, so maybe the multi-scene setup requires this too, but there's nothing about it in the docs.
     
  19. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Getting back to this -- I tried the built-in functionality, and the log messages indicate that it worked, but I still have all the individual meshes in the hierarchy.... I'm using v3.3.5 on Unity 2019.4.34

    upload_2022-4-8_10-20-23.png
     
  20. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Ok, that’s a screen shot of the pre-merged folder. After doing the ”Create Merged Mesh Copy” command, there should be a new folder copy in your Hieracrchy named something like ”…merged mesh copy”. Would you mind just trying again as the messaged seem to show it should be there.

    thanks

    joe
     
  21. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    D'oh! There are five merged mesh objects way down at the bottom of the hierarchy, I didn't think to look down there. Thanks! It did split the entire fence into 4 or 5 groups, instead of a single mesh for the entire thing. That might be preferable for frustrum culling though -- is that intentional?
     
  22. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Yes, sorry should have mentioned that, intentional, also as users often wanted posts seperate to panels etc.
    Performance wise it’s pretty much the same as one mesh. I guess you could always do another merge on those 4 if you needed a single.

    cheers

    joe
     
    gecko likes this.
  23. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    268
    So, I am finding that the number of assets generated is unwieldy in terms of source control. I'm also finding that the names of these assets are exceedingly long. So, here are some questions:

    1) Is there a way to avoid the generation of all these little assets for a single fence?
    2) Is there a way to reduce the size of the filenames? It's so long I've had to make modifications to Windows Registry as well as Git in order to support filenames over 255 chars.

    Ideally, the data for a fence's many generated meshes would be stored in a single .asset file. Are you perhaps familiar with this technique where many individual meshes could be piled into a single asset file?
    https://docs.unity3d.com/ScriptReference/AssetDatabase.AddObjectToAsset.html

    This would solve the above two problems because in addition to consolidating all of the meshes into one file, it would let the long filenames live only inside Unity, not as files.
     
  24. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    1. Yes, have you used the Merged Mesh Copy feature after finishing a fence, this would reduce the number of assets to <10.
    If you mean during construction, then no.. as you know the fences are built from individual selectable components, so this is the basis of it’s construction and flexibility.

    2. Yes, if you’d like to email support with a naming convention that would suit you, I can send you a mod. It would be useful if you could send an example of a problematic generated name so I can be sure I’ve understood the problem and fixed it.

    Cheers

    Joe
     
  25. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    268
    Ah ok thanks for the quick response! So, if I merge the mesh, as far as I can tell, it cannot be edited again. Is that right?

    That's what's prevented me from using that feature. There appears to be no way to retain editability without storing the individual asset meshes.
     
  26. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    That’s right, a finished fence can be edited, but not a merged one right now. Would it solve your problem if I sent you a mod for that too, and included it in the next update?
     
  27. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    268
    I appreciate the offer for these mods greatly. It would definitely help.

    What would really make it sing is if the individual asset files could be deleted when generating the merged mesh. Without that, I need to go in and manually delete them, which is highly error prone. This is assuming that the individual assets are not needed for the editing step.
     
  28. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Once you’ve done the merge you would just delete the single previous ’Finished…” folder, or have I misunderstood? The new merged copy is in its own parent folder.
    What would you need to manually delete?
     
  29. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    268
    I was more going on the hundreds of individual files being added to Git... but yes, that folder could be deleted, you're correct.
     
  30. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Ok. BTW, there’s also a Remove Unused feature under Globals that removes any UNUSED assets from a live AFWB. Although to be honest it’s just as quick to remove the tool from the hierarchy and re-add it when you need it.
     
  31. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    268
    OK yeah those steps are all reasonable. I would love to be able to just say "Finish -> Merged" and end up with an editable merged version that skips the generation of the intermediate meshes. Each additional step required, especially when this tool is put into production with new artists, is an opportunity for errors.
     
  32. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    No problem, that’s doable. Look forward to hearing from you with the other details and contact.
     
  33. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I'm trying to do this now to a fence that I completed awhile ago, and have since made another fence. Is there a way to generate meshes from an older fence? I don't recall what I did exactly when finishing it, but that fence's parent has nothing in the inspector, and the Auto Fence object looks like it still has the new fence in mind. I tried using my other Mesh Combiner tool but it created those red spheres on every other post.
     
  34. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Hi, can I get a bit more info...

    >> Is there a way to generate meshes from an older fence?
    Do you know how old? If it was from before v3.1 (about 2 years ago) then the build info won't be available and it might not be possible

    >> but that fence's parent has nothing in the inspector,
    Do you mean it doesn't have the options here?:

    Screenshot 2022-05-24 at 14.27.28.png


    Can you post screenshots?

    If all else fails you could drag the Finished fence in to your assets folder to make a prefab, export that as a package and send it to twoclicktools@gmail.com (if possible in the next 24 hours)

    Joe
     
  35. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Support

    For the first time since launch, we're both going to be away on holiday at the same time for a week from tomorrow. I can answer support questions still, but nothing that would require running Unity.

    Cheers

    Joe
     
  36. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    The parent inspector has no components in it at all. I made this fence a month or two ago, but don't recall my work sequence. So too late for this fence. I'll send you the prefab package, but it's not super urgent, can wait until after your holiday. Thanks!

    Dave
     
  37. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
  38. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Asset Store minimum versions

    For anyone who didn’t know yet, the latest Unity guidelines for Asset Store publishers stipulate that updates to existing packages can now only be submitted using Unity 2019.4 or newer, and new packages must use 2020.3 or newer. We’re just waiting for this sale to finish and then AFWB will be updated to 3.5 using whatever the current LTS version of 2019.4 is at the time.

    Just a heads up in case you’re on earlier Unity versions, we’ll post again when it's up. Thanks!
     
    Marcos-Elias and julianr like this.
  39. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    285
    Hello @Two_Click_Tools , thanks for this fantastic tool.
    I got couples of questions after playing around with the tool.

    I got this test castle wall up.
    upload_2022-7-18_16-1-5.png

    1/ Ray miss
    But only by modify the code to simply set the pos = hit.point.
    Code (CSharp):
    1. // lower things to ground level
    2.     public void Ground(List<Vector3> vec3List)
    3.     {
    4.         RaycastHit hit;
    5.         Vector3 pos, highPos;
    6.         float extraHeight = 4;//((globalScale.y * postSize.y)/2) + postHeightOffset;
    7.         SetIgnoreColliders(true);
    8.  
    9.         for (int i = 0; i < vec3List.Count; i++)
    10.         {
    11.             highPos = pos = vec3List[i];
    12.             highPos.y += extraHeight;
    13.             if (Physics.Raycast(highPos+Vector3.up*500f, Vector3.down, out hit, 1000)) // First check from above, looking down
    14.             //if (Physics.Raycast(highPos, Vector3.down, out hit, 500, groundLayers)) // First check from above, looking down
    15.             {
    16.                 if (hit.collider.gameObject != null)
    17.                 {
    18.                     pos = hit.point;// += new Vector3(0, -(hit.distance - extraHeight), 0);
    19.                 }
    20.             }
    21.             else if (Physics.Raycast(pos, Vector3.up, out hit, 1000)) // maybe we've gone below... check upwards
    22.             {
    23.                 if (hit.collider.gameObject != null)
    24.                 {
    25.                     pos = hit.point;// += new Vector3(0, +hit.distance, 0);
    26.                 }
    27.             }
    28.             vec3List[i] = pos;
    29.         }
    30.         SetIgnoreColliders(false);
    31.     }
    With the original code it would have some ray miss or something, they sink to the ground.

    upload_2022-7-18_16-5-49.png


    2/Reverse Fence
    Reverse Fence is cool, but only useful at the end of creation. Because everything I edit the fence like moving control points, it reversed again, and I have to click Reverse Fence.
    Wishlist for a toggle just so the fence processing always calculate result in Reverse if it is toggled On.

    3/Less stretch for wall on slope
    I tried all 3 slope mode, only sheer can work for this use case (castle wall on slope), but a more advance mode to reduce stretch/sheer will be appreciated!


    upload_2022-7-18_16-12-7.png

    4/Continuous mesh ?
    So this image is self-explanatory, is there a way to fix this, or we have to export to blender and adjust the final mesh ?

    upload_2022-7-18_16-17-24.png


    This tool is fantastic for fence, but for wall on slope it need many adjust afterward.
    Still good for prototyping though. I hope all my problems are just lacking in understanding of using it.
    Pls point me anywhere I'm wrong, thank you
     

    Attached Files:

  40. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Hey Spikebor, thanks for your message.

    4) Continuous Mesh
    No problem. For flat walls, the mode you show in your picture is the default mode as they blend seamlessly like that.
    For the wall in your picture with extruded edges we've added a 'Miter' mode that will give you what you want. (Image in next post)
    This is in the upcoming v3.5 release, but I can send you a mod now if you contact twoclicktools@gmail.com

    2) Reverse fence.
    This sounds like a good idea. I'll add it to 3.5. If you contact us I can send you an early mod.

    3) Less Stretch for wall on Slope
    I'm not sure what you mean with this? By definition if you have a wall going up a very steep slope, it will need to stretch and shear. Would it be possible to create an image/sketch of how you would want it to look?
    Have you tried inserting (control-shift-click) one or more node in the middle of that section, and adjusting their position, so each section can be a little shorter and less stretched?
    I can also see that because your ground is very steep and uneven, you may want to lower the Rail A/B Position Offset Y, to sink it in to the ground a little to prevent gaps at the bottom of the wall. (make sure 'Lock Y Grounded' is off)

    4) Yes, you're right, that doesn't look right. I haven't seen this before.
    Could you send a screenshot with 'Show Control Nodes' enabled, so I can see where your click-points are?
    Again, you could also try Inserting one or mode nodes along that section. With a very long section that has massive elevation changes, it looks like the ray could miss. As a general rule, the more elevation you have, it's good to have more click-points.
    If you're looking at the Ground() code, you can also change the line
    float extraHeight = 4;
    to be something higher like 40. The setting of 4 was to catch an edge-case, which no longer applies.

    I look forward to hearing from you so I can send you the requested features. (We can't release 3.5 at the moment until the Sale ends)

    Thanks

    Joe
     
    Last edited: Jul 18, 2022
    gurayg and julianr like this.
  41. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Miter Joint mode:
    wall.jpg
     
  42. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    285
    Thank you, this will fix what I have.
    Can't believe we'll still get update in 2022 given the asset is from 2014.
    I can wait for the 3.5 update like everyone as this is not urgent.
    Hope you have a nice day!
     
    julianr likes this.
  43. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Thanks very much, plenty more to come!

    If you, or anyone else wants to change the Reverse mode to a permanent toggle before the update is available,
    you can make a small change to AutoFenceEditor.cs, at line 2894 change:

    Code (CSharp):
    1.    
    2.     void ReverseClickPoints()
    3.     {
    4.         af.clickPoints.Reverse();
    5.         af.ForceRebuildFromClickPoints();
    6.     }
    to:

    Code (CSharp):
    1.  
    2.     void ReverseClickPoints()
    3.     {
    4.         af.clickPoints.Reverse();
    5.         af.handles.Reverse();
    6.         af.clickPointFlags.Reverse();
    7.         af.ForceRebuildFromClickPoints();
    8.     }
    9.  
     
    julianr and Spikebor like this.
  44. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    268
    Hey is there a way to insert a gap in an existing section of fence? I'm not seeing it.
    What I am able to do is make a gap as I draw out new fence. I'm also able to insert new nodes in an existing fence, between nodes. However I cannot see how to insert a gap between two existing nodes. Thanks.
     
  45. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Hi Ben, at the moment it isn’t possible to add a gap after the fence has been laid out.
    There may be a workaround if it’s just a single section you want to remove. Enable ’Auto Hide Buriedˋ on the Rail settings and then place an obstacle - such as a cube with collider - in the way between two posts, this will omit that section.
    I’ll add this feature to the next update.

    Cheers

    Joe
     
  46. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    268
    Ok thanks Joe.
     
  47. Damjan-Mozetic

    Damjan-Mozetic

    Joined:
    Aug 15, 2013
    Posts:
    46
    Hello Joe,

    First of all, thank you for creating this tool. It's stellar!

    The issue I am having is with normals on placed geometry. The top image is an asset I created and dragged into the editor directly, the bottom image is the same asset placed using Auto fence builder. You can see from the lighting that the normals are off (like, 90 degrees off). Is there any fix to this?

    Thank you,

    Damjan
    shot_2022-09-24_10-36-20.png
     
  48. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    Hi Damjan,

    Yes, I see what you mean. I’ll check this. Is there a possibility you could export and send the prefab to twoclicktools@gmail.com so I can figure out why this happened?

    Thanks

    Joe
     
  49. Two_Click_Tools

    Two_Click_Tools

    Joined:
    Oct 9, 2014
    Posts:
    250
    ... also, could you try changing Slope Mode in the Rail Controls, and let me know if it makes any difference.
    Are you using AFWB 3.4?
    Which Unity version?

    Thanks

    Joe
     
  50. Damjan-Mozetic

    Damjan-Mozetic

    Joined:
    Aug 15, 2013
    Posts:
    46
    Hi, I have e-mailed you the prefab.

    Changing slope mode to any of the three values does not solve the issue.

    Unity version 2020.3.38f1 on Windows 11.
    Auto Fence & Wall Builder v.3.4

    Thanks,
    Damjan