Skip to content

Commit b614fd5

Browse files
author
Karl Henkel
authored
Merge branch 'master' into uni-9224-docs-pb5
2 parents db5243c + 4983452 commit b614fd5

26 files changed

Lines changed: 174165 additions & 255 deletions

CHANGELOG.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
* Updated documentation for v5.0.0.
1313

14+
### Changes
15+
16+
- Add `GameObject/ProBuilder` menu to create primitives with default dimensions.
17+
18+
## [5.0.0-pre.12] - 2021-03-05
19+
20+
### Bug Fixes
21+
22+
- [case: 1317773] Fixing undo after shape creation.
23+
- Fixed shape creation requiring two undos to remove new shape.
24+
- Fixed shape preview flickering when executing shortcut to redo.
25+
- Fixed new shapes instantiating with generic "Shape" name instead of the primitive name.
26+
27+
## [5.0.0-pre.11] - 2021-02-25
28+
1429
### Bug Fixes
1530

16-
- [case: 1317148] Fixing edge picking problem with some Unity versions.
31+
- [case: 1317148] Fixing edge picking problem with some Unity versions.
1732
- [case: 1312537] Fixing script stripping on disabled objects when building.
1833
- [case: 1311258] Fixing material reverting when subdividing edge.
1934
- Added Particle System and IMGUI modules as a dependency.
@@ -26,7 +41,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2641
- Added Point-to-point Cut tool.
2742
- Added a selection preview when using the Select Path tool.
2843
- Added `Selection X Ray` option to highlight occluded element selections with a muted color. Default shortcut is `Alt + Shift + X` (modifiable in Shortcut Manager).
29-
- MergeElements.Merge moved to public API
3044
- Added Analytics for Actions and Menu Shortcuts
3145

3246
### Bug Fixes
@@ -67,7 +81,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6781
- [case: 1285654] Fixed selected faces highlight for isometric camera mode in sceneview.
6882
- [case: 1286045] Fixed selection cleaning problem after scene restart.
6983
- [case: 1266769] Fixed tooltip window not rendering correctly on Linux.
70-
- [case: 1281658] Fixed warning when modifying a PBMesh with particule effect using PBMesh as shape emitter.
84+
- [case: 1281658] Fixed warning when modifying a PBMesh with particule effect using PBMesh as shape emitter.
7185

7286
### Changes
7387

Editor/EditorCore/CutTool.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ void OnEnable()
167167
{
168168
m_IconContent = new GUIContent()
169169
{
170-
image = IconUtility.GetIcon("Tools/PolyShape/CreatePolyShape"),
170+
//image = IconUtility.GetIcon("Tools/PolyShape/CreatePolyShape"),
171+
image = IconUtility.GetIcon("Toolbar/CutTool"),
171172
text = "Cut Tool",
172173
tooltip = "Cut Tool"
173174
};
@@ -197,7 +198,7 @@ void OnDisable()
197198
{
198199
Undo.undoRedoPerformed -= UndoRedoPerformed;
199200

200-
ExecuteCut();
201+
ExecuteCut(false);
201202
Clear();
202203
}
203204

@@ -218,6 +219,8 @@ void Clear()
218219
m_SelectedEdges = null;
219220

220221
EditorHandleDrawing.ClearHandles();
222+
223+
ProBuilderEditor.Refresh();
221224
}
222225

