我很想为我的项目添加一个动画。虽然我将类referance添加到另一个类,但visual studio却给出了以下错误:
inaccesible due to its protection level
我定义了数据类型但没有任何改变。这是我的代码块;
static Dictionary<string, AnimationClip> ProcessAnimations(
AnimationContentDictionary animations, IList<BoneContent> bones)
{
// Build up a table mapping bone names to indices.
Dictionary<string, int> boneMap = new Dictionary<string, int>();
for (int i = 0; i < bones.Count; i++)
{
string boneName = bones[i].Name;
if (!string.IsNullOrEmpty(boneName))
boneMap.Add(boneName, i);
}
// Convert each animation in turn.
Dictionary<string, AnimationClip> animationClips;
animationClips = new Dictionary<string, AnimationClip>();
foreach (KeyValuePair<string, AnimationContent> animation in animations)
{
AnimationClip processed = ProcessAnimation(animation.Value, boneMap);
animationClips.Add(animation.Key, processed);
}
这部分给出了这个错误:
animationClips = new Dictionary<string, AnimationClip>();
AnimationClip类:
class AnimationClip
{
public AnimationClip(TimeSpan duration, List<Keyframe> keyframes)
{
Duration = duration;
Keyframes = keyframes;
}
/// </summary>
public AnimationClip()
{
}
/// </summary>
[ContentSerializer]
public TimeSpan Duration { get; private set; }
/// <summary>
/// Gets a combined list containing all the keyframes for all bones,
/// sorted by time.
/// </summary>
[ContentSerializer]
public List<Keyframe> Keyframes { get; private set; }
}
任何人都可以帮助我吗?提前谢谢。
答案 0 :(得分:1)
更改
class AnimationClip
到
public class AnimationClip
让它的成员公开是一件事,但如果你想以这种方式访问它,那么这个类本身也需要公开。