c-sharp class can not reference Animation rigging package types
Despite adding the 'using UnityEngine.Animations.Rigging' header atop the script, it still cant resolve the 'Rigging' class inside 'Animations'. Specifically, it can't reference the 'TwoBoneIKConstraint' class. It's a simple class as seen below. The script can use other unity types just fine, so why not the types from the animation rigging package? Here's the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations.Rigging;
public class TwoBoneIkWeightByAnimationTrack
{
public bool Graduating { get; set; }
public void GraduateIkWeight(MonoBehaviour caller, Animator animator, string animationState,
List<TwoBoneIKConstraint> twoBoneIkConstraints, bool inverse)
{
if ( Graduating ) return;
caller.StartCoroutine(GraduateWeight(
animator,
animationState,
twoBoneIkConstraints,
inverse));
}
private IEnumerator GraduateWeight(
Animator animator,
string animationState,
List<TwoBoneIKConstraint> twoBoneIkConstraints,
bool inverse)
{
Graduating = true;
AnimatorStateInfo animStateInfo = animator.GetCurrentAnimatorStateInfo(0);
if ( !animStateInfo.IsName(animationState) ) yield break;
float percentComplete = 0f;
while ( percentComplete < 1f )
{
foreach ( var ikConstraint in twoBoneIkConstraints )
{
float normalizedTime = animStateInfo.normalizedTime;
percentComplete = normalizedTime - Mathf.Floor(normalizedTime);
ikConstraint.weight = inverse ? (1f - percentComplete) : percentComplete;
}
}
Graduating = false;
}
}
Same for me. Using UnityEngine.Animations.Rigging, Rigging is red and is not properly referenced.
Answer by unity_E08B61DC7432832ECC7B · Jan 22 at 10:28 PM
Solved my issue with resolving the 'Rigging' part of UnityEngine.Animations. I looked at the project my script belonged to and saw References in Visual Studio. There I saw Unity.Animations.Rigging, deleted it and added it again. Now I can reference Unity.Animations.Rigging. Hope it helps someone
Thank you so much, I was going crazy. You reminded me of a button that does that. Preferences>External tools>Regenerate project files fixed everything for me.
What version of unity are you using? I'm on 2019.4.20f1 (LTS) and the Prefereneces>External tools> Regenerate project files is missing the Regenerate project files option. Only the Generate all .csproj files is available. Was it moved or renamed?
Answer by oscarAbraham · Jan 22 at 01:14 AM
Have you installed the rigging package? I bet that's what it is. You need to go to Window>Package Manager, then search for the rigging package there and install it.
Yes, I've already installed the rigging package when I ran into the issue.
Your answer
![](https://koobas.hobune.stream/wayback/20220613033249im_/https://answers.unity.com/themes/thub/images/avi.jpg)