Skip to content

Instantly share code, notes, and snippets.

@iwashihead
Last active December 29, 2015 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iwashihead/62fc2207fe7b2fb2cf8d to your computer and use it in GitHub Desktop.
Save iwashihead/62fc2207fe7b2fb2cf8d to your computer and use it in GitHub Desktop.
[Unity][Editor]タイムスケールをショートカットキーで変更
using UnityEngine;
using UnityEditor;
/// <summary>
/// タイムスケールをショートカットキーで変更するコマンド
/// </summary>
public class ChangeTimeScale {
[MenuItem ("Window/TimeScale/ × 2 %#RIGHT")]
public static void TimeScale2X () {
if (!Application.isPlaying) return;
Time.timeScale *= 2;
Debug.Log("Time.timeScale = " + Time.timeScale);
}
[MenuItem ("Window/TimeScale/ ÷ 2 %#LEFT")]
public static void TimeScaleHalf () {
if (!Application.isPlaying) return;
Time.timeScale *= 0.5f;
Debug.Log("Time.timeScale = " + Time.timeScale);
}
[MenuItem ("Window/TimeScale/ + 0.1 %#UP")]
public static void TimeScalePlusLittle () {
if (!Application.isPlaying) return;
Time.timeScale += 0.1f;
Debug.Log("Time.timeScale = " + Time.timeScale);
}
[MenuItem ("Window/TimeScale/ - 0.1 %#DOWN")]
public static void TimeScaleMinusLittle () {
if (!Application.isPlaying) return;
Time.timeScale -= 0.1f;
Debug.Log("Time.timeScale = " + Time.timeScale);
}
[MenuItem ("Window/TimeScale/ Reset 1 %#0")]
public static void TimeScaleReset () {
if (!Application.isPlaying) return;
Time.timeScale = 1;
Debug.Log("Time.timeScale = " + Time.timeScale);
}
}
@iwashihead
Copy link
Author

主にデバッグで使用。
スローモーションや時間のかかる場面のスキップなど用途は結構あります。
Time.timeScaleをいじるので、ゲーム内の処理によってはバグることもあるので注意!

@iwashihead
Copy link
Author

非実行時に編集できるようにすると、gitにTimeScaleの変更を誤ってあげてしまうことがあったのでエディタ実行時のみ動くように変更

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment