JetBrains / JetBrains/resharper-unity

An action to restart the game in Unity

Open
#618 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

Something that can be mapped to a shortcut. Here is how I implemented in Unity using a short editor script..

public static class ReplayGameMenuItem
{
private static bool isDisabled;

[MenuItem("Tools/Re-play Game _F5")]
public static void MenuItem()
{
if (isDisabled)
return;

if (EditorApplication.isPlaying)
{
EditorApplication.isPlaying = false;
EditorApplication.playModeStateChanged += StateChanged;
} else
{
EditorApplication.isPlaying = true;
}

isDisabled = true;
}

private static void StateChanged(PlayModeStateChange change)
{
if (change == PlayModeStateChange.EnteredEditMode)
{
EditorApplication.isPlaying = true;
isDisabled = false;
EditorApplication.playModeStateChanged -= StateChanged;
}
}
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.