private static void SaveAnimator(AnimatorDatam datam, Material material, Texture2D positionTexture, Texture2D normalTexture) { string assetPath = AssetDatabase.GetAssetPath(datam); string startFolder = FileUtil.GetProjectRelativePath(assetPath); string path = EditorUtility.SaveFilePanel("Save Animation Asset", startFolder, datam.name, "asset"); if (string.IsNullOrEmpty(path)) { return; } path = FileUtil.GetProjectRelativePath(path); AssetDatabase.CreateAsset(datam, path); AssetDatabase.CreateAsset(material, path.Replace(datam.name, datam.name.Replace("Animator", "Material"))); AssetDatabase.CreateAsset(positionTexture, path.Replace(datam.name, datam.name.Replace("Animator", "Position Texture"))); AssetDatabase.CreateAsset(normalTexture, path.Replace(datam.name, datam.name.Replace("Animator", "Normal Texture"))); AssetDatabase.SaveAssets(); }
void InitAnimator(Material material, Mesh mesh, AnimationClip[] clips) { lastCreatedAnimator = ScriptableObject.CreateInstance <AnimatorDatam>();//new AnimatorDatam(); lastCreatedAnimator.name = vox.name.Replace("Vox", "Animator"); lastCreatedAnimator.data = new AnimatorData(); lastCreatedAnimator.material = material;// materials[0]; lastCreatedAnimator.mesh = mesh; lastCreatedAnimator.data.datas = new AnimationData[clips.Length]; for (int i = 0; i < lastCreatedAnimator.data.datas.Length; i++) { if (clips[i] != null) { lastCreatedAnimator.data.datas[i].name = clips[i].name; lastCreatedAnimator.data.datas[i].time = clips[i].length; lastCreatedAnimator.data.datas[i].framesPerSecond = (int)clips[i].frameRate; lastCreatedAnimator.data.datas[i].frames = Mathf.CeilToInt(clips[i].frameRate * clips[i].length); } } }