Jump to content

Suggested layout of Unity?


micha

Recommended Posts

Just trying to gauge Best Practices while I'm upgrading the Unity projects for a large-ish mod I'm maintaining (I'm not very experienced with Unity).

Do people use a single Unity project into which they put all of their parts (albeit in different scenes)?

Or do people use one Unity project per part?

Or something entirely different?

 

The current layout is a bit of a mish-mash, some parts are grouped into a single Unity Project, others are in their own so I'm trying to see what the best way forward is.

 

As far as I can see:

Keeping each part (or small set of related parts) in separate projects:

  • Pros:
    • Fast loading
    • allows multiple people to work on the project as long as they don't work on the same parts
    • no need to worry about global namespace
  • Cons:
    • Need to maintain Unity project settings and add-ons and plugins (such as PartTools) separately for each project, taking up additional space in the repository and bigger chance for misconfiguration

Maintaining a single Unity project (and separating parts into suitable directories):

  • Pros:
    • A single unity project
    • easy to double-check global settings (eg, "Visible Metafiles" or the PartTools "GameData")
    • single copy of plug-ins/addons
    • potential for shared assets
  • Cons:
    • Slow loading
    • more chance for conflicts if multiple people are working on the project
    • more care needed to keep namespace "clean" (ie, must name all assets uniquely)

 

 

What do people think?

 

Link to comment
Share on other sites

Making separate projects for each part seems like a nightmare for anything more than a handful of parts. Doing any work would required constantly opening new instances of Unity to work on a different part. And each project takes up a fair amount of space just by itself, several 100 MB I think.

Separate scenes is ok, but I don't see any real reason to not just have all parts under the same scene. As long as you are careful and don't have things like parts parented to each other it shouldn't be a problem. Just turn off the parent object for whichever parts you aren't working on at the time. If you have a lot of parts it might make sense to have groups of related parts in separate scenes, maybe something like having all parts that share a texture map in the same scene.

I'm not sure why loading time would be much of a problem. You just open Unity once and everything is there. I've never noticed a significant difference in Unity loading time based on project size.

But really, the best option is whatever works best for you.

Link to comment
Share on other sites

The largest part of a Unity project is the "Library" folder which should never go into an SCM. So I'd save about 20-odd MB unifying all the separate projects (about a dozen). Mostly it's a management thing.

You're right, time spent opening Unity isn't such a big deal I just thought I'd list it as I noticed loading the "all-in-one" project took quite a bit longer.

 

Not sure how you manage multiple parts in a single scene. Aren't they all supposed to be at "0,0,0"? In which case they'd all be on top of each other?

What benefit is there in having multiple parts in one scene?

 

But really, the best option is whatever works best for you.

:) Sure; but given my noobishness with Unity, I'd like to stand on the shoulders of giants and see what has worked best for others.

Link to comment
Share on other sites

Yes parts will overlap, but you can disable all but the one you are working on. In the upper left corner of the Inspector window tab there is a little checkbox that will disable the currently selected object (and all of its children). I use that to focus on one thing at a time.

And if you want to look at multiple parts at the same time for whatever reason you can move them around, just make sure to move them back to 0,0,0 before exporting them.

Keeping everything in one scene means that you never have to load scenes when switching parts, depending on how you work it could be a minor problem, but I always like having everything in one place whenever possible.

You can also create a more complex hierarchy of parts in a scene, essentially making "folders" using empty game objects (right click on the hierarchy window to make a new empty object). That way you can keep your scene more organized if you have lots of parts.

As long as the Part Tools script is added to each individual part (the object created when you drag the model into the scene) then it doesn't matter how any upstream objects are organized, it just exports from the object that the script is on.

Link to comment
Share on other sites

I also, and I'm sure others, do what Dmagic posted, as to "hiding" all parts, but the one you are working on.
I know Blender has this same "function" as well... I'm sure most, if not all, other 3d modelling programs can do it as well.

I've "dabbled" and modified several parts mods, and i create seperate projects for each mod... I havent bothered keeping them in seperate scenes... just organized by a project per mod.

Edited by Stone Blue
Link to comment
Share on other sites

Wait...   "As long as the Part Tools script is added to each individual part (the object created when you drag the model into the scene)" - I've been attaching the PartTools script to the GameObject, not to the imported object (as per some tutorial I read a long time back).

Ie:

Scene -
    - GameObject (PartTools)
          - MyKspPart (Mesh, Mesh Renderer, Collider, Material/Texture, ...)
 

 

Should PartTools be on the object itself?  In which case what's the point of needing the empty GameObject at all?

Or did I just misunderstand something.

 

 

Link to comment
Share on other sites

i think you misunderstood.

-Scene
  -GameObject (PartTools) <---- each gameobject should be everything included for each part
     - everything for a single part (mesh, mesh renderer, collider, etc)

So...

-Scene

    -Part 1 empty Gameobject (w/ Part Tools component)
       - all the  child objects, meshes, colliders, components for this one part

    -Part 2 empty Gameobject (w/ Part Tools component)
       - all the  child objects, meshes, colliders, components for this one part

    -Part 3 empty Gameobject (w/ Part Tools component)
       - all the  child objects, meshes, colliders, components for this one part

and each Part X, can be "hidden", as DMagic described... so they are still in the scene, unchanged, as you work on a single, "active" part. you can still expand/close each part's hierarchy, whether they are "active" or "hidden"... i usually close each hidden part's hierarchy, to clean up the clutter, and only have my "active" part expanded... I'm sure everyone else does this too... especially if you have more than a couple parts in your scene

I'm in the process of trying to get a reinstall of Unity working with my existing projexts, and its not goin welll, or I would post screenshots, which would explain everything easier/clearer

Edited by Stone Blue
Link to comment
Share on other sites

What Stone Blue said, but you can also have objects above the ones containing the Part Tools, so:

- Scene

  • Engines
    • Engine 1 (w/Part Tools)
      • Child objects
    • Engine 2 (w/Part Tools)
      • ...
  • Tanks
    • Tank 1 (w/Part Tools)
      • ...

 

That way you can organize things better if you have a log of parts You can disable the top level empty gameobject to hide all of the parts below it, or collapse it so you don't see them in the list.

Link to comment
Share on other sites

Ok, cool, thanks guys.

 

So a single Unity project with a single Scene, add a GameObject for each separate part, add PartTools to it, and all the bits for each part. Use additional empty GameObjects for layout/grouping purposes, and show/hide parts as and when needed.

KSPedia in the single project as well?


 

Link to comment
Share on other sites

So I was curious and attached the PartTools script directly to a part instead of an empty GameObject and exported that directly. Apart from having to fix a rotation, it got loaded into KSP no worries. This seems to indicate there's no particular reason to use an empty GameObject for your KSP parts in Unity?

Link to comment
Share on other sites

You can do the same thing with KSPedia or a UI project. Just make one Canvas then add everything under that object and disable all but the page you are working on. The asset exporter doesn't care about how things look in your hierarchy window, or even if the scene is loaded, it only works from the prefabs you have saved on disk.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...