AnimationBaker.ConvertDumpToUnityAnimationFile C# (CSharp) Метод

ConvertDumpToUnityAnimationFile() публичный Метод

public ConvertDumpToUnityAnimationFile ( ) : void
Результат void
    public void ConvertDumpToUnityAnimationFile()
    {
        if(animClip.IsEmpty()){
            Debug.Log ("Current dump is empty, nothing to bake!");
            return;
        }
        if(!bakingProperties.HasConstraint()){
            Debug.Log ("Can't bake animation file: no one property selected!");
            return;
        }
        if(!sourceSkeleton)
            sourceSkeleton = transform;
        curAnimationName = animClip.name;
        AnimationClip uAnimClip = new AnimationClip();
        uAnimClip.frameRate = animClip.samples;
        uAnimClip.name = curAnimationName;
        MethodInfo[] clipMethods = reflection.GetMethods ();
        foreach(MethodInfo mI in clipMethods){
            if(mI.Name == "set_legacy"){
                object[] arg = new object[1];
                arg[0] = isLegacyType;
                mI.Invoke(uAnimClip,arg);
            }
        }
        //uAnimClip.legacy = isLegacyType;
        skeletonInfo = new SkeletonInfo(new string[0],sourceSkeleton,0);
        skeletonInfo.UpdateSkeletonInfo(true);
        sampleStep = (float)1/animClip.samples;
        for(int i = 0;i<(skeletonInfo.bonesCount);i++){
            uAnimClip = WriteCurveToClip(uAnimClip,i);
        }
        string newAnimationFileFolderPath = animationFileFolderPath+sourceSkeleton.name+"/";
        BINS.CreateFolder(newAnimationFileFolderPath);
        //Debug.Log ("new animation folder path:"+newAnimationFolderPath);
        #if UNITY_EDITOR
            UnityEditor.AssetDatabase.CreateAsset(uAnimClip,newAnimationFileFolderPath+clipNamePrefix+uAnimClip.name+".anim");
            UnityEditor.AssetDatabase.SaveAssets();
        #endif
        //AssetDatabase.Refresh();
        Debug.Log ("animation file was created:"+uAnimClip.name+".anim");
    }

Usage Example

Пример #1
0
 void BakeDump()
 {
     curCharacter = Instantiate(charactersList[selectedCharacter],Vector3.zero,Quaternion.identity) as Transform;
     curCharacter.name = charactersList[selectedCharacter].name;
     curCharacter.gameObject.AddComponent<AnimationBaker>();
     baker = curCharacter.GetComponent<AnimationBaker>();
     baker.LoadAnimationDump(dumpFilePath);
     if(useRootConstraints){
         baker.useRootConstraints = true;
         baker.rootPositionConstraint = rootPositionConstraints;
         baker.rootRotationConstraint = rootRotationConstraints;
         baker.rootScaleConstraint = rootScaleConstraints;
     }
     baker.bakingProperties = bakingProperties;
     baker.ConvertDumpToUnityAnimationFile();
     DestroyImmediate(curCharacter.gameObject);
 }