Search Unity

[RELEASED] Module Generator

Discussion in 'Assets and Asset Store' started by Sidema, Sep 29, 2016.

  1. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Hi,

    I've added an additional field in order to specify the seed mode. I felt that this would be more convenient than having this included in the generation mode.

    The three modes are:

    • Manual : Same behaviour as before. (Default mode)
    • Auto : The random generator will be seeded every time the module is executed (UnityEngine.Random.Range(Int32.MinValue, Int32.MaxValue))
    • Position : As suggested, the position and rotation determine the seed.

    upload_2020-7-13_14-50-27.png

    Are there any other featured you would like to see included?

    Edit: Documentation has been updated.
     
    Last edited: Jul 13, 2020
    StevenPicard likes this.
  2. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    Great news! Thank you! This is going to be used extensively in a couple of our games.

    The only other thing I could think of is the randomization of textures themselves (so you wouldn't need to swap out an actual prefab but just change the texture itself.)
     
  3. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    I'll look into this. Wouldn't it make more sense to change the material?

    It might also come in a separate script because the use case is much different from selecting one prefab in a set of prefabs. It would have to generate a prefab and then instantiate a material for that prefab. By attaching a separate script (like "MaterialGenerator") to the game object it would be more flexible.
     
  4. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    Yes, I should have said material. That would make more sense.
     
  5. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Hi,

    I've implemented the material exchange. I call it "MaterialHandler". I'd like to get a small feedback on this:

    upload_2020-7-15_15-6-53.png

    The class is independent of the actual module generator because it basically should only be performed when the Start() method of the MonoBehaviour is called. You don't want to execute this when the module manager handles the modules but only when the part is generated.

    Is this approach ok for you?

    The seed and seed mode are handled just like in the module with its three modes: manual, auto and position.

    Since a renderer can have an array of materials, it might be possible that you only want to change one of those materials and not all. Thus, I have given the possibility to index the material to change within the list of materials of the renderer. If you want to change multiple materials in the list, you'ld have to add one material handler per material to change. Does that make sense to you?

    Then, you see a list of materials with different weights which are handled in the same way part generation is handled.

    Finally, 2 convenient fields for debugging: Original material and replacement material.

    Any feedback on this?
     
    hopeful and StevenPicard like this.
  6. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    All I can say is that looks great! I am really looking forward to working with this!
     
  7. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Hi,

    Version 1.4 has been submitted and is pending in review. I'll get back to you as soon as the package is available on the store.

    I don't see how I can change the category... for an unknown reason, I don't see Tools->Level design as an option.
     
    StevenPicard likes this.
  8. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Version 1.4 is available on the store ! Go find it here.
     
    StevenPicard likes this.
  9. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    Great news! I'm glad this came out in time for the weekend.
     
    Metron likes this.
  10. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    Hey, I just saw this in the asset store - because of the update - and I could use something like this. I was thinking I'd have to write it. Glad to see that the material generation feature has been added!
     
    StevenPicard likes this.
  11. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    It's really a great asset and a huge time saver.
     
    hopeful likes this.
  12. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I see this is listed under the Input Management category ...? That could explain why I've been around since Unity 4 but never saw this in the store.

    Tools > Level Design is where this should be.

    I did just now pick it up, BTW. :)

    UPDATE: I don't know if the store still runs this way, but it used to be you could tell your store representative to change the category your asset is listed under.
     
    Last edited: Jul 19, 2020
    StevenPicard likes this.
  13. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Hi,

    I'll contact support today to see if the category could be changed.

    Thanks for your advice.

    Did you have the time to check on the MaterialHandler? Does it work as you want?
     
  14. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I've been away from my project the last few days, and haven't fired this up yet. It occurred to me though that I'd probably want to make sure I was able to take LOD into account. This means not only selecting from a list of possible materials for an object (say, red brick, weathered red brick, painted brick, etc.), but also from lower resolution versions of that material when at distance.
     
  15. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Hi,

    thanks for your suggestion. I think that you can achieve this with the current state of the material handler. In fact, you'll have to set up your LODs anyway. You could add a Material Handler to the list of components and set it up during your LOD creation step, no?

    Unless your LOD setup workflow does not use Unity's LOD system, this is how I would do it.

    (BTW. This is where the seed mode comes in handy because it would ensure that lower lods would trigger the same material based on position, for example).
     
    hopeful likes this.
  16. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    I'll be getting some materials in a day or two from our 3D artist so I should be able to test it very shortly.
     
    Sidema likes this.
  17. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    hopeful likes this.
  18. trueh

    trueh

    Joined:
    Nov 14, 2013
    Posts:
    74
    Hi,

    Trying to use Module Generator in Unity 2020.2, but some functions are missing:

    [CompilerError] The type name 'DrawCapFunction' does not exist in the type 'Handles'
    Compiler Error at Assets\Sidema\Utility\Editor\BoxEditor.cs:26 column 20
    24: private bool m_AllowNegativeSize = true;
    -->26: public Handles.DrawCapFunction drawMethodForHandles;
    28: public Func<Vector3, float> getHandleSizeMethod;

    It seems that Unity has removed DrawCapFunction and other methods from the API.

    Regards
     
  19. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Hi,

    thanks for your message. Another user has informed us about the problem just yesterday.

    We're looking into this and will provide a new version next week (with some new, additional features).

    Sorry for the inconvenience.

    Happy new year :)

    Stefan
     
    Markklarsen and hopeful like this.
  20. trueh

    trueh

    Joined:
    Nov 14, 2013
    Posts:
    74
    Happy new year :).

    I managed to solve it myself with a couple of changes in your code. Just let me know if you have any issue (this one is easy :)
     
  21. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Would you mind sending me the changes via PM? Would speed up my work :)
     
    hopeful likes this.
  22. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Hi,

    just to give a feedback... I only managed to work on this today... Sorry for the delay.
     
  23. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Hi,

    I've currently some trouble to submit the package to the asset store. In fact, the support for 5.3.x asset tools seems to be dropped.

    I'd have to submit the module generator with Unity 2017.4.1 which will drop the support for all versions older than that.

    Not sure if I should do so.
     
  24. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    It's probably all right. You might keep an older version on hand yourself in case someone desperately needs it, though.
     
  25. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Hi,

    I've submitted the new package to the store... Hopefully, it will be available soon.

    Release notes:

    v1.5
    Added:
    - Checkbox when manual generation is selected.
    -> Checkbox permits to generate the module as a separate object, which can be drag/dropped into prefab folder
    -> Module scripts are stripped from generated module

    Changes:
    - Adapted the scripts to support Unity API changes in 2020 (deprecated functions)


    Thanks to @trueh for having shared his changes with me.
     
  26. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
  27. dasjmp

    dasjmp

    Joined:
    Dec 21, 2015
    Posts:
    5
    Screen Shot 2021-01-28 at 12.25.20 AM.png I just downloaded and installed the 1.5 version in a completely new and empty project in unity 2020.1.f171 and it will not even run, please see attached picture.
     
  28. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    I'll check this immediately.
     
  29. Sidema

    Sidema

    Joined:
    Jan 5, 2016
    Posts:
    58
    Sorry, that one slipped...

    Quickfix: Simply change DrawCapFunction to CapFunction in BoxEditor.cs line 309.

    Edit: I've submitted the new version 1.6. I've also tested this version with the latest 2021.1.0b4.
     
    Last edited: Jan 28, 2021
  30. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    New version is live.
     
  31. dasjmp

    dasjmp

    Joined:
    Dec 21, 2015
    Posts:
    5
    Is there some needed step to enable the buttons to save settings when you are in editing mode under unity 2020 versions? None of those buttons are showing up under unity 2020.1.17f1 when editing a part.
     
  32. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Hi,
    when is this happening? Is this happening with a prefab? Or while editing a non-prefab?
     
  33. dasjmp

    dasjmp

    Joined:
    Dec 21, 2015
    Posts:
    5
    Steps I follow:
    1) I create a new project.
    2) Install module generator v1.6 via the package manager.
    3) Create a 3d cube and save as a prefab. Delete 3d cube from scene.
    4) Create an empty object, attach the module script to it.
    5) Press the add a part set button on the module, press the add a part button.
    6) Drag in the 3d cube prefab into the Part 0 object slot.
    7) Select the Part 0 entry in the Module, then when displayed in the editor window, drag the object to change the position. "Editing part" shows up, but no buttons to save cancel, etc appear: Screen Shot 2021-01-30 at 11.12.02 AM.png
     
  34. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Hi,

    I've tested your exact steps in 2020.1.17f1 and everything works as expected. Do you see any error messages?
     

    Attached Files:

  35. dasjmp

    dasjmp

    Joined:
    Dec 21, 2015
    Posts:
    5
    There are two warnings when I install the package, these happen on both Mac & Windows for 2020.1.17f1:

    Screen Shot 2021-01-31 at 11.42.36 PM.png

    Reading page 7 of the included documentation.pdf: "Second, as soon as you start to manipulate the preview object, you switch into the “part editing mode”; an “Editing part” label is displayed in the scene view as well as the “Apply” and “Cancel” buttons."

    None of these buttons are displayed in 2020.1.17f1 (Mac & PC) or in 2019.4.18f1 (only tested on Mac so far).
     
  36. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Have you moved the object?
     
  37. dasjmp

    dasjmp

    Joined:
    Dec 21, 2015
    Posts:
    5
    Yes, as shown in post #83, the object has been moved and the "editing part" label is displayed, but no other buttons. When I try to select a second part, a warning pops up and tells me that my current changes will be lost, but still no buttons to save them. I would be happy to show you via Google meet (or some other sharing program), but it is almost 1am in the pacific timezone and I need to head to be now for work in the morning.
     
  38. Markklarsen

    Markklarsen

    Joined:
    Aug 28, 2016
    Posts:
    8
    Hello if I use 2020.2.2f1 or 2021.1.0.b4 I don't get the "Add Part set" button in the inspector but if I use the + to add part sets it add one, but I can't put anything in the attach point, and if I create a part I can't add an object.

    upload_2021-2-1_15-37-2.png
    the above picture is from 2020.2.2f1 inspector

    But it works fine if I use it in 2020.1.14f1, there is an "Add part set" button in the inspector.

    I can upgrade the project to 2020.2.2f1 and module generator still works with the object I have created in 2020.1.14f1, but I can't change them.

    Am I doing something wrong? do I need to do something in 2020.2.2f1 and above to get it working
     
  39. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    I've requested support on this. In fact, there seems to be a bug on one of the editorgui functions which does not report the foldout correctly. Thus the editor doesn't get drawn correctly.

    Link to support request since I saw this in the current beta.

    Bug #1311349 reported
     
    Last edited: Feb 2, 2021
  40. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
  41. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Hi,

    A user reported a strange problem: The buttons were not visible within the editor scene view.

    It seems to be linked to high resolution screens and a problem related to the screen size reported by Screen.width and Screen.height.

    To solve this:

    - Please open the ModuleInspector.cs
    - Go to line 578 and divide the screen width and screen height by 2 :
    Code (CSharp):
    1. Rect buttonsAreaRect = new Rect(Screen.width*.5f - 114f, Screen.height*.5f - 95f, 104f, 50f);
    - Go to line 597 and do the same for the screen height:
    Code (CSharp):
    1. Rect toggleAreaRect = new Rect(5f, Screen.height*.5f - 105f, 110f, 70f);
    This should solve the problem.
     
  42. esmundoz

    esmundoz

    Joined:
    Sep 18, 2013
    Posts:
    12
    Hi, thanks for this great asset, I've been testing it out for our game lately! In my use case, it would be helpful to have a range for the whole part set, to define a minimum and maximum number of parts added. As I've understood this, to have an attachment point sometimes being empty, you add a part with no object to the list. But I want to make sure there at least is some attachment points in the part set that isn't empty in any circumstance, even though I add a part with no object to each part list. Hope you can add a solution to this!
     
  43. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Hi,

    I'm currently on holiday. I'll look into this when I'm back next week.

    I didn't quite understand the second part of your request (after "But I want to make sure...").
     
  44. esmundoz

    esmundoz

    Joined:
    Sep 18, 2013
    Posts:
    12
    Thanks!
    I'm looking for a way to make sure that a part set generates objects, even though each part in itself has the possibility to be empty.
     
  45. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    I propose to discuss this in pm. I'll text you next week. Is this okay?
     
  46. esmundoz

    esmundoz

    Joined:
    Sep 18, 2013
    Posts:
    12
    Yes, of course!
     
  47. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    I sent you a PM.