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

Class managing transforms before bake in edit mode More...

+ Inheritance diagram for MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker:
+ Collaboration diagram for MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker:

Classes

class  NodeProperties
 Node properties for position rotation nodes More...
 
struct  SavedData
 Saved data of position rotation More...
 

Public Member Functions

void SaveChanges ()
 save changes to baker More...
 
void Load (List< SavedData > dataToExtract)
 Called by Time Rewind Editor to load game objects from Save File More...
 
NodeProperties Load (SavedData input)
 load properties of and create editor only gameobjects attached under the gameobject for displaying gizmos More...
 
SavedData CreateSaveData (NodeProperties input)
 Conversion from nodeproperties to saveddata More...
 
Transform AddNode (int index)
 will insert a new node into the nodelist More...
 
void CreateFindEditorNodesParent ()
 Create Parent Gameobject under gameobject target More...
 
NodeProperties AddNode (Vector3 position, Quaternion rotation)
 function used to create new node hierarchy from recording data More...
 
GameObject CreateGameobject (Vector3 position, Quaternion rotation)
 Create a gameobject for baker based on position and rotation More...
 
void DeleteNode (int index)
 Deletes node form hierarchy More...
 
int GetIndexOfNode (Transform input)
 Returns index of Transform More...
 
bool Contains (Transform input)
 check if hierarchy contains transform More...
 
NodeProperties GetProperties (Transform input)
 Get node properties from target input More...
 
void UpdateSelected (Transform newselection)
 Select New selected More...
 
int GetSelected (Transform selected)
 Get index of selected transform More...
 
void Clear ()
 Clear hierarchy More...
 
List< SavedDataCreateSavedDataList ()
 Create Hiararchy save list for cache More...
 

Public Attributes

bool m_Gizmos
 Gizmos setting More...
 
Transform m_NodeParent
 Parent for hierarchy nodes More...
 
Transform m_SelectedTransform
 selected transform More...
 

Protected Member Functions

void OnDestroy ()
 Called when destorying object in scene More...
 

Properties

Transform [] NodePositions [get]
 Get all node positions from Hierarchy More...
 
List< NodePropertiesSnapshots [get, set]
 Node in hierarchy More...
 
Action< string > Save [set]
 saving action More...
 
dynamic BaseBaker [get, set]
 Scriptableobject cache holder object from editor .dll More...
 

Detailed Description

Class managing transforms before bake in edit mode

Member Function Documentation

◆ AddNode() [1/2]

Transform MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.AddNode ( int  index)

will insert a new node into the nodelist

Parameters
index
Returns
158  {
159  GameObject newnode;
160  NodeProperties newproperties = new NodeProperties() { m_TransitionDuration = 60 };
161 
162  if (Snapshots.Count == 0)
163  {
164  newnode = CreateGameobject(m_NodeParent.transform.position, Quaternion.identity);
165 
166  newproperties.m_Transform = newnode.transform;
167  Snapshots.Add(newproperties);
168  }
169  else
170  {
171  newnode = CreateGameobject(Snapshots[index].m_Transform.position, Snapshots[index].m_Transform.rotation);
172  newproperties.m_Transform = newnode.transform;
173  Snapshots.Insert(index + 1, newproperties);
174  }
175 
176  ReorderGameObjectList();
177  return newnode.transform;
178  }
+ Here is the caller graph for this function:

◆ AddNode() [2/2]

NodeProperties MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.AddNode ( Vector3  position,
Quaternion  rotation 
)

function used to create new node hierarchy from recording data

Parameters
position
rotation
Returns
204  {
205  GameObject newnode = CreateGameobject(position, rotation);
206  NodeProperties property = new NodeProperties() { m_Transform = newnode.transform, m_TransitionDuration = 1 };
207  Snapshots.Add(property);
208  return property;
209  }

◆ Clear()

void MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.Clear ( )

Clear hierarchy

