Search Unity

Create an Time.TimeScale editor

Discussion in 'Editor & General Support' started by usernameHed, Aug 21, 2019.

  1. usernameHed

    usernameHed

    Joined:
    Apr 5, 2016
    Posts:
    93
    Hello, I am doing a lot of editor tools, I need to be able to do slow motion of some action in the scene in Editor, NOT in play mode (moving objects, cameras...)

    For a basic exemple, I want to do a transition of an abject to one place to another, in 2 secondes.
    I want to be able to control the TimeScale, from 0 to 1, do visualize better my situation.

    So... How can I do a EditorTime.TimeScale ?

    I have done my own custom timer, who work both in edtior AND in play:

    - In play, for starting a Chrono:
    Code (CSharp):
    1. _timeStart = Time.fixedTime;
    - In play, for get time of the Chrono:
    Code (CSharp):
    1.  currentTime = Time.fixedTime - _timeStart;
    - In Editor, for starting a Chrono:
    Code (CSharp):
    1. _timeStart = EditorApplication.timeSinceStartup;
    - In Editor, for get time of the Chrono:
    Code (CSharp):
    1. currentTime = EditorApplication.timeSinceStartup - _timeStart;
    This timer working, I would like now to add some sort of timeScale for this...
    It automaticly works in Play mode with different timeScale, but not in Editor of course, it doesn't, because EditorApplication.timeSinceStartup is not related to the game time.


    How could I do it ?
    Thank you !