Beispiel #1
0
 public bool Equals(XmlProvider provider)
 {
     try
     {
         return(CurrentUser.id == provider.CurrentUser.id &&
                AbsoluteFile.Equals(provider.AbsoluteFile) &&
                DictionaryEqual(KnownNodes, provider.KnownNodes));
     }
     catch
     {
         return(false);
     }
 }
        private static void CheckForMissingKeyFrameForJointOfAnimationClip(string[] importedAssets)
        {
            foreach (string importedAsset in importedAssets)
            {
                if (!importedAsset.Contains("Characters"))
                {
                    continue;
                }
                if (!importedAsset.Contains("Animations"))
                {
                    continue;
                }
                if (!importedAsset.EndsWith(".anim"))
                {
                    continue;
                }

                string animationFolderPath = importedAsset.Substring(0, importedAsset.LastIndexOf("/"));
                string characterFolderPath = animationFolderPath.Substring(0, animationFolderPath.LastIndexOf("/"));
                //Debug.Log("animationFolder: " + animationFolder);
                //Debug.Log("characterFolder: " + characterFolder);
                string characterFolderName = characterFolderPath.Substring(
                    characterFolderPath.LastIndexOf("/") + 1,
                    characterFolderPath.Length - characterFolderPath.LastIndexOf("/") - 1
                    );
                //DLog.Log("characterFolderName: " + characterFolderName);
                int characterGroupId = Convert.ToInt32(characterFolderName.Split('_')[1]);
                //DLog.Log("Character group id " + characterGroupId);
                GameObject characterPrefab;
                Transform  allJoint = null;
                foreach (string child in Directory.GetDirectories(new AssetFile(characterFolderPath).ShowAbsolutePath()))
                {
                    string childAbsolutePath = child.Replace("\\", "/");
                    //DLog.Log(childAbsolutePath);
                    string childRelativePath = new AbsoluteFile(childAbsolutePath + "/" + characterGroupId + "_1.prefab")
                                               .ShowRelativePathAsAsset();
                    //DLog.Log("chileRelativePath: " + childRelativePath);
                    characterPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(
                        childRelativePath
                        );
                    allJoint = characterPrefab.transform.FindDeepChild("All_jnt");
                    if (characterPrefab != null && allJoint != null)
                    {
                        //DLog.Log(characterPrefab.name);
                        break;
                    }
                }

                Transform[]      joints             = allJoint.GetComponentsInChildren <Transform>();
                string[]         jointNamesFromRig  = joints.Select(transform => transform.name).ToArray();
                HashSet <string> jointNamesFromClip = new HashSet <string>();
                AnimationClip    clip = AssetDatabase.LoadAssetAtPath <AnimationClip>(importedAsset);
                foreach (EditorCurveBinding ecb in AnimationUtility.GetCurveBindings(clip))
                {
                    //DLog.Log(ecb.path);
                    string jointName = ecb.path.Substring(
                        ecb.path.LastIndexOf("/") + 1, ecb.path.Length - ecb.path.LastIndexOf("/") - 1
                        );
                    //DLog.Log(jointName);
                    jointNamesFromClip.Add(jointName);
                }

                foreach (string jointFromRig in jointNamesFromRig)
                {
                    bool found = false;
                    foreach (string jointFromClip in jointNamesFromClip)
                    {
                        if (jointFromRig.Equals(jointFromClip))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        DLog.LogError(string.Format(
                                          "Animation clip '{0}' does not contain KeyFrame for joint of name '{1}'",
                                          clip.name, jointFromRig
                                          ));
                    }
                }
            }
        }