223226
/// <summary>
@@ -369,9 +372,7 @@ void OnOverlayGUI(UObject target, SceneView view)
369372
if(m_Mesh == null)
370373
{
371374
if(GUILayout.Button(EditorGUIUtility.TrTextContent("Start")))
372-
{
373375
UpdateTarget();
374-
}
375376

376377
if(GUILayout.Button(EditorGUIUtility.TrTextContent("Quit")))
377378
{
@@ -383,8 +384,12 @@ void OnOverlayGUI(UObject target, SceneView view)
383384
{
384385
if(GUILayout.Button(EditorGUIUtility.TrTextContent("Complete")))
385386
ExecuteCut();
387+
386388
if(GUILayout.Button(EditorGUIUtility.TrTextContent("Cancel")))
389+
{
387390
Clear();
391+
ToolManager.RestorePreviousTool();
392+
}
388393
}
389394
}
390395

@@ -717,10 +722,13 @@ internal void UpdateMeshConnections()
717722
/// <summary>
718723
/// Compute the cut result and display a notification
719724
/// </summary>
720-
void ExecuteCut()
725+
void ExecuteCut(bool restorePrevious = true)
721726
{
722727
ActionResult result = DoCut();
723728
EditorUtility.ShowNotification(result.notification);
729+
730+
if(restorePrevious)
731+
ToolManager.RestorePreviousTool();
724732
}
725733

726734
/// <summary>
@@ -811,6 +819,7 @@ internal ActionResult DoCut()
811819
//Update mesh selection after the cut has been performed
812820
MeshSelection.ClearElementSelection();
813821
m_Mesh.SetSelectedFaces(newFaces);
822+
ProBuilderEditor.Refresh();
814823

815824
Clear();
816825

Editor/EditorCore/DrawShapeTool.cs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using UnityEditor.EditorTools;
3+
using UnityEditor.SettingsManagement;
34
using UnityEngine;
45
using UnityEngine.ProBuilder;
56
using UnityEngine.ProBuilder.Shapes;
@@ -42,12 +43,17 @@ class DrawShapeTool : EditorTool
4243

4344
static readonly GUIContent k_ShapeTitle = new GUIContent("Create Shape");
4445

46+
[UserSetting]
4547
internal static Pref<int> s_ActiveShapeIndex = new Pref<int>("ShapeBuilder.ActiveShapeIndex", 0);
46-
public static Pref<bool> s_SettingsEnabled = new Pref<bool>("ShapeComponent.SettingsEnabled", false);
48+
public static Pref<bool> s_SettingsEnabled = new Pref<bool>("ShapeComponent.SettingsEnabled", false, SettingsScope.Project);
4749

50+
[UserSetting]
4851
internal static Pref<int> s_LastPivotLocation = new Pref<int>("ShapeBuilder.LastPivotLocation", (int)PivotLocation.FirstCorner);
52+
[UserSetting]
4953
internal static Pref<Vector3> s_LastPivotPosition = new Pref<Vector3>("ShapeBuilder.LastPivotPosition", Vector3.zero);
54+
[UserSetting]
5055
internal static Pref<Vector3> s_LastSize = new Pref<Vector3>("ShapeBuilder.LastSize", Vector3.one);
56+
[UserSetting]
5157
internal static Pref<Quaternion> s_LastRotation = new Pref<Quaternion>("ShapeBuilder.LastRotation", Quaternion.identity);
5258

5359
int m_ControlID;
@@ -108,7 +114,8 @@ void OnEnable()
108114

109115
m_IconContent = new GUIContent()
110116
{
111-
image = IconUtility.GetIcon("Tools/ShapeTool/Arch"),
117+
//image = IconUtility.GetIcon("Tools/ShapeTool/Arch"),
118+
image = IconUtility.GetIcon("Toolbar/Panel_Shapes"),
112119
text = "Shape Settings",
113120
tooltip = "Shape Settings"
114121
};
@@ -233,7 +240,7 @@ internal void SetBounds(Vector3 size)
233240

234241
internal void DuplicatePreview(Vector3 position)
235242
{
236-
if(position.Equals(Vector3.positiveInfinity))
243+
if(position.Equals(Vector3.positiveInfinity) || !Event.current.isMouse)
237244
return;
238245

239246
var pivotLocation = (PivotLocation)s_LastPivotLocation.value;
@@ -269,9 +276,11 @@ internal void DuplicatePreview(Vector3 position)
269276
}
270277

271278
ProBuilderShape proBuilderShape;
279+
272280
if(m_DuplicateGO == null)
273281
{
274-
proBuilderShape = ShapeFactory.Instantiate(activeShapeType, ( (PivotLocation)s_LastPivotLocation.value )).GetComponent<ProBuilderShape>();
282+
var instantiated = ShapeFactory.Instantiate(activeShapeType, ((PivotLocation)s_LastPivotLocation.value));
283+
proBuilderShape = instantiated.GetComponent<ProBuilderShape>();
275284
m_DuplicateGO = proBuilderShape.gameObject;
276285
m_DuplicateGO.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
277286
ApplyPrefsSettings(proBuilderShape);
@@ -327,7 +336,10 @@ internal void RebuildShape()
327336
EditorShapeUtility.CopyLastParams(shapeComponent.shape, shapeComponent.shape.GetType());
328337
shapeComponent.gameObject.hideFlags = HideFlags.HideInHierarchy;
329338
shapeComponent.mesh.renderer.sharedMaterial = EditorMaterialUtility.GetUserMaterial();
339+
shapeComponent.rotation = Quaternion.identity;
340+
shapeComponent.gameObject.name = EditorShapeUtility.GetName(shapeComponent.shape);
330341
UndoUtility.RegisterCreatedObjectUndo(shapeComponent.gameObject, "Draw Shape");
342+
EditorUtility.InitObject(shapeComponent.mesh);
331343
m_IsShapeInit = true;
332344
}
333345

@@ -389,7 +401,7 @@ void OnOverlayGUI(UObject overlayTarget, SceneView view)
389401
if(snapDisabled)
390402
EditorGUILayout.Toggle("Snapping (only Global)", false);
391403
else
392-
EditorSnapSettings.gridSnapEnabled = EditorGUILayout.Toggle("Snapping", EditorSnapSettings.gridSnapEnabled);
404+
EditorSnapSettings.gridSnapEnabled = EditorGUILayout.Toggle("Grid Snapping", EditorSnapSettings.gridSnapEnabled);
393405
}
394406
#endif
395407

@@ -406,13 +418,29 @@ void OnOverlayGUI(UObject overlayTarget, SceneView view)
406418
}
407419
}
408420

421+
void ResetPrefs()
422+
{
423+
var type = EditorShapeUtility.availableShapeTypes[s_ActiveShapeIndex];
424+
if(currentShapeInOverlay == m_LastShapeCreated)
425+
m_LastShapeCreated = null;
426+
427+
UndoUtility.RegisterCompleteObjectUndo(currentShapeInOverlay, "Change Shape");
428+
currentShapeInOverlay.SetShape(EditorShapeUtility.CreateShape(type), currentShapeInOverlay.pivotLocation);
429+
SetBounds(currentShapeInOverlay.size);
430+
431+
ProBuilderEditor.Refresh();
432+
}
433+
409434
void DrawShapeGUI()
410435
{
411436
if(m_BoldCenteredStyle == null)
412437
m_BoldCenteredStyle = new GUIStyle("BoldLabel") { alignment = TextAnchor.MiddleCenter };
413438

414439
EditorGUILayout.LabelField(EditorShapeUtility.shapeTypes[s_ActiveShapeIndex.value], m_BoldCenteredStyle, GUILayout.ExpandWidth(true));
415440

441+
if(EditorShapeUtility.s_ResetUserPrefs.value)
442+
ResetPrefs();
443+
416444
var shape = currentShapeInOverlay.shape;
417445

418446
int groupCount = EditorShapeUtility.shapeTypesGUI.Count;

0 commit comments

Comments
 (0)