Time Rewizer  v.1.1
Created by: Mark Oostveen
MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility Class Reference

Class used to contain functions needed accross custom editors for time rewinding More...

+ Collaboration diagram for MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility:

Public Types

enum  AssetType { AssetType.Bake, AssetType.Settings }
 Type of asset More...
 
enum  SettingType { SettingType.Animation, SettingType.PositionRotation }
 Setting types More...
 

Static Public Member Functions

static T CreateScriptableSettings< T > (string defaultName)
 Creates a scriptable settings object in the asset folder More...
 
static ScriptableBake Createbake (string name)
 Creates new time rewinding asset More...
 
static T CreateScriptableCache< T > (string defaultName, string type)
 Creates a scriptable cache object inside the asset folder More...
 
static ScriptableBake GetBake (string name)
 Get Asset based on name and current scene More...
 
static T GetSetting< T > (string name)
 Get Asset based on name and current scene More...
 
static T GetCacheobj< T > (string name, string type)
 Get Cache objects More...
 
static T1 GetCache< T1 > (GameObject linkedObject, string type)
 Get Cache from given type if cache isn't created this function will create a cache More...
 
static void DestroyAsset (Object input)
 Destroy asset from asset database More...
 
static void DestroyAsset (string path)
 Destroy asset from asset database More...
 
static string Assetpathbakes (string name)
 Get bake Path to Object of name More...
 
static string AssetPathSettings (string name)
 Get setting Path to Object of name More...
 
static string AssetPathHierachyCache (string name, string typeName)
 Get cache Path to Object of name More...
 
static void InitializeScriptableobject (ObjectSerializer[] preloadinfo, GameObject linkedobject, ScriptableBake scriptableobject, Type snapshottype, string tag)
 will set contents of scriptableobject and will bind all compatible rewinding assets to this scriptableobject More...
 
static void Clean (IBaker target, GameObject gameobject, ScriptableBake scriptableobject, Type baketype, string tag)
 Cleans current gameobject of scriptableobject data, attached to the target More...
 
static void SaveScene ()
 Save Current Active Scene More...
 
static T SingletonWindow< T > ()
 Get the singleton window of window type More...
 
static T StartWindow< T, T1, T2 > (string scriptableSettingsName, T1 attachedscript, Action startupAction, Action ClearBakeCallBack)
 T is output window T1 is input for attached baker script T2 is settings that need to be used for this window More...
 
static void StartStopRecording< T, T1, T2, T3 > (T1 window, GameObject attachedobj)
 T: SnapshotType T1: Recorder type and type of window T2: Baker Type T3 ComponentType More...
 
static bool CheckRecordingState< T0 > (string settingsscriptableobjectname)
 Check recording checkmark of a settings object More...
 
static bool CheckActiveState< T0 > (string settingsscriptableobjectname)
 Returns if settings script indicates it needs to be started on launch More...
 
static void SaveDirtyObject (Object obj)
 Save changes to a scriptable object More...
 
static ScriptableBake ReturnBakeForBaker (IBaker baker)
 GetScriptabletime object from IBaker More...
 

Static Public Attributes

static string IconPath => "Assets/Plugins/Time Rewizer/Editor/Icons/"
 Get path where editor icons are stored More...
 
static readonly Sprite m_RecordingImage
 Get Recording Image More...
 
static ScriptableBake bake
 Starts window of given type. please give all listed types below to setup editor window for baking T0: Type of window being outputted T1: Baker type used T2: Type of Cache Object used T3: Setting type being used T4: Properties type Used by baker T5: Properties type being used to save data by Cache object More...
 

Detailed Description

Class used to contain functions needed accross custom editors for time rewinding

Member Enumeration Documentation

◆ AssetType

Type of asset

Enumerator
Bake 

Rewinding Bake

Settings 

Settings for editor window

9  {
13  Bake,
14 
18  Settings,
19  }

◆ SettingType

Setting types

Enumerator
Animation 

Animation Editor Window

PositionRotation 

Position Rotation Editor Window

25  {
29  Animation,
30 
34  PositionRotation
35  }

Member Function Documentation

◆ Assetpathbakes()

static string MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.Assetpathbakes ( string  name)
static

Get bake Path to Object of name

Parameters
name
Returns
18  {
19  EditorRewizeSystemUtility.StripUnwantedCharacters(ref name);
20  string scenename = SceneManager.GetActiveScene().name;
21  EditorRewizeSystemUtility.StripUnwantedCharacters(ref scenename);
22  return "Assets/Plugins/Time Rewizer/ProjectData/Bakes/" + scenename + "_" + name + ".asset";
23  }

