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

Class Containing Bake Functions for Baking More...

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

Static Public Member Functions

static void BakeAnimation (AnimationBaker bakemonobehaviour)
 
static void BakeInternalValueRewind (ref InternalValueBaker.PropertyInfo input, InternalValueBaker bakemonobehaviour, PropertyInspectorCustomEditorWindow window)
 
static bool CleanInternalValueRewind (ref InternalValueBaker.PropertyInfo input, PropertyInspectorCustomEditorWindow window)
 
static void BakePositionRotation (PositionRotationBaker bakemonobehaviour)
 

Static Public Attributes

static Type ValueType
 

Detailed Description

Class Containing Bake Functions for Baking

Member Function Documentation

◆ BakeAnimation()

static void MarkOostveen.TimeRewizer.Editor.Baking.Bake.BakeAnimation ( AnimationBaker  bakemonobehaviour)
static
10  {
11  List<AnimationBaker.NodeProperties> bakequeuelist = bakemonobehaviour.Snapshots;
12 
13  if (bakequeuelist.Count == 0)
14  {
15  Debug.Log("No Snapshots to bake, Exiting");
16  return;
17  }
18 
19  ScriptableBake bakeobj = EditorRewizeSystemUtility.ReturnBakeForBaker(bakemonobehaviour);
20  bakeobj.DeleteType(typeof(AnimationRewizer.Snapshot));
21 
22  List<ObjectSerializer> structlist = new List<ObjectSerializer>();
23 
24  for (int i = 0; i < bakequeuelist.Count; i++)
25  {
26  AnimationBaker.NodeProperties property = bakequeuelist[i];
27 
28  for (int j = 0; j != property.m_TransitionDuration; j++)
29  {
30  Parameter[] parameterarray = new Parameter[property.m_Parameters.Length];
31  for (byte k = 0; k < property.m_Parameters.Length; k++)
32  {
33  dynamic value = null;
34 
35  switch (property.m_Parameters[k].m_Type)
36  {
37  case AnimatorControllerParameterType.Bool:
38  value = property.m_Parameters[k].m_BoolValue;
39  break;
40 
41  case AnimatorControllerParameterType.Float:
42  value = property.m_Parameters[k].m_FloatValue;
43  break;
44 
45  case AnimatorControllerParameterType.Int:
46  value = property.m_Parameters[k].m_IntValue;
47  break;
48 
49  case AnimatorControllerParameterType.Trigger:
50  break;
51  }
52 
53  parameterarray[k] =
54  new Parameter(property.m_Parameters[k].m_Name, value, property.m_Parameters[k].m_Type);
55  }
56 
57  AnimationRewizer.SnapshotData data =
58  new AnimationRewizer.SnapshotData() { Parameters = parameterarray };
59  AnimationRewizer.Snapshot snapshot = new AnimationRewizer.Snapshot(data);
60  structlist.Add(new ObjectSerializer(snapshot, bakeobj, true, "A_R"));
61  }
62  }
63  EditorRewizeSystemUtility.InitializeScriptableobject(structlist.ToArray(), bakemonobehaviour.gameObject,
64  EditorRewizeSystemUtility.ReturnBakeForBaker(bakemonobehaviour), typeof(AnimationRewizer.Snapshot), "A_R");
65 
66  Debug.Log("Bake Completed " + structlist.Count + " Snapshots.");
67  }
+ Here is the call graph for this function:

◆ BakeInternalValueRewind()

static void MarkOostveen.TimeRewizer.Editor.Baking.Bake.BakeInternalValueRewind ( ref InternalValueBaker.PropertyInfo  input,
InternalValueBaker  bakemonobehaviour,
PropertyInspectorCustomEditorWindow  window 
)
static
11  {
12  if (input.m_Values.Count > 0)
13  {
14  //get and cleanup scriptableObject
15  ScriptableBake bakeobj = EditorRewizeSystemUtility.ReturnBakeForBaker(bakemonobehaviour);
16 
17  //get internal value list
18  dynamic valuelist = input.m_Values;
19 
20  ObjectSerializer[] serializedobjects = new ObjectSerializer[valuelist.Count];
21 
22  //delete existing instances with the same type
23  CleanInternalValueRewind(ref input, window);
24 
25  //get tuple with generic types
26  (Type ValueType, Type ValueRewindType, MethodInfo createinstancefunction) types =
27  InternalValueGetTypes(input);
28 
29  string tag = input.m_Parent.name + "_" + input.m_FieldInfo.Name;
30 
31  object snapshotinstance = null;
32  //Create serializeable instances
33  for (int i = 0; i < serializedobjects.Length; i++)
34  {
35  snapshotinstance =
36  types.createinstancefunction.Invoke(null, new object[] { valuelist[i].m_Value.GetEditorValue() });
37 
38  serializedobjects[i] = new ObjectSerializer(snapshotinstance, bakeobj, true,
39  tag);
40  }
41 
42  //add objects to bakeobj, save it and link to references internaly
43  EditorRewizeSystemUtility.InitializeScriptableobject(serializedobjects, bakemonobehaviour.gameObject,
44  bakeobj, snapshotinstance.GetType(), tag);
45 
46  Debug.Log("Bake Completed " + serializedobjects.Length + " Snapshots, Of type: " +
47  input.m_FieldInfo.FieldType);
48 
49  input.m_Instance.PreLoadInfo = bakeobj;
50 
51  EditorRewizeSystemUtility.SaveDirtyObject(input.m_Parent);
52  EditorRewizeSystemUtility.SaveDirtyObject(bakemonobehaviour);
53  EditorRewizeSystemUtility.SaveScene();
54  }
55  else
56  {
57  Debug.Log("No snapshots to bake, Check hierarchy");
58  }
59  }
+ Here is the call graph for this function:

