Search Unity

SketchUp to Unity Workflow

Discussion in 'Formats & External Tools' started by eneroth3, Nov 1, 2018.

  1. eneroth3

    eneroth3

    Joined:
    Oct 22, 2018
    Posts:
    63
    I've been using Unity for about two weeks now and have learned lots! I've looked into C# scripting, had a quick look on shaders, almost completed my own seamless portals and very much enjoy working in Unity.

    However, there is one thing that I think is a real pain, one thing that makes me leave my computer and go brush my hair or something rather than get on with my project: the SketchUp import workflow. I don't know if I miss something obvious, if there is a problem with the design of the Unity import, or a little of both.

    I've been using SketchUp for 10+ years, mostly for architectural modeling, and naturally want to use it for my level design (I intend to look into Blender for character design with animations and stuff). I want to do as much of the level design as possible in SketchUp with its superior tools for copying, moving, rotating etc, not just create individual pieces and assemble the scene in Unity. I still haven't found a way to rotate a GameObject around a custom axis, or use a vertex outside your selection as starting point when precisely moving it.

    When trying Unity's native SketchUp support, all textures were missing. I don't know if I missed some setting, and the only workaround I can find online is to first export a FBX from SketchUp, and import that instead in Unity. Already here the workflow gets one extra annoying step.

    My next problem is that it doesn't seem like I can link individual SketchUp components in Unity, only whole models. In SketchUp a component is virtually an embedded model, with its own local axes and all. The recommended workflow in SketchUp when creating multiple related objects, e.g. a furniture collection, is to have a master working file where you have all those objects as components. This way you can edit a shared sub-component, an have it update throughout all your objects. In my workflow with Unity it's natural for me to have one big SketchUp model, and let different groups or component represent different rooms or levels. Then I'd like to use just one of those components at a time in Unity. However, when dragging the component in from the Project View, the whole model comes in. If I purge what I don't want, the link is broken and updates made to that SketchUp component aren't reflected in Unity.

    I suppose I could get around this my making a script for SketchUp that exports my room or level components into separate files, that Unity can link to, but it's one more step making the workflow a bit more tedious. Also the Unity UI suggests you can link to individual groups or components, as you can see them in the project view and drag them into the hierarchy. I think what bugs me here is really how the Unity UI suggest something that it hen can't do.

    Another problem with importing these assemblies from SketchUp is that the local axes aren't preserved. Everything gets converted to global coordinates, with all transforms set to the origin. I would have expected this data to be kept in Unity, so I could place GameObjects like portals relative to the local coordinates of individual rooms. Honoring local axes would probably also be a requirement for mapping SketchUp ComponentDefinitions to presets, as multiple instances would need their shared content to be defined in local axes.

    If there is another way to easily get a level made in SketchUp into Unity, feel free to tell me. Otherwise I think this could be seen as a draft to a feature request.
     
  2. eneroth3

    eneroth3

    Joined:
    Oct 22, 2018
    Posts:
    63
    Some updates:

    I think I've found an acceptable workflow. It turned out there was a bug in my previous Unity version which caused the materials tab for model inspection not to function. Now that I've updated and this works it's become much easier to understand how the program is to be used.

    From my main über workign SketchUp model I export individual components (e.g. rooms or levels) to external SketchUp files, that I then reference in my Unity scene. It would be lovely if unity could keep a live link to an individual component definition within a SketchUp model, but this works to.

    While writing this I found the Select Nodes option, but that doesn't work the way I would find natural in a SketchUp context. It allows to selects groups or component instances, and presumably import them relative their current positions in the SketchUp model. To me it would be much more natural to link to a single definition used by such a group or component instance, given how a definition more or less is an embedded model in SketchUp. Properties of the individual instances, like their transforms, are irrelevant to me. In my working file I even just place them arbitrarily, and move them around as I go to form logical categories. Inside of them however I care a lot about positioning relative to the local axes.

    Unity's material import from SketchUp seems broken. The materials are referenced correctly on the imported meshes, but all textures are missing. However, I've been able to create my materials anew as unity materials in external files. In the model inspector I've remapped each material in the model to the corresponding external material. This allows me to apply the materials where I want them and do the UV mapping in SketchUp, but let them reference full Unity materials with all the settings SketchUp doesn't support.

    Is there a way to automatically set up this on demand remap for SketchUp models? I'd really like all materials to remap to the file by the same name as the material, in my materials folder?

    Also, it would be nice to know if the missing textures is a known issue. I can't find it mentioned in the documentations. Quite the opposite, the documentations claims Unity supports SU materials. Am I missing something here? Am I supposed to extract textures and or materials?
     
  3. Maximvs

    Maximvs

    Joined:
    Oct 10, 2016
    Posts:
    10
    Hi eneroth3,

    I'm not that familiar with SketchUp but i believe you can export .ifc 2x3 format from it right?

    If so, what if I told you that you could automatically convert your model to Unity and have UV's done at the same time.
    Also if properly done architectural model, you would have game object hierarchy by object type eg. Doors, Windows, Slabs etc...

    I recommend that you check Tridify Convert (https://www.tridify.com/convert/) and tell me what do you think about it.
     
  4. eneroth3

    eneroth3

    Joined:
    Oct 22, 2018
    Posts:
    63
    Hi Maximvs

    I think I've found a quite good workflow now, but this part of Unity has certainly been one of the least intuitive (I've found shaders and scripting much easier to pick up).

    I have a large working file in SketchUp containing all my levels. This allows for updating a reoccurring element once and have it updated everywhere. Each level is a component (kind of like an embedded model) that I then export to a standalone SketchUp file and reference in Unity. Personally I'd love if Unity could reference component definitions directly in the parent model, but this works for now.

    I've also found the issue with texture export. Unity assumes each SketchUp texture is associated with an external file. In SketchUp textures are embedded, and their associated path was often set when the material was first created, on a completely different computer with completely different files. When I started creating new materials from custom images within SketchUp, those were recognized by Unity as the external files were accessible in my asset folder. I think a lot could be done about making the SketchUp to Unity import more intuitive here. The best would be to just ignore the path and always use the embedded texture file from the SketchUp model.
     
    tonialatalo likes this.
  5. Hypertectonic

    Hypertectonic

    Joined:
    Dec 16, 2016
    Posts:
    75
    Hey eneroth, did you find a better workflow for importing components, or just SketchUp to Unity in general? I had hoped that with nested prefabs now a thing that Unity would have updated their SketchUp importer to finally fix this problem, but no luck.

    I made a script to automatically create materials with standard shader based on the extracted textures, then its easy to remap. Has saved me lots of time on big models.

    Code (CSharp):
    1. // Purpose
    2. // Creates a new material asset with the same name and directory of a chosen texture, with that texture set as albedo.
    3.  
    4. using System.IO;
    5. using UnityEngine;
    6. using UnityEditor;
    7.  
    8. namespace HYPER
    9. {
    10.     public class CreateMaterialsFromTextures
    11.     {
    12.         [MenuItem("Assets/Create/Material from Texture")]
    13.         static void CreateMatsFromTexs()
    14.         {
    15.             foreach (Texture tex in Selection.GetFiltered<Texture>(SelectionMode.Assets))
    16.             {
    17.                 string filePath = AssetDatabase.GetAssetPath(tex);
    18.                 if (File.Exists(filePath))
    19.                 {
    20.                     string fileName = Path.GetFileNameWithoutExtension(filePath);
    21.                     string cleanPath = filePath.Replace(Path.GetFileName(filePath), "");
    22.  
    23.                     Material material = new Material(Shader.Find("Standard"));
    24.                     AssetDatabase.CreateAsset(material, cleanPath + fileName + ".mat");
    25.  
    26.                     material.mainTexture = tex;
    27.  
    28.                     Debug.Log("Created new material " + fileName + ".mat from texture");
    29.                 }
    30.             }
    31.         }
    32.     }
    33. }
    BTW I've used many of your SketchUp plugins in the past, thank you for sharing. :)
     
  6. Maximvs

    Maximvs

    Joined:
    Oct 10, 2016
    Posts:
    10
    Hi Guys, for some unknown reason Unity has removed our Tridify BIM Tools plugin from Asset Store.
    But don't worry, You can still download Tridify BIM Tools plugin from here https://www.tridify.com/developers/unity/

    Cheers!
     
  7. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,639
    Did your package contain Unityscript by any chance? A little while ago, Unity has removed any assets that use Unityscript since it's now completely deprecated.