public static void ApplyProperties(ShapeComponent shape, Vector3 newCenterPosition, Vector3 newSize)
        {
            var bounds = new Bounds();

            bounds.center = newCenterPosition;
            bounds.size   = newSize;

            UndoUtility.RecordComponents <Transform, ProBuilderMesh, ShapeComponent>(shape.GetComponents(typeof(Component)), "Resize Shape");
            shape.UpdateBounds(bounds);

            ProBuilderEditor.Refresh(false);
        }
        public void DrawShapeParametersGUI(DrawShapeTool tool = null)
        {
            if (target == null || serializedObject == null)
            {
                return;
            }

            serializedObject.Update();

            var foldoutEnabled = tool == null ? s_foldoutEnabled : DrawShapeTool.s_SettingsEnabled.value;

            foldoutEnabled = EditorGUILayout.Foldout(foldoutEnabled, m_ShapePropertyLabel, true);

            if (tool == null)
            {
                s_foldoutEnabled = foldoutEnabled;
            }
            else
            {
                DrawShapeTool.s_SettingsEnabled.value = foldoutEnabled;
            }

            if (foldoutEnabled)
            {
                EditorGUI.indentLevel++;

                EditorGUI.BeginChangeCheck();
                m_ActiveShapeIndex = HasMultipleShapeTypes
                    ? -1
                    : Mathf.Max(-1, Array.IndexOf(EditorShapeUtility.availableShapeTypes, m_CurrentShapeType));
                m_ActiveShapeIndex = EditorGUILayout.Popup(m_ActiveShapeIndex, EditorShapeUtility.shapeTypes);

                if (EditorGUI.EndChangeCheck())
                {
                    var type = EditorShapeUtility.availableShapeTypes[m_ActiveShapeIndex];
                    foreach (var comp in targets)
                    {
                        ShapeComponent shapeComponent = ((ShapeComponent)comp);
                        Shape          shape          = shapeComponent.shape;
                        if (shape.GetType() != type)
                        {
                            if (tool != null)
                            {
                                DrawShapeTool.s_ActiveShapeIndex.value = m_ActiveShapeIndex;
                            }
                            UndoUtility.RecordComponents <Transform, ProBuilderMesh, ShapeComponent>(shapeComponent.GetComponents(typeof(Component)), "Change Shape");
                            shapeComponent.SetShape(EditorShapeUtility.CreateShape(type), shapeComponent.pivotLocation);
                            ProBuilderEditor.Refresh();
                        }
                    }
                }

                if (tool)
                {
                    EditorGUILayout.PropertyField(m_ShapePivotProperty, k_ShapePivotLabel);
                }

                EditorGUILayout.PropertyField(m_ShapeSizeXProperty, k_ShapeSizeXLabel);
                if (HasMultipleShapeTypes || (m_CurrentShapeType != typeof(Plane) && m_CurrentShapeType != typeof(Sprite)))
                {
                    EditorGUILayout.PropertyField(m_ShapeSizeYProperty, k_ShapeSizeYLabel);
                }
                EditorGUILayout.PropertyField(m_ShapeSizeZProperty, k_ShapeSizeZLabel);

                EditorGUI.indentLevel--;
            }

            if (!HasMultipleShapeTypes)
            {
                EditorGUILayout.PropertyField(m_ShapeProperty, new GUIContent("Shape Properties"), true);
            }

            if (serializedObject.ApplyModifiedProperties())
            {
                foreach (var comp in targets)
                {
                    var shapeComponent = comp as ShapeComponent;
                    if (shapeComponent.isEditable)
                    {
                        UndoUtility.RecordComponents <Transform, ProBuilderMesh, ShapeComponent>(shapeComponent.GetComponents(typeof(Component)), "Resize Shape");
                        shapeComponent.UpdateComponent();
                        if (tool != null)
                        {
                            tool.SetBounds(shapeComponent.size);
                            DrawShapeTool.SaveShapeParams(shapeComponent);
                        }
                        ProBuilderEditor.Refresh();
                    }
                }
            }

            GUI.enabled = true;
        }
        static void DoOrientationHandlesGUI(ShapeComponent shapeComponent, bool updatePrefs)
        {
            if (GUIUtility.hotControl != 0 && !s_OrientationControlIDs.Contains(GUIUtility.hotControl))
            {
                return;
            }

            foreach (var f in Faces)
            {
                if (f.IsVisible && EditorShapeUtility.PointerIsInFace(f))
                {
                    if (DoOrientationHandle(f, shapeComponent))
                    {
                        UndoUtility.RecordComponents <Transform, ProBuilderMesh, ShapeComponent>(shapeComponent.GetComponents(typeof(Component)), "Rotate Shape");
                        shapeComponent.RotateInsideBounds(s_ShapeRotation);

                        ProBuilderEditor.Refresh();

                        if (updatePrefs)
                        {
                            DrawShapeTool.SaveShapeParams(shapeComponent);
                        }
                    }
                }
            }
        }