Skip to content

Commit

Permalink
Merge pull request #91 from soupday/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
soupday authored Nov 29, 2023
2 parents a6f68c0 + 76971aa commit 67373c4
Show file tree
Hide file tree
Showing 34 changed files with 4,227 additions and 998 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

### 1.6.0
- Fixes to root bones and physics components in LOD combiner.
- Support for Magica Cloth 2 Physics (if present) - Cloth simulation and spring bones.
- Collider Manager rebuild to support magica cloth
- Collider editor now uses direct on screen manipulation of colliders.
- Support for Json Schema 1.2
- A bug in CC4 can cause the character to export with this schema.
- Run time wrinkle material fix.

### 1.5.2
- Animation Retargeter fixes.
- AnimationMode removed.
Expand Down
95 changes: 68 additions & 27 deletions Editor/AnimPlayerGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void OpenPlayer(GameObject scenePrefab)
{
if (scenePrefab)
{
scenePrefab = Util.TryResetScenePrefab(scenePrefab);
//scenePrefab = Util.TryResetScenePrefab(scenePrefab);
SetCharacter(scenePrefab);
}

Expand Down Expand Up @@ -84,11 +84,11 @@ public static void ClosePlayer()
EditorApplication.update -= UpdateCallback;
EditorApplication.playModeStateChanged -= PlayStateChangeCallback;

if (CharacterAnimator)
{
GameObject scenePrefab = Util.GetScenePrefabInstanceRoot(CharacterAnimator.gameObject);
Util.TryResetScenePrefab(scenePrefab);
}
//if (CharacterAnimator)
///{
//GameObject scenePrefab = Util.GetScenePrefabInstanceRoot(CharacterAnimator.gameObject);
//Util.TryResetScenePrefab(scenePrefab);
//}

#if SCENEVIEW_OVERLAY_COMPATIBLE
//2021.2.0a17+
Expand Down Expand Up @@ -121,7 +121,7 @@ public static bool IsPlayerShown()
public static void SetCharacter(GameObject scenePrefab)
{
if (scenePrefab)
Util.LogInfo("scenePrefab.name: " + scenePrefab.name + " " + PrefabUtility.IsPartOfPrefabInstance(scenePrefab));
Util.LogDetail("scenePrefab.name: " + scenePrefab.name + " " + PrefabUtility.IsPartOfPrefabInstance(scenePrefab));

if (!scenePrefab && WindowManager.IsPreviewScene)
scenePrefab = WindowManager.GetPreviewScene().GetPreviewCharacter();
Expand Down Expand Up @@ -246,12 +246,10 @@ enum AnimatorFlags
// GUIStyles
private static Styles guiStyles;

[SerializeField]
private static List<BoneItem> boneItemList;
[SerializeField]
public static bool isTracking = false;
[SerializeField]
private static GameObject lastTracked;
[SerializeField] private static List<BoneItem> boneItemList;
[SerializeField] public static bool isTracking = false;
[SerializeField] public static GameObject lastTracked;
[SerializeField] public static bool trackingPermitted = true;
private static string boneNotFound = "not found";

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -286,7 +284,7 @@ private static AnimatorController CreateAnimatiorController()
{
controllerPath = dirString + controllerName + ".controller";

Util.LogInfo("Creating Temporary file " + controllerPath);
Util.LogDetail("Creating Temporary file " + controllerPath);
AnimatorController a = AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
a.name = controllerName;
// play mode parameters
Expand Down Expand Up @@ -373,7 +371,7 @@ private static void SelectOverrideAnimation(AnimationClip clip, AnimatorOverride

foreach (var v in overrides)
{
Util.LogInfo("Overrides: " + " Key: " + v.Key + " Value: " + v.Value);
Util.LogDetail("Overrides: " + " Key: " + v.Key + " Value: " + v.Value);
}

overrides[0] = new KeyValuePair<AnimationClip, AnimationClip>(overrides[0].Key, WorkingClip);
Expand All @@ -390,7 +388,7 @@ public static void SelectOverrideAnimationWithoutReset(AnimationClip clip, Anima

foreach (var v in overrides)
{
Util.LogInfo("Overrides: " + " Key: " + v.Key + " Value: " + v.Value);
Util.LogDetail("Overrides: " + " Key: " + v.Key + " Value: " + v.Value);
}

overrides[0] = new KeyValuePair<AnimationClip, AnimationClip>(overrides[0].Key, WorkingClip);
Expand Down Expand Up @@ -439,7 +437,7 @@ public static void ResetToBaseAnimatorController()

if (!characterPrefab) return;

Util.LogInfo(("Attempting to reset: " + characterPrefab.name));
Util.LogDetail(("Attempting to reset: " + characterPrefab.name));

GameObject basePrefab = PrefabUtility.GetCorrespondingObjectFromSource(characterPrefab);

Expand All @@ -448,36 +446,36 @@ public static void ResetToBaseAnimatorController()
if (true) //(PrefabUtility.IsAnyPrefabInstanceRoot(basePrefab))
{
string prefabPath = AssetDatabase.GetAssetPath(basePrefab);
Util.LogInfo((basePrefab.name + "Prefab instance root found: " + prefabPath));
Util.LogDetail((basePrefab.name + "Prefab instance root found: " + prefabPath));

Util.LogInfo("Loaded Prefab: " + basePrefab.name);
Util.LogDetail("Loaded Prefab: " + basePrefab.name);
Animator baseAnimator = basePrefab.GetComponent<Animator>();
if (!baseAnimator) baseAnimator = basePrefab.GetComponentInChildren<Animator>();
if (baseAnimator != null)
{
Util.LogInfo("Prefab Animator: " + baseAnimator.name);
Util.LogDetail("Prefab Animator: " + baseAnimator.name);
if (baseAnimator.runtimeAnimatorController)
{
Util.LogInfo("Prefab Animator Controller: " + baseAnimator.runtimeAnimatorController.name);
Util.LogDetail("Prefab Animator Controller: " + baseAnimator.runtimeAnimatorController.name);
string controllerpath = AssetDatabase.GetAssetPath(baseAnimator.runtimeAnimatorController);
Util.LogInfo("Prefab Animator Controller Path: " + controllerpath);
Util.LogDetail("Prefab Animator Controller Path: " + controllerpath);
AnimatorController baseController = AssetDatabase.LoadAssetAtPath<AnimatorController>(controllerpath);

if (CharacterAnimator.runtimeAnimatorController != null)
{
// ensure the created override controller is the one on the animator
// to avoid wiping user generated controller (it will have to be a disk asset - but nevertheless)
Util.LogInfo("Current controller on character: " + CharacterAnimator.runtimeAnimatorController.name);
Util.LogDetail("Current controller on character: " + CharacterAnimator.runtimeAnimatorController.name);
if (CharacterAnimator.runtimeAnimatorController.GetType() == typeof(AnimatorOverrideController) && CharacterAnimator.runtimeAnimatorController.name == overrideName)
{
Util.LogInfo("Created override controller found: can reset");
Util.LogDetail("Created override controller found: can reset");
CharacterAnimator.runtimeAnimatorController = baseController;
}
}
}
else
{
Util.LogInfo("NO Prefab Animator Controller");
Util.LogDetail("NO Prefab Animator Controller");
CharacterAnimator.runtimeAnimatorController = null;
}
}
Expand All @@ -495,7 +493,7 @@ private static void DestroyAnimationController()
{
//if (showMessages)

Util.LogInfo("Override controller: " + controllerPath + " exists -- removing");
Util.LogDetail("Override controller: " + controllerPath + " exists -- removing");
AssetDatabase.DeleteAsset(controllerPath);
}
}
Expand Down Expand Up @@ -602,6 +600,7 @@ public static void DrawPlayer()
if (!CheckTackingStatus())
CancelBoneTracking(false); //object focus lost - arrange ui to reflect that, but dont fight with the scene camera

EditorGUI.BeginDisabledGroup(!trackingPermitted);
if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("Camera Gizmo").image, "Select individual bone to track with the scene camera."), guiStyles.settingsButton, GUILayout.Width(24f), GUILayout.Height(24f)))
{
GenerateBoneMenu();
Expand All @@ -615,6 +614,7 @@ public static void DrawPlayer()
CancelBoneTracking(true); //tracking deliberately cancelled - leave scene camera in last position with last tracked object still selected
}
EditorGUI.EndDisabledGroup();
EditorGUI.EndDisabledGroup();
GUILayout.FlexibleSpace();

EditorGUI.BeginChangeCheck();
Expand Down Expand Up @@ -725,7 +725,20 @@ public static void DrawPlayer()
EditorGUI.EndDisabledGroup();

GUILayout.Space(10f);
GUILayout.Label(new GUIContent(EditorGUIUtility.IconContent("d_UnityEditor.GameView").image, "Controls for 'Play Mode'"), guiStyles.playIconStyle, GUILayout.Width(24f), GUILayout.Height(24f));
//GUILayout.Label(new GUIContent(EditorGUIUtility.IconContent("d_UnityEditor.GameView").image, "Controls for 'Play Mode'"), guiStyles.playIconStyle, GUILayout.Width(24f), GUILayout.Height(24f));

if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("d_ViewToolOrbit On").image, "Select the character root."), EditorStyles.toolbarButton))
{
if (ColliderManagerEditor.EditMode)
{
Selection.activeObject = null;
}
else
{
Selection.activeObject = selectedAnimator.gameObject;
}

}

