@@ -540,9 +540,6 @@ static GameObject[] GenerateFacePickingObjects(
540540 {
541541 var pb = selection [ i ] ;
542542
543- GameObject go = InternalUtility . EmptyGameObjectWithTransform ( pb . transform ) ;
544- go . name = pb . name + " (Face Depth Test)" ;
545-
546543 Mesh m = new Mesh ( ) ;
547544 m . vertices = pb . positionsInternal ;
548545 m . triangles = pb . facesInternal . SelectMany ( x => x . indexesInternal ) . ToArray ( ) ;
@@ -559,8 +556,8 @@ static GameObject[] GenerateFacePickingObjects(
559556
560557 m . colors32 = colors ;
561558
562- go . AddComponent < MeshFilter > ( ) . sharedMesh = m ;
563- go . AddComponent < MeshRenderer > ( ) . sharedMaterial = BuiltinMaterials . facePickerMaterial ;
559+ GameObject go = InternalUtility . MeshGameObjectWithTransform ( pb . name + " (Face Depth Test)" , pb . transform , m ,
560+ BuiltinMaterials . facePickerMaterial , true ) ;
564561
565562 pickerObjects [ i ] = go ;
566563 }
@@ -587,10 +584,11 @@ static void GenerateVertexPickingObjects(
587584 {
588585 // build vertex billboards
589586 var pb = selection [ i ] ;
590- GameObject go = InternalUtility . EmptyGameObjectWithTransform ( pb . transform ) ;
591- go . name = pb . name + " (Vertex Billboards)" ;
592- go . AddComponent < MeshFilter > ( ) . sharedMesh = BuildVertexMesh ( pb , map , ref index ) ;
593- go . AddComponent < MeshRenderer > ( ) . sharedMaterial = BuiltinMaterials . vertexPickerMaterial ;
587+
588+ var mesh = BuildVertexMesh ( pb , map , ref index ) ;
589+ GameObject go = InternalUtility . MeshGameObjectWithTransform ( pb . name + " (Vertex Billboards)" , pb . transform , mesh ,
590+ BuiltinMaterials . vertexPickerMaterial , true ) ;
591+
594592 pickerObjects [ i ] = go ;
595593 }
596594
@@ -602,10 +600,10 @@ static void GenerateVertexPickingObjects(
602600 for ( int i = 0 ; i < selectionCount ; i ++ )
603601 {
604602 var pb = selection [ i ] ;
605- GameObject go = InternalUtility . EmptyGameObjectWithTransform ( pb . transform ) ;
606- go . name = pb . name + " (Depth Mask)" ;
607- go . AddComponent < MeshFilter > ( ) . sharedMesh = pb . mesh ;
608- go . AddComponent < MeshRenderer > ( ) . sharedMaterial = BuiltinMaterials . facePickerMaterial ;
603+
604+ GameObject go = InternalUtility . MeshGameObjectWithTransform ( pb . name + " (Depth Mask)" , pb . transform , pb . mesh ,
605+ BuiltinMaterials . facePickerMaterial , true ) ;
606+
609607 depthObjects [ i ] = go ;
610608 }
611609 }
@@ -632,10 +630,11 @@ static void GenerateEdgePickingObjects(
632630 {
633631 // build edge billboards
634632 var pb = selection [ i ] ;
635- GameObject go = InternalUtility . EmptyGameObjectWithTransform ( pb . transform ) ;
636- go . name = pb . name + " (Edge Billboards)" ;
637- go . AddComponent < MeshFilter > ( ) . sharedMesh = BuildEdgeMesh ( pb , map , ref index ) ;
638- go . AddComponent < MeshRenderer > ( ) . sharedMaterial = BuiltinMaterials . edgePickerMaterial ;
633+
634+ var mesh = BuildEdgeMesh ( pb , map , ref index ) ;
635+ GameObject go = InternalUtility . MeshGameObjectWithTransform ( pb . name + " (Edge Billboards)" , pb . transform , mesh ,
636+ BuiltinMaterials . edgePickerMaterial , true ) ;
637+
639638 pickerObjects [ i ] = go ;
640639 }
641640
@@ -646,11 +645,11 @@ static void GenerateEdgePickingObjects(
646645 for ( int i = 0 ; i < selectionCount ; i ++ )
647646 {
648647 var pb = selection [ i ] ;
648+
649649 // copy the select gameobject just for z-write
650- GameObject go = InternalUtility . EmptyGameObjectWithTransform ( pb . transform ) ;
651- go . name = pb . name + " (Depth Mask)" ;
652- go . AddComponent < MeshFilter > ( ) . sharedMesh = pb . mesh ;
653- go . AddComponent < MeshRenderer > ( ) . sharedMaterial = BuiltinMaterials . facePickerMaterial ;
650+ GameObject go = InternalUtility . MeshGameObjectWithTransform ( pb . name + " (Depth Mask)" , pb . transform , pb . mesh ,
651+ BuiltinMaterials . facePickerMaterial , true ) ;
652+
654653 depthObjects [ i ] = go ;
655654 }
656655 }
0 commit comments