public void Move()
        {
            Vector2 uv    = ManualUVRenderer.WorldToUV(m_pivotPoint.transform.position);
            Vector2 delta = uv - m_initialUV;

            Move(delta);
            m_prevPivotPoint = m_pivotPoint.transform.position;
        }
 private void Update()
 {
     if (m_prevPivotPoint != m_pivotPoint.position)
     {
         BeginMove();
         Vector2 uv    = ManualUVRenderer.WorldToUV(m_pivotPoint.transform.position);
         Vector2 delta = uv - ManualUVRenderer.WorldToUV(m_prevPivotPoint);
         Move(delta);
         m_prevPivotPoint = m_pivotPoint.transform.position;
     }
 }
Esempio n. 3
0
        private bool Raycast(out Vector2 uv)
        {
            float dinstance;
            Ray   ray = Window.Pointer;

            if (!m_plane.Raycast(ray, out dinstance))
            {
                uv = Vector2.zero;
                return(false);
            }

            uv = ManualUVRenderer.WorldToUV(ray.GetPoint(dinstance));
            return(true);
        }
Esempio n. 4
0
        private void OnBoxSelection(object sender, BoxSelectionArgs e)
        {
            Bounds  selectionBounds = m_selectionComponent.BoxSelection.SelectionBounds;
            Vector2 min             = ManualUVRenderer.WorldToUV(Window.Camera.ScreenToWorldPoint(selectionBounds.min));
            Vector2 max             = ManualUVRenderer.WorldToUV(Window.Camera.ScreenToWorldPoint(selectionBounds.max));

            switch (m_tool.Mode)
            {
            case ProBuilderToolMode.Vertex:
                m_uvEditor.SelectVertices(uv => (min.x <= uv.x && min.y <= uv.y && uv.x <= max.x && uv.y <= max.y) ? 0 : 1, false, !SelectMultipleAction());
                break;

            case ProBuilderToolMode.Face:
                m_uvEditor.SelectFaces(uv => (min.x <= uv.x && min.y <= uv.y && uv.x <= max.x && uv.y <= max.y) ? 0 : 1, false, !SelectMultipleAction());
                break;

            default:
                m_uvEditor.SelectEdges((uv0, uv1) => PBMath.Intersects(min, max, uv0, uv1) ? 0 : 1, false, !SelectMultipleAction());
                break;
            }

            m_uvEditor.RefreshPivotPoint();
        }
        public void Rotate()
        {
            Vector2 uv    = ManualUVRenderer.WorldToUV(m_pivotPoint.transform.position);
            float   angle = -m_pivotPoint.transform.eulerAngles.z;

            for (int i = 0; i < m_selection.Count; ++i)
            {
                ManualUVSelection selection = m_selection[i];
                PBMesh            mesh      = selection.Mesh;
                Vector2[]         textures  = mesh.Textures;
                foreach (int index in m_indexes[i])
                {
                    textures[index] = (m_initialUVs[i][index]).RotateAroundPoint(uv, angle);
                }
                mesh.Textures = textures;
                mesh.RefreshUV();
            }

            if (UVChanged != null)
            {
                UVChanged();
            }
        }
 public void BeginScale()
 {
     m_initialUV  = ManualUVRenderer.WorldToUV(m_pivotPoint.transform.position);
     m_initialUVs = m_selection.Select(s => s.Mesh.Textures.ToArray()).ToArray();
     GetIndexes();
 }