352  {
353  for (int i = 0; i < Snapshots.Count; i++)
354  {
355  GameObject nodegameobject = Snapshots[i].m_Transform.gameObject;
356 
357  PositionRotationBaker.DestroyImmediate(nodegameobject);
358  }
359 
360  Snapshots.Clear();
361  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Contains()

bool MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.Contains ( Transform  input)

check if hierarchy contains transform

Parameters
input
Returns
254  {
255  NodeProperties properties = GetProperties(input);
256  return properties != null;
257  }

◆ CreateFindEditorNodesParent()

void MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.CreateFindEditorNodesParent ( )

Create Parent Gameobject under gameobject target

184  {
185  m_NodeParent = transform.Find("EditorNodes");
186  if (m_NodeParent == null)
187  {
188  m_NodeParent = new GameObject("EditorNodes").transform;
189  m_NodeParent.tag = "EditorOnly";
190  m_NodeParent.hideFlags = HideFlags.HideInHierarchy;
191  m_NodeParent.transform.parent = transform;
192  m_NodeParent.transform.position = transform.position;
193  Snapshots = new List<NodeProperties>();
194  }
195  }

◆ CreateGameobject()

GameObject MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.CreateGameobject ( Vector3  position,
Quaternion  rotation 
)

Create a gameobject for baker based on position and rotation

Parameters
position
rotation
Returns
218  {
219  GameObject newnode = new GameObject();
220  newnode.transform.parent = m_NodeParent;
221  newnode.tag = "EditorOnly";
222  newnode.transform.position = position;
223  newnode.transform.rotation = rotation;
224  return newnode;
225  }

◆ CreateSaveData()

SavedData MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.CreateSaveData ( NodeProperties  input)

Conversion from nodeproperties to saveddata

Parameters
input
Returns
143  {
144  return new SavedData()
145  {
146  m_Position = input.m_Transform.position,
147  m_Rotation = input.m_Transform.rotation,
148  m_TransitionDuration = input.m_TransitionDuration
149  };
150  }

◆ CreateSavedDataList()

List<SavedData> MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.CreateSavedDataList ( )

Create Hiararchy save list for cache

Returns
368  {
369  List<SavedData> output = new List<SavedData>(Snapshots.Count);
370 
371  for (int i = 0; i < Snapshots.Count; i++)
372  {
373  output.Add(new SavedData()
374  {
375  m_Position = Snapshots[i].m_Transform.position,
376  m_Rotation = Snapshots[i].m_Transform.rotation,
377  m_TransitionDuration = Snapshots[i].m_TransitionDuration
378  });
379  }
380 
381  return output;
382  }

◆ DeleteNode()

void MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.DeleteNode ( int  index)

Deletes node form hierarchy

Parameters
index
232  {
233  PositionRotationBaker.DestroyImmediate(Snapshots[index].m_Transform.gameObject);
234  Snapshots.RemoveAt(index);
235  ReorderGameObjectList();
236  }
+ Here is the caller graph for this function:

◆ GetIndexOfNode()

int MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.GetIndexOfNode ( Transform  input)

Returns index of Transform

Parameters
input
Returns
244  {
245  return Snapshots.IndexOf(GetProperties(input));
246  }
+ Here is the caller graph for this function:

◆ GetProperties()

NodeProperties MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.GetProperties ( Transform  input)

Get node properties from target input

Parameters
input
Returns
265  {
266  for (int i = 0; i < Snapshots.Count; i++)
267  {
268  if (Snapshots[i].m_Transform == input)
269  {
270  return Snapshots[i];
271  }
272  }
273 
274  return null;
275  }
+ Here is the caller graph for this function:

◆ GetSelected()

int MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.GetSelected ( Transform  selected)

Get index of selected transform

Parameters
selected
Returns
292  {
293  if (Contains(selected))
294  {
295  return GetIndexOfNode(selected);
296  }
297 
298  return 9999999;
299  }
+ Here is the caller graph for this function:

◆ Load() [1/2]

void MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.Load ( List< SavedData dataToExtract)

Called by Time Rewind Editor to load game objects from Save File

Parameters
dataToExtract
100  {
101  for (int i = 0; i < Snapshots.Count; i++)
102  {
103  PositionRotationBaker.DestroyImmediate(Snapshots[i].m_Transform.gameObject);
104  }
105 
106  Snapshots = new List<NodeProperties>();
107 
108  for (int i = 0; i < dataToExtract.Count; i++)
109  {
110  Snapshots.Add(new NodeProperties()
111  {
112  m_Transform = CreateGameobject(dataToExtract[i].m_Position, dataToExtract[i].m_Rotation).transform,
113  m_TransitionDuration = dataToExtract[i].m_TransitionDuration
114  });
115  }
116 
117  ReorderGameObjectList();
118  }

◆ Load() [2/2]

NodeProperties MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.Load ( SavedData  input)

load properties of and create editor only gameobjects attached under the gameobject for displaying gizmos

Parameters
input
Returns
126  {
127  GameObject newgameobject = CreateGameobject(input.m_Position, input.m_Rotation);
128  newgameobject.transform.parent = m_NodeParent;
129 
130  return new NodeProperties()
131  {
132  m_Transform = newgameobject.transform,
133  m_TransitionDuration = input.m_TransitionDuration
134  };
135  }

◆ OnDestroy()

void MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.OnDestroy ( )
protected

Called when destorying object in scene

88  {
89  if (m_NodeParent != null)
90  {
91  PositionRotationBaker.DestroyImmediate(m_NodeParent.gameObject);
92  }
93  }

◆ SaveChanges()

void MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.SaveChanges ( )

save changes to baker

67  {
68  Save.Invoke(name);
69  }
+ Here is the caller graph for this function:

◆ UpdateSelected()

void MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.UpdateSelected ( Transform  newselection)

Select New selected

Parameters
newselection
282  {
283  m_SelectedTransform = newselection;
284  }

Member Data Documentation

◆ m_Gizmos

bool MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.m_Gizmos

Gizmos setting

◆ m_NodeParent

Transform MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.m_NodeParent

Parent for hierarchy nodes

◆ m_SelectedTransform

Transform MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.m_SelectedTransform

selected transform

Property Documentation

◆ BaseBaker

dynamic MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.BaseBaker
getset

Scriptableobject cache holder object from editor .dll

61 { get; set; }

◆ NodePositions

Transform [] MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.NodePositions
get

Get all node positions from Hierarchy

33  {
34  get
35  {
36  Transform[] transforms = new Transform[Snapshots.Count];
37  for (int i = 0; i < transforms.Length; i++)
38  {
39  transforms[i] = Snapshots[i].m_Transform;
40  }
41 
42  return transforms;
43  }
44  }

◆ Save

Action<string> MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.Save
set

saving action

56 { private get; set; }

◆ Snapshots

List<NodeProperties> MarkOostveen.TimeRewizer.Editor.Baking.PositionRotationBaker.Snapshots
getset

Node in hierarchy

51 { get; set; }