コード例 #1
0
    public void DuplicateFaces_ToSubmesh()
    {
        //Make first faces selected
        ProBuilderMesh mesh = selectables[0];

        Assume.That(mesh.faces, Is.Not.Null);
        Face        face          = selectables[0].faces[0];
        List <Face> selectedFaces = new List <Face>();

        selectedFaces.Add(face);
        mesh.SetSelectedFaces(selectedFaces);
        Assert.AreEqual(mesh.selectedFaceCount, 1);
        MeshSelection.SetSelection(mesh.gameObject);
        MeshSelection.OnObjectSelectionChanged();

        UnityEditor.ProBuilder.Actions.DuplicateFaces duplicateFaces = new UnityEditor.ProBuilder.Actions.DuplicateFaces();
        ProBuilderSettings.Set <UnityEditor.ProBuilder.Actions.DuplicateFaces.DuplicateFaceSetting>("DuplicateFaces.target", UnityEditor.ProBuilder.Actions.DuplicateFaces.DuplicateFaceSetting.Submesh);
        duplicateFaces.PerformAction();

        //All selectable object should have all faces selected
        Assert.AreEqual(selectables[0].faces.Count, 7);

        Assert.AreEqual(MeshSelection.selectedObjectCount, 1);
        Assert.AreEqual(UnityEditor.Selection.objects[0], mesh.gameObject);
    }
コード例 #2
0
    public void DuplicateFaces_ToObject()
    {
        //Make first faces selected
        ProBuilderMesh mesh = selectables[0];

        Assume.That(mesh.faces, Is.Not.Null);
        Face        face          = selectables[0].faces[0];
        List <Face> selectedFaces = new List <Face>();

        selectedFaces.Add(face);
        mesh.SetSelectedFaces(selectedFaces);
        Assert.AreEqual(mesh.selectedFaceCount, 1);
        MeshSelection.SetSelection(mesh.gameObject);
        MeshSelection.OnObjectSelectionChanged();

        UnityEditor.ProBuilder.Actions.DuplicateFaces duplicateFaces = new UnityEditor.ProBuilder.Actions.DuplicateFaces();
        ProBuilderSettings.Set <UnityEditor.ProBuilder.Actions.DuplicateFaces.DuplicateFaceSetting>("DuplicateFaces.target", UnityEditor.ProBuilder.Actions.DuplicateFaces.DuplicateFaceSetting.GameObject);
        duplicateFaces.PerformAction();

        //selectable object should keep all faces selected
        Assert.AreEqual(selectables[0].faces.Count, 6);

        Assert.AreEqual(MeshSelection.selectedObjectCount, 1);
        Assert.AreNotEqual(UnityEditor.Selection.objects[0], mesh.gameObject);

        //This needs to be called explicitly in the case of unit test so that the internal representation of ProBuilder MeshSelection
        //gets updated prior to accessing it
        MeshSelection.OnObjectSelectionChanged();
        ProBuilderMesh newMesh = MeshSelection.activeMesh;

        Assert.AreEqual(newMesh.faces.Count, 1);
    }