Texture bigPlayButton = EditorApplication.isPlaying ? EditorGUIUtility.IconContent("preAudioPlayOn").image : EditorGUIUtility.IconContent("preAudioPlayOff").image;
string playToggleTxt = EditorApplication.isPlaying ? "Exit 'Play Mode'." : "Enter 'Play Mode' and focus on the scene view window. This is to be used to evaluate play mode physics whilst allowing visualization of objects such as colliders.";
Expand Down Expand Up @@ -1142,6 +1155,34 @@ private static void TrackBone(BoneItem boneItem)
scene.Repaint();
}

public static void ForbidTracking()
{
// this is called by the collider manager editor script to use its own tracking while editing colliders
// this avoids having an objected selected since its control handles will be visible and cause problems

if (isTracking)
{
isTracking = false;
Selection.activeObject = null;
}

trackingPermitted = false;

if (boneItemList != null)
{
foreach (BoneItem boneItem in boneItemList)
{
if (boneItem.selected)
boneItem.selected = false;
}
}
}

public static void AllowTracking()
{
trackingPermitted = true;
}

public static void ReEstablishTracking(string humanBoneName)
{
//if (boneItemList == null)
Expand Down
2 changes: 1 addition & 1 deletion Editor/AnimPlayerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void DoWindow(int id)

public static void Empty(int id)
{
Util.LogInfo("Showing " + id);
Util.LogDetail("Showing " + id);
}
}
}
13 changes: 3 additions & 10 deletions Editor/AnimRetargetGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,14 +470,11 @@ public static bool CanClipLoop(AnimationClip clip)
foreach (EditorCurveBinding binding in curveBindings)
{
Keyframe[] testKeys = AnimationUtility.GetEditorCurve(clip, binding).keys;
//Debug.Log(Math.Round(testKeys[0].value, 3) + " -- " + Math.Round(testKeys[testKeys.Length - 1].value, 3) + " --- " + (Math.Round(testKeys[0].value, 3) != Math.Round(testKeys[testKeys.Length - 1].value, 3)));
if (Math.Round(testKeys[0].value, 2) != Math.Round(testKeys[testKeys.Length - 1].value, 2))
{
canLoop = false;
//Debug.Log(binding.propertyName + " 0: " + testKeys[0].value + " last: " + testKeys[testKeys.Length - 1].value);
}
}
//Debug.Log("Animation Clip " + clip.name + (canLoop ? " can loop" : " can NOT loop"));
return canLoop;
}

