Skip to content

Commit 5c6058c

Browse files
authored
[UUM-131032] Coreclr - fast enter playmode (#666)
* builtin mat and csg files changes * Updating Poly2Tri for fast enter playmode * fast enter playmode for materials, log, normals * moving the rest of the runtime scripts to be compatible with fast enter playmode * update ShowHoveredInfo * Updating editor menu actions for fast enter playmode * Fixing overlay not showing on the first action * Adding Runtime Init on load attribute to reset editor scripts part.1 * switch attribute to InitializeOnEnterPlaymode for the editor only code * best support of fast entering playmode for editor scripts * fixing errors after fast enter playmode * fixing tools states on enter fast playmode * changelog * fix error on enter playmode * Fixing tools icons not loading properly when importing the package (#668) * remove old tests not used anymore
1 parent 6fbb737 commit 5c6058c

51 files changed

Lines changed: 595 additions & 456 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313

1414
### Changes
1515

16+
- [UUM-131032] Added a reset of static variables when entering playmode to allow fast enter playmode compatibility.
1617
- [UUM-138539] Removed the pb_ObjectArray file that was deprecated 8 years ago and is not used amymore.
1718
- [UUM-138960] Removed a large utility dictionary to reduce binary size and runtime memory overhead.
1819

Debug/Scripts/ShowHoveredInfo.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ public class ShowHoveredInfo : MonoBehaviour
1010
static Material m_Material;
1111
bool m_IsHovering;
1212

13+
#if UNITY_EDITOR
14+
[RuntimeInitializeOnLoadMethod]
15+
static void ResetStaticsOnLoad()
16+
{
17+
m_Material = null;
18+
}
19+
#endif
20+
1321
void Start()
1422
{
1523
if (m_Material == null)

Editor/EditorCore/CutTool.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
namespace UnityEditor.ProBuilder
2020
{
2121
[EditorTool("Cut Tool", typeof(ProBuilderMesh), typeof(PositionToolContext))]
22+
[Icon("Packages/com.unity.probuilder/Editor Default Resources/Icons/Toolbar/CutTool.png")]
2223
class CutTool : EditorTool
2324
{
2425
ProBuilderMesh m_Mesh;
@@ -85,12 +86,6 @@ public CutVertexData(Vector3 position, Vector3 normal, VertexTypes types = Verte
8586

8687
Color m_CurrentHandleColor = k_HandleColor;
8788

88-
GUIContent m_IconContent;
89-
public override GUIContent toolbarIcon
90-
{
91-
get { return m_IconContent; }
92-
}
93-
9489
//Handles and point placement
9590
int m_ControlId;
9691
bool m_PlacingPoint;
@@ -169,13 +164,6 @@ public override bool IsAvailable()
169164

170165
void OnEnable()
171166
{
172-
m_IconContent = new GUIContent()
173-
{
174-
image = IconUtility.GetIcon("Toolbar/CutTool"),
175-
text = "Cut Tool",
176-
tooltip = "Cut Tool"
177-
};
178-
179167
s_HandleColorUseExistingVertex = Handles.selectedColor;
180168
s_HandleColorAddVertexOnEdge = Handles.selectedColor;
181169

@@ -201,6 +189,7 @@ public override void OnActivated()
201189
Undo.undoRedoPerformed += UndoRedoPerformed;
202190
MeshSelection.objectSelectionChanged += UpdateTarget;
203191
ProBuilderEditor.selectModeChanged += OnSelectModeChanged;
192+
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
204193
}
205194

206195
public override void OnWillBeDeactivated()
@@ -210,6 +199,7 @@ public override void OnWillBeDeactivated()
210199
Undo.undoRedoPerformed -= UndoRedoPerformed;
211200
MeshSelection.objectSelectionChanged -= UpdateTarget;
212201
ProBuilderEditor.selectModeChanged -= OnSelectModeChanged;
202+
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
213203
}
214204

215205
/// <summary>
@@ -242,6 +232,16 @@ void ExitTool()
242232
ToolManager.RestorePreviousTool();
243233
}
244234

235+
private void OnPlayModeStateChanged(PlayModeStateChange state)
236+
{
237+
if (state == PlayModeStateChange.ExitingEditMode || state == PlayModeStateChange.ExitingPlayMode)
238+
{
239+
// Reset tool state when entering/exiting playmode
240+
if (ToolManager.IsActiveTool(this))
241+
ExitTool();
242+
}
243+
}
244+
245245
/// <summary>
246246
/// Undo/Redo callback: Reset and recompute lines, and update the targeted face if needed
247247
/// </summary>

0 commit comments

Comments
 (0)