◆ AssetPathHierachyCache()

static string MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.AssetPathHierachyCache ( string  name,
string  typeName 
)
static

Get cache Path to Object of name

Parameters
name
typeName
Returns
44  {
45  EditorRewizeSystemUtility.StripUnwantedCharacters(ref name);
46  EditorRewizeSystemUtility.StripUnwantedCharacters(ref typeName);
47  string scenename = SceneManager.GetActiveScene().name;
48  EditorRewizeSystemUtility.StripUnwantedCharacters(ref scenename);
49 
50  return "Assets/Plugins/Time Rewizer/ProjectData/Cache/Hierachy/" + name + "_" + scenename + "_" +
51  typeName + ".asset";
52  }

◆ AssetPathSettings()

static string MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.AssetPathSettings ( string  name)
static

Get setting Path to Object of name

Parameters
name
Returns
31  {
32  EditorRewizeSystemUtility.StripUnwantedCharacters(ref name);
33 
34  return "Assets/Plugins/Time Rewizer/ProjectData/EditorSettings/" + name + ".asset";
35  }

◆ CheckActiveState< T0 >()

static bool MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.CheckActiveState< T0 > ( string  settingsscriptableobjectname)
static

Returns if settings script indicates it needs to be started on launch

Template Parameters
T0
Parameters
settingsscriptableobjectname
Returns
Type Constraints
T0 :ScriptableObject 
T0 :ISetting 
204  : ScriptableObject, ISetting
205  {
206  T0 settings = GetSetting<T0>(settingsscriptableobjectname);
207 
208  return settings.Active;
209  }

◆ CheckRecordingState< T0 >()

static bool MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.CheckRecordingState< T0 > ( string  settingsscriptableobjectname)
static

Check recording checkmark of a settings object

Template Parameters
T0
Parameters
settingsscriptableobjectname
Returns
Type Constraints
T0 :ScriptableObject 
T0 :ISetting 
190  : ScriptableObject, ISetting
191  {
192  T0 settings = GetSetting<T0>(settingsscriptableobjectname);
193 
194  return settings.Recording;
195  }

◆ Clean()

static void MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.Clean ( IBaker  target,
GameObject  gameobject,
ScriptableBake  scriptableobject,
Type  baketype,
string  tag 
)
static

Cleans current gameobject of scriptableobject data, attached to the target

