Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Combine Children Extented (sources to share)

Discussion in 'Scripting' started by Neodrop, Dec 26, 2009.

  1. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    322
    Hey, not sure if this is still being worked on but I don't think it works properly with scaled objects. If an object is flipped along an axis, often it will result in the normals being flipped upon combine. I'll poke around and see if I can find a solution to this.

    Edit1: Pretty sure the source of the problem is the winding order of the flipped mesh. Not quite sure what determines if the winding order needs to be reversed.
     
    Last edited: Oct 31, 2014
  2. shoeshine1984

    shoeshine1984

    Joined:
    Dec 3, 2013
    Posts:
    16
    Hi Neodrop, this is awesome :) Thank you so much for creating this!
    I read the above discussion with Austin_CLS and I'm trying to do the same - combine mesh, then rebake the lightmap. Of course the lightmap UV isn't there any more after combining, and your suggestion was to save the mesh as asset (.asset file) and then import it with "generate lightmap UV" option checked.

    Maybe I'm not doing this correctly, but when I click on the .asset file in editor it doesn't display any import options like when I select a blender or fbx file. Do you know if this can be accomplished?

    Thank you again!
     
  3. sowatnow

    sowatnow

    Joined:
    Jun 12, 2014
    Posts:
    309
    Hi

    I am getting the following error when I import the script:

    Assets/Standard Assets (Mobile)/$CombineChildrenExtended.cs(66,25): error CS0246: The type or namespace name `MeshCombineUtility' could not be found. Are you missing a using directive or an assembly reference?

    I found meshbomeutility script, but have the following problem now. It says Can'd add component: "$CombineChildrenExtended" because it doest exist.
     
    Last edited: Dec 5, 2014
  4. tomaz52

    tomaz52

    Joined:
    Feb 12, 2014
    Posts:
    22
    Can someone help? This script dont run in Unity 5, i have this line error.

    No overload for method "GetTriangles" Takes 3 arguments

    But i can find reference to fix that.

    Here the sample

    Mesh mesh = new Mesh();
    mesh.name = "Combined Mesh";
    mesh.vertices = vertices;
    mesh.normals = normals;
    mesh.uv = uv;
    mesh.uv2 = uv1;
    mesh.tangents = tangents;
    if (generateStrips)
    //mesh.GetTriangles(strip, 0);//Here is the problem
    //Debug.Log ("Fix here!!");
    else
    mesh.triangles = triangles;

    return mesh;
     
  5. tomaz52

    tomaz52

    Joined:
    Feb 12, 2014
    Posts:
    22

    Problem solved!!!!
     
  6. RLin

    RLin

    Joined:
    May 10, 2015
    Posts:
    133
    how did you solve it? I have the same problem.
     
  7. bigoMay

    bigoMay

    Joined:
    Sep 14, 2013
    Posts:
    6
    Hi,

    I used the script CombineChildrenExtended.cs in Unity 5.3 and it works smoothly after disabling the option GenerateTriangleStrips.

    About CombineOnStart, I thought that was the option to enable/disable combining meshes in runtime, but on the Start() code it is evaluated in the same branch as FrameToWait. So, even if CombineOnStart is set to false, the script will go to the else branch that will call CombineLate(). I just wanted to point this out, since it might be a bit confusing for the user.