◆ BakePositionRotation()

static void MarkOostveen.TimeRewizer.Editor.Baking.Bake.BakePositionRotation ( PositionRotationBaker  bakemonobehaviour)
static
12  {
13  List<PositionRotationBaker.NodeProperties> bakequeuelist = bakemonobehaviour.Snapshots;
14 
15  if (bakequeuelist.Count == 0)
16  {
17  Debug.Log("No Snapshots to bake, Exiting");
18  return;
19  }
20 
21  ScriptableBake bakeobj = EditorRewizeSystemUtility.ReturnBakeForBaker(bakemonobehaviour);
22 
23  bakeobj.DeleteType(typeof(PositionRotationRewizer.Snapshot));
24 
25  List<ObjectSerializer> structlist = new List<ObjectSerializer>();
26 
27  for (int i = 0; i < bakequeuelist.Count - 1; i++)
28  {
29  PositionRotationBaker.NodeProperties property = bakequeuelist[i];
30  PositionRotationBaker.NodeProperties nextporperty = bakequeuelist[i + 1];
31 
32  for (int j = 1; j != property.m_TransitionDuration + 1; j++)
33  {
34  float multiplier = (j / property.m_TransitionDuration);
35 
36  PositionRotationRewizer.Snapshot snapshot = new PositionRotationRewizer.Snapshot(
37  Vector3.Lerp(property.m_Transform.position, nextporperty.m_Transform.position, multiplier),
38  Quaternion.Slerp(property.m_Transform.rotation, nextporperty.m_Transform.rotation, multiplier));
39  structlist.Add(new ObjectSerializer(snapshot, bakeobj, true, "P_R"));
40  }
41  }
42 
43  EditorRewizeSystemUtility.InitializeScriptableobject(structlist.ToArray(), bakemonobehaviour.gameObject,
44  EditorRewizeSystemUtility.ReturnBakeForBaker(bakemonobehaviour), typeof(PositionRotationRewizer.Snapshot), "P_R");
45 
46  Debug.Log("Bake Completed " + structlist.Count + " Snapshots.");
47  }
+ Here is the call graph for this function:

◆ CleanInternalValueRewind()

static bool MarkOostveen.TimeRewizer.Editor.Baking.Bake.CleanInternalValueRewind ( ref InternalValueBaker.PropertyInfo  input,
PropertyInspectorCustomEditorWindow  window 
)
static
63  {
64  if (input.m_Instance.LoadScriptableContent() != null)
65  {
66  ScriptableBake bakeobj = input.m_Instance.LoadScriptableContent();
67 
68  //get generic types and create method
69  (Type ValueType, Type ValueRewindType, MethodInfo createinstancefunction) types =
70  InternalValueGetTypes(input);
71 
72  //create instance to compare with in bakeobj
73  object compareinstance = types.createinstancefunction.Invoke(null,
74  new[]
75  {
76  ((dynamic)RewizeUtilityFunctions.CreateInstanceByType(window.m_VariableType)).GetEditorValue()
77  });
78 
79  //delete matching types with same tag
80  bakeobj.DeleteType(compareinstance.GetType(), input.m_Parent.name + "_" + input.m_FieldInfo.Name);
81  input.m_Instance.PreLoadInfo = null;
82 
83  EditorRewizeSystemUtility.SaveDirtyObject(input.m_Parent);
84 
85  return true;
86  }
87  else
88  {
89  return false;
90  }
91  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ ValueType

Type MarkOostveen.TimeRewizer.Editor.Baking.Bake.ValueType
static