Esempio n. 1
0
        public static void MergeSingle()
        {
            if (MeshOperations.operating)
            {
                return;
            }
            MeshOperations.operating = true;
            Call.Delay(() => MeshOperations.operating = false);
            var primary = Selection.gameObjects[0];
            var merged  = primary.GetMeshSource().GetMesh().Copy();
            var wrap    = merged.GetMeshWrap();

            foreach (var source in Selection.gameObjects.Skip(1))
            {
                var mesh    = source.GetMeshWrap();
                var matches = new Dictionary <int, int>();
                for (int indexA = 0; indexA < wrap.positions.Length; ++indexA)
                {
                    var vertexA = wrap.positions[indexA];
                    for (int indexB = 0; indexB < mesh.positions.Length; ++indexB)
                    {
                        var vertexB  = mesh.positions[indexB];
                        var distance = Vector3.Distance(vertexA, vertexB);
                        if (distance < MeshOperations.Get().distance)
                        {
                            //Log.Show("Difference is : " + distance);
                            //Log.Show(indexA + " matches " + indexB);
                            matches[indexA] = indexB;
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public void OnEnable()
 {
     MeshOperations.instance     = this;
     this.vertexMaterial         = new Material(Shader.Find("Zios/Utility/Draw Vertexes"));
     this.distanceMaterial       = new Material(Shader.Find("Zios/Utility/Draw Vertexes Outlined"));
     this.lockSelection          = false;
     Selection.selectionChanged += this.RefreshSceneView;
     EditorApplication.update   += this.CheckChanged;
     //EditorApplication.hierarchyWindowChanged += this.Reset;
     this.RefreshSceneView(true);
 }