Exemple #1
0
    public void Setup()
    {
        // make sure the ProBuilder window is open
        if (ProBuilderEditor.instance == null)
        {
            ProBuilderEditor.MenuOpenWindow();
            m_OpenedWindow = true;
        }

        m_ShowIconsInitialValue = ProBuilderEditor.s_IsIconGui.value;
    }
Exemple #2
0
 public void Setup()
 {
     // make sure the ProBuilder window is open
     if (ProBuilderEditor.instance == null)
     {
         ProBuilderEditor.MenuOpenWindow();
         m_OpenedWindow = true;
     }
     Assert.That(ProBuilderEditor.instance, Is.Not.Null);
     m_PBMesh                    = ShapeGenerator.CreateShape(ShapeType.Cube);
     m_PreviousSelectMode        = ProBuilderEditor.selectMode;
     ProBuilderEditor.selectMode = SelectMode.Vertex;
 }
    public void Setup()
    {
        // make sure the ProBuilder window is open
        if (ProBuilderEditor.instance == null)
        {
            ProBuilderEditor.MenuOpenWindow();
            m_OpenedWindow = true;
        }

        UVEditor.MenuOpenUVEditor();

        m_cube = ShapeFactory.Instantiate <Cube>();
        UnityEditor.ProBuilder.EditorUtility.InitObject(m_cube);
    }
        public void Setup()
        {
            // make sure the ProBuilder window is open
            if (ProBuilderEditor.instance == null)
            {
                ProBuilderEditor.MenuOpenWindow();
                m_OpenedWindow = true;
            }

            UVEditor.MenuOpenUVEditor();

            m_cube = ShapeGenerator.CreateShape(ShapeType.Cube);
            UnityEditor.ProBuilder.EditorUtility.InitObject(m_cube);
        }
Exemple #5
0
    public void Setup()
    {
        // make sure the ProBuilder window is open
        if (ProBuilderEditor.instance == null)
        {
            ProBuilderEditor.MenuOpenWindow();
        }

        Assume.That(ProBuilderEditor.instance, Is.Not.Null);

        m_PBMesh = ShapeFactory.Instantiate(typeof(UnityEngine.ProBuilder.Shapes.Plane));
        MeshSelection.SetSelection(m_PBMesh.gameObject);
        MeshSelection.OnObjectSelectionChanged();

        m_PreviousSelectMode        = ProBuilderEditor.selectMode;
        ProBuilderEditor.selectMode = SelectMode.Object;
    }
    public void Setup()
    {
        // make sure the ProBuilder window is open
        if (ProBuilderEditor.instance == null)
        {
            ProBuilderEditor.MenuOpenWindow();
        }

        Assume.That(ProBuilderEditor.instance, Is.Not.Null);

        m_PBMesh = ShapeGenerator.CreateShape(ShapeType.Plane);
        MeshSelection.SetSelection(m_PBMesh.gameObject);
        MeshSelection.OnObjectSelectionChanged();

        m_PreviousSelectMode        = ProBuilderEditor.selectMode;
        ProBuilderEditor.selectMode = SelectMode.Object;
    }
Exemple #7
0
    public static IEnumerator ExtrudeOrthogonally_OneElementManyTimes_NoYOffsetAccumulates()
    {
        // Generate single face plane
        var pb = ShapeGenerator.GeneratePlane(PivotLocation.Center, 1f, 1f, 0, 0, Axis.Up);

        try
        {
            pb.transform.position = Vector3.zero;
            pb.transform.rotation = Quaternion.identity;

            ProBuilderEditor.MenuOpenWindow();
            EditorApplication.ExecuteMenuItem("Window/General/Scene");

            var sceneView = UnityEngine.Resources.FindObjectsOfTypeAll <UnityEditor.SceneView>()[0];
            sceneView.orthographic = true;
            sceneView.drawGizmos   = false;
            sceneView.pivot        = new Vector3(0, 0, 0);
            sceneView.rotation     = Quaternion.AngleAxis(90f, Vector3.right);
            sceneView.size         = 2.0f;
            sceneView.Focus();

            var e = new Event();
            e.type = EventType.MouseEnterWindow;
            sceneView.SendEvent(e);

            Assume.That(pb.facesInternal.Length, Is.EqualTo(1));
            var face = pb.facesInternal[0];

            // Select face
            var selectedFaces = new List <Face>();
            selectedFaces.Add(face);
            Tools.current = Tool.Move;
            ProBuilderEditor.toolManager.SetSelectMode(SelectMode.Face);
            pb.SetSelectedFaces(selectedFaces);
            MeshSelection.SetSelection(pb.gameObject);

            // Center mouse position
            var bounds   = SceneView.focusedWindow.rootVisualElement.worldBound;
            var mousePos = (bounds.size * 0.5f + bounds.position) + new Vector2Int(1, 1);

            e = new UnityEngine.Event()
            {
                type          = EventType.MouseDown,
                mousePosition = mousePos,
                modifiers     = EventModifiers.None,
                clickCount    = 1,
                delta         = Vector2.zero,
            };
            sceneView.SendEvent(e);

            e = new UnityEngine.Event()
            {
                type          = EventType.MouseUp,
                mousePosition = mousePos,
                modifiers     = EventModifiers.None,
                clickCount    = 0,
                delta         = Vector2.zero,
            };
            sceneView.SendEvent(e);

            yield return(null);

            const int k_ExtrudeCount = 100;
            for (int i = 0; i < k_ExtrudeCount; i++)
            {
                // Press down at the center of the face
                e = new UnityEngine.Event()
                {
                    type          = EventType.MouseDown,
                    mousePosition = mousePos,
                    modifiers     = EventModifiers.None,
                    clickCount    = 1,
                    delta         = Vector2.zero,
                };
                sceneView.SendEvent(e);

                // Do lateral 1px drag and release
                var mouseDelta = new Vector2(i % 2 == 0 ? 1f : -1f, 0f);
                mousePos += mouseDelta;

                e.type          = EventType.MouseDrag;
                e.mousePosition = mousePos;
                e.modifiers     = EventModifiers.Shift;
                e.clickCount    = 0;
                e.delta         = mouseDelta;
                sceneView.SendEvent(e);

                e.type          = EventType.MouseUp;
                e.mousePosition = mousePos;
                e.delta         = Vector2.zero;
                sceneView.SendEvent(e);

                yield return(null);
            }

            // Check that our face count is correct after all extrusions
            Assume.That(pb.facesInternal.Length, Is.EqualTo(k_ExtrudeCount * 4 + 1));

            // We should have the last extruded face in selection
            var postExtrudeSelectedFaces = pb.GetSelectedFaces();
            Assume.That(postExtrudeSelectedFaces.Length, Is.EqualTo(1));
            var lastExtrudedFace = postExtrudeSelectedFaces[0];
            var faceVertices     = pb.GetVertices(lastExtrudedFace.indexes);

            // After many orthogonal extrusions, the last face should still be at y=0 coordinate
            for (int i = 0; i < faceVertices.Length; i++)
            {
                Assert.That(faceVertices[i].position.y, Is.EqualTo(0f));
            }
        }
        finally
        {
            UObject.DestroyImmediate(pb.gameObject);
        }
    }