Search Unity

Instantiated Copy of ProbuilderMesh copies aswell the later transformations

Discussion in 'World Building' started by Maeslezo, Dec 28, 2020.

  1. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    331
    Hello,

    I am having a weird problem.

    When I copy a ProbuilderMesh with Instantiate, the transformations I apply to the original one are applied too to the copied mesh.

    This is solved somehow if I select the copied mesh in the editor hierarchy,

    I tried with Refresh, Rebuild, etc, but nothing worked.

    I suppose selecting the object does something, but I couldn't find it.

    Any ideas?

    A code snippet that reproduce the problem
    Code (CSharp):
    1. public class MeshDuplication : MonoBehaviour
    2. {
    3.     // Start is called before the first frame update
    4.     private IEnumerator Start()
    5.     {
    6.         ProBuilderMesh mesh1 = ShapeGenerator.CreateShape(ShapeType.Cube, PivotLocation.Center);
    7.         yield return new WaitForSeconds(1f);
    8.  
    9.         GameObject copy = Instantiate(mesh1.gameObject);
    10.         copy.transform.position = mesh1.transform.position + 3f*Vector3.right;
    11.         yield return new WaitForSeconds(1f);
    12.  
    13.         mesh1.TranslateVertices(new []{mesh1.faces.First()}, Vector3.right);
    14.     }
    15. }
    Instantiation Mesh Copy.gif
     

    Attached Files:

  2. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    331
    I think internal ProBuilderMesh.MakeUnique (file ProBuilderMeshFunction.cs, line 347) would do the trick, but it is internal.

    Any workaround?
     
  3. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    331
    @kaarrrllll any change to take a look to this?

    Thank you

     
  4. michiel98

    michiel98

    Joined:
    Apr 20, 2021
    Posts:
    3
    Hello,

    I am having the exact same problem. Did you ever found a solution for this?
     
  5. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    331
  6. michiel98

    michiel98

    Joined:
    Apr 20, 2021
    Posts:
    3
    Thanks but the bug is still there for me even on 5.0.4 or 5.0.0-pre.10. The link you send also seems to be related to a different issue. Did you accidentally send the wrong link or am I not understanding how that issue is related?

    Thanks for the help.
     
  7. Foor1o

    Foor1o

    Joined:
    Jan 5, 2017
    Posts:
    5
    Hello,

    Problem still occurs on version 5.0.6, any solution?
     
  8. unity_STWR-WB9WnBhFA

    unity_STWR-WB9WnBhFA

    Joined:
    Sep 4, 2019
    Posts:
    2
    having the same issue and no solution so far...
     
  9. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    eisclimber likes this.