Parameters
target
gameobject
scriptableobject
baketype
tag
44  {
45  if (target.BaseBaker.m_Scriptable != null)
46  {
47  ScriptableBakeExtention.InitializePreRewindAbleGameObject(gameobject,
48  ScriptableBakeExtention.FieldActionOption.Clear, scriptableobject, baketype, tag);
49  SaveDirtyObject(gameobject);
50  SaveDirtyObject(scriptableobject);
51  SaveScene();
52  }
53  else
54  {
55  Debug.Log("Nothing Baked, nothing to clear");
56  }
57  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Createbake()

static ScriptableBake MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.Createbake ( string  name)
static

Creates new time rewinding asset

Parameters
name
31  {
33 
34  ScriptableBake instance = ScriptableObject.CreateInstance<ScriptableBake>();
35  AssetDatabase.CreateAsset(instance, Assetpathbakes(name));
36  AssetDatabase.SaveAssets();
37  return instance;
38  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateScriptableCache< T >()

static T MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.CreateScriptableCache< T > ( string  defaultName,
string  type 
)
static

Creates a scriptable cache object inside the asset folder

Template Parameters
T
Parameters
defaultName
type
Returns
Type Constraints
T :ScriptableObject 
T :ICache 
47  : ScriptableObject, ICache
48  {
50 
51  T instance = ScriptableObject.CreateInstance<T>();
52 
53  AssetDatabase.CreateAsset(instance, AssetPathHierachyCache(defaultName, type));
54  AssetDatabase.SaveAssets();
55  return instance;
56  }
+ Here is the call graph for this function:

◆ CreateScriptableSettings< T >()

static T MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.CreateScriptableSettings< T > ( string  defaultName)
static

Creates a scriptable settings object in the asset folder

Template Parameters
T
Parameters
defaultName
Returns
Type Constraints
T :ScriptableObject 
15  : ScriptableObject
16  {
18 
19  ScriptableObject instance = ScriptableObject.CreateInstance<T>();
20 
21  AssetDatabase.CreateAsset(instance, AssetPathSettings(defaultName));
22  AssetDatabase.SaveAssets();
23  return (T)instance;
24  }
+ Here is the call graph for this function:

◆ DestroyAsset() [1/2]

static void MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.DestroyAsset ( Object  input)
static

Destroy asset from asset database

Parameters
input
129  {
131 
132  DestroyAsset(AssetDatabase.GetAssetPath(input));
133  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DestroyAsset() [2/2]

static void MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.DestroyAsset ( string  path)
static

Destroy asset from asset database

Parameters
path
140  {
142 
143  AssetDatabase.DeleteAsset(path);
144  }
+ Here is the call graph for this function:

◆ GetBake()

static ScriptableBake MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.GetBake ( string  name)
static

Get Asset based on name and current scene

Parameters
name
Returns
64  {
66 
67  return (ScriptableBake)AssetDatabase.LoadAssetAtPath(Assetpathbakes(name),
68  typeof(ScriptableBake));
69  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCache< T1 >()

static T1 MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.GetCache< T1 > ( GameObject  linkedObject,
string  type 
)
static

Get Cache from given type if cache isn't created this function will create a cache

Template Parameters
T1
Parameters
linkedObject
type
Returns
Type Constraints
T1 :ScriptableObject 
T1 :ICache 
108  : ScriptableObject, ICache
109 
110  {
112 
113  //Get Corresponding cache
114  T1 cache = EditorRewizeSystemUtility.GetCacheobj<T1>(linkedObject.name, type);
115  if (cache == null && !Application.isPlaying)
116  {
117  EditorRewizerDebug.Log("Can't find cache creating new cache of type " + typeof(T1));
118  cache = CreateScriptableCache<T1>(linkedObject.name, type);
119  }
120 
121  return cache;
122  }
+ Here is the call graph for this function:

◆ GetCacheobj< T >()

static T MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.GetCacheobj< T > ( string  name,
string  type 
)
static

Get Cache objects

Template Parameters
T
Parameters
name
type
Returns
Type Constraints
T :ScriptableObject 
T :ICache 
91  : ScriptableObject, ICache
92  {
94 
95  return (T)AssetDatabase.LoadAssetAtPath(AssetPathHierachyCache(name, type),
96  typeof(T));
97  }
+ Here is the call graph for this function:

◆ GetSetting< T >()

static T MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.GetSetting< T > ( string  name)
static

Get Asset based on name and current scene

Template Parameters
T
Parameters
name
Returns
Type Constraints
T :ScriptableObject 
T :ISetting 
77  : ScriptableObject, ISetting
78  {
80 
81  return (T)AssetDatabase.LoadAssetAtPath(AssetPathSettings(name), typeof(T));
82  }
+ Here is the call graph for this function:

◆ InitializeScriptableobject()

static void MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.InitializeScriptableobject ( ObjectSerializer []  preloadinfo,
GameObject  linkedobject,
ScriptableBake  scriptableobject,
Type  snapshottype,
string  tag 
)
static

will set contents of scriptableobject and will bind all compatible rewinding assets to this scriptableobject

Parameters
preloadinfo
linkedobject
scriptableobject
snapshottype
tag
25  {
26  ScriptableBakeExtention.InitializePreRewindAbleGameObject(linkedobject,
27  ScriptableBakeExtention.FieldActionOption.Fill, scriptableobject, snapshottype, tag);
28  scriptableobject.SetContents(preloadinfo);
29  SaveDirtyObject(linkedobject);
30  SaveDirtyObject(scriptableobject);
31  SaveScene();
32  AssetDatabase.SaveAssets();
33  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReturnBakeForBaker()

static ScriptableBake MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.ReturnBakeForBaker ( IBaker  baker)
static

GetScriptabletime object from IBaker

Parameters
baker
Returns
25  {
26  return baker.BaseBaker.m_Scriptable;
27  }
+ Here is the caller graph for this function:

◆ SaveDirtyObject()

static void MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.SaveDirtyObject ( Object  obj)
static

Save changes to a scriptable object

Parameters
obj
13  {
14  SerializedObject serialized = new SerializedObject(obj);
15  EditorUtility.SetDirty(obj);
16  serialized.ApplyModifiedPropertiesWithoutUndo();
17  }
+ Here is the caller graph for this function:

◆ SaveScene()

static void MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.SaveScene ( )
static

Save Current Active Scene

63  {
64  EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
65  }
+ Here is the caller graph for this function:

◆ SingletonWindow< T >()

static T MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.SingletonWindow< T > ( )
static

Get the singleton window of window type

Template Parameters
T
Returns
Type Constraints
T :EditorWindow 
93  : EditorWindow
94  {
95  EditorRewizerDebug.Log("Getting Window of type: " + typeof(T));
96 
97  T[] windows = Resources.FindObjectsOfTypeAll<T>();
98 
99  return windows.Length > 0 ? windows[0] : null;
100  }
+ Here is the call graph for this function:

◆ StartStopRecording< T, T1, T2, T3 >()

static void MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.StartStopRecording< T, T1, T2, T3 > ( T1  window,
GameObject  attachedobj 
)
static

T: SnapshotType T1: Recorder type and type of window T2: Baker Type T3 ComponentType

Template Parameters
T
T1
T2
T3
Parameters
window
attachedobj
Type Constraints
T :ISnapShot 
T1 :IRecorder<T> 
T1 :IBakeWindow<T2> 
T2 :MonoBehaviour 
T2 :IBaker 
T3 :MonoBehaviour 
T3 :IRecordAble<T> 
163  : ISnapShot
164  where T1 : IRecorder<T>, IBakeWindow<T2>
165  where T2 : MonoBehaviour, IBaker
166  where T3 : MonoBehaviour, IRecordAble<T>
167  {
168  if (window.Recording && Application.isPlaying)
169  {
170  EditorRewizerDebug.Log("Initialized Recording on " + attachedobj.name, attachedobj.transform);
171  //subscribe
172  T3 rewinding = attachedobj.GetComponent<T3>();
173  rewinding.OnTracked += window.Record;
174  }
175  else if (!Application.isPlaying)
176  {
177  //desubscribe
178  T3 rewinding = attachedobj.GetComponent<T3>();
179  rewinding.OnTracked -= window.Record;
180  }
181  }
+ Here is the call graph for this function:

◆ StartWindow< T, T1, T2 >()

static T MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.StartWindow< T, T1, T2 > ( string  scriptableSettingsName,
T1  attachedscript,
Action  startupAction,
Action  ClearBakeCallBack 
)
static

T is output window T1 is input for attached baker script T2 is settings that need to be used for this window

Template Parameters
T
T1
T2
Parameters
scriptableSettingsName
attachedscript
Returns
Type Constraints
T :EditorWindow 
T :IBakeWindow<T1> 
T1 :MonoBehaviour 
T1 :IBaker 
T2 :ScriptableObject 
T2 :ISetting 
114  : EditorWindow, IBakeWindow<T1>
115  where T1 : MonoBehaviour, IBaker
116  where T2 : ScriptableObject, ISetting
117  {
118  EditorRewizerDebug.Log("Obtaining Window Settings of type " + typeof(T2));
119 
120  T2 scriptableobjectinstance = GetSetting<T2>(scriptableSettingsName);
121 
122  if (scriptableobjectinstance == null)
123  {
124  EditorRewizerDebug.Log("Can't find settings of: " + typeof(T2) + " creating a new one...");
125  scriptableobjectinstance = CreateScriptableSettings<T2>(scriptableSettingsName);
126  }
127 
128  T window = SingletonWindow<T>();
129 
130  if (window == null)
131  {
132  EditorRewizerDebug.Log("No Window Active of type " + typeof(T) + ", instantiating a new one.");
133  window = EditorWindow.GetWindow<T>(true, scriptableSettingsName);
134  }
135 
136  EditorRewizerDebug.Log("Initializing Window of type " + typeof(T));
137 
138  window.titleContent = new GUIContent(scriptableSettingsName);
139  window.Initialize(attachedscript);
140  if (window is IRecorder)
141  ((IRecorder)window).Recording = scriptableobjectinstance.Recording;
142 
143  window.Clear = ClearBakeCallBack;
144  window.WindowStartup(startupAction);
145  window.Show();
146 
147  return window;
148  }
+ Here is the call graph for this function:

Member Data Documentation

◆ bake

ScriptableBake MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.bake
static

Starts window of given type. please give all listed types below to setup editor window for baking T0: Type of window being outputted T1: Baker type used T2: Type of Cache Object used T3: Setting type being used T4: Properties type Used by baker T5: Properties type being used to save data by Cache object

Template Parameters
T0
T1
T2
T3
T4
T5
Parameters
scriptableSettingsName
bakertarget
type
conversionMethod
loadOverwrite
Returns

◆ IconPath

string MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.IconPath => "Assets/Plugins/Time Rewizer/Editor/Icons/"
static

Get path where editor icons are stored

◆ m_RecordingImage

readonly Sprite MarkOostveen.TimeRewizer.Editor.Baking.EditorRewizeSystemUtility.m_RecordingImage
static

Get Recording Image