Expand Down Expand Up @@ -529,7 +526,6 @@ static void CloseMouthToggle(bool close)
AnimPlayerGUI.UpdateAnimator();
}


static void ApplyPose(int mode)
{
if (!(OriginalClip && WorkingClip)) return;
Expand Down Expand Up @@ -1325,14 +1321,11 @@ static string GenerateClipAssetPath(AnimationClip originalClip, string character
return assetPath;
}




static AnimationClip WriteAnimationToAssetDatabase(AnimationClip workingClip, string assetPath, bool originalSettings = false)
{
if (string.IsNullOrEmpty(assetPath)) return null;

Util.LogInfo("Writing Asset: " + assetPath);
Util.LogDetail("Writing Asset: " + assetPath);

var output = Object.Instantiate(workingClip); // clone so that workingClip isn't locked to an on-disk asset
AnimationClip outputClip = output as AnimationClip;
Expand Down Expand Up @@ -1367,12 +1360,12 @@ static AnimationClip WriteAnimationToAssetDatabase(AnimationClip workingClip, st
if (asset == null)
{
// New
Util.LogInfo("Writing New Asset: " + assetPath);
Util.LogDetail("Writing New Asset: " + assetPath);
AssetDatabase.CreateAsset(outputClip, assetPath);
}
else
{
Util.LogInfo("Updating Existing Asset: " + assetPath);
Util.LogDetail("Updating Existing Asset: " + assetPath);
outputClip.name = asset.name;
EditorUtility.CopySerialized(outputClip, asset);
AssetDatabase.SaveAssets();
Expand Down
Loading

0 comments on commit 67373c4

Please sign in to comment.