Skip to content

Commit

Permalink
fix compilation issues on 2022+
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Sep 19, 2022
1 parent 9d62811 commit a88b38b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
6 changes: 5 additions & 1 deletion UnityGLTF/Assets/UnityGLTF/Editor/Scripts/GLTFImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ string GetUniqueName(string desiredName)
}
}

#if !UNITY_2022_1_OR_NEWER
AssetDatabase.Refresh();
#endif

// Save materials as separate assets and rewrite refs
if (materials.Length > 0)
Expand All @@ -345,8 +347,10 @@ string GetUniqueName(string desiredName)
}
}

AssetDatabase.SaveAssets();
#if !UNITY_2022_1_OR_NEWER
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
#endif
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ public override void OnInspectorGUI()
serializedObject.ApplyModifiedProperties();
try
{
#if UNITY_2022_2_OR_NEWER
SaveChanges();
#else
ApplyAndImport();
#endif
GUIUtility.ExitGUI();
}
catch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal void CollectClipCurvesForHumanoid(GameObject root, AnimationClip clip,
animatedTransforms.Add(tr, null);
}

Debug.Log("Animated:\n" + string.Join("\n", animatedTransforms.Keys.Select(x => x.name)));
// Debug.Log("Animated:\n" + string.Join("\n", animatedTransforms.Keys.Select(x => x.name)));

var recorder = new GLTFRecorder(root.transform, false, false, false);

Expand All @@ -48,8 +48,12 @@ internal void CollectClipCurvesForHumanoid(GameObject root, AnimationClip clip,
var length = clip.length;
var time = 0f;

#if UNITY_2020_1_OR_NEWER
var driver = ScriptableObject.CreateInstance<AnimationModeDriver>();
AnimationMode.StartAnimationMode(driver);
#else
AnimationMode.StartAnimationMode();
#endif
AnimationMode.BeginSampling();

root.transform.position = Vector3.zero;
Expand All @@ -72,14 +76,16 @@ internal void CollectClipCurvesForHumanoid(GameObject root, AnimationClip clip,
recorder.UpdateRecording(time);

AnimationMode.EndSampling();
#if UNITY_2020_1_OR_NEWER
AnimationMode.StopAnimationMode(driver);

// playableGraph.Destroy();
#else
AnimationMode.StopAnimationMode();
#endif

recorder.EndRecording(out var data);
if (data == null || !data.Any()) return;

static string CalculatePath(Transform child, Transform parent)
string CalculatePath(Transform child, Transform parent)
{
if (child == parent) return "";
if (child.parent == null) return "";
Expand Down Expand Up @@ -119,7 +125,7 @@ static string CalculatePath(Transform child, Transform parent)
targetCurves[calculatedPath] = curveSet;
}

Debug.Log("Recorded Transforms:\n" + string.Join("\n", targetCurves.Keys));
// Debug.Log("Recorded Transforms:\n" + string.Join("\n", targetCurves.Keys));
}
}
}

0 comments on commit a88b38b

Please sign in to comment.