Last active
December 29, 2015 21:53
-
-
Save iwashihead/62fc2207fe7b2fb2cf8d to your computer and use it in GitHub Desktop.
[Unity][Editor]タイムスケールをショートカットキーで変更
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
非実行時に編集できるようにすると、gitにTimeScaleの変更を誤ってあげてしまうことがあったのでエディタ実行時のみ動くように変更