public GameObject loadSkeleton(GenderType gender, RigType rig) { var prefab = Resources.Load("Animation/" + gender.ToString() + "/" + rig.ToString() + "/skeleton"); var clone = GameObject.Instantiate(prefab); return(clone as GameObject); }
public void GenerateAnimationAsset(GenderType gender, RigType rig, Dictionary <String, String> zmoPaths) { GameObject skeleton = new GameObject("skeleton"); bool male = (gender == GenderType.MALE); ZMD zmd = new ZMD(male ? "Assets/3DData/Avatar/MALE.ZMD" : "Assets/3DData/Avatar/FEMALE.ZMD"); zmd.buildSkeleton(skeleton); BindPoses poses = ScriptableObject.CreateInstance <BindPoses>(); poses.bindPoses = zmd.bindposes; poses.boneNames = getBoneNames(zmd.boneTransforms); poses.boneTransforms = zmd.boneTransforms; LoadClips(skeleton, zmd, gender, rig, zmoPaths); string path = "Assets/Resources/Animation/" + gender.ToString() + "/" + rig.ToString() + "/skeleton.prefab"; AssetDatabase.CreateAsset(poses, path.Replace("skeleton.prefab", "bindPoses.asset")); AssetDatabase.SaveAssets(); PrefabUtility.CreatePrefab(path, skeleton); }
public void LoadClips(GameObject skeleton, ZMD zmd, GenderType gender, RigType rig, Dictionary <String, String> zmoPaths) { List <AnimationClip> clips = new List <AnimationClip>(); foreach (KeyValuePair <String, String> motion in zmoPaths) { string unityPath = "Assets/Resources/Animation/" + gender.ToString() + "/" + rig.ToString() + "/clips/" + motion.Key + ".anim"; AnimationClip clip = new ZMO("Assets/" + motion.Value).buildAnimationClip(zmd); clip.name = motion.Key; clip.legacy = true; clip = (AnimationClip)Utils.SaveReloadAsset(clip, unityPath, ".anim"); clips.Add(clip); } Animation animation = skeleton.AddComponent <Animation>(); AnimationUtility.SetAnimationClips(animation, clips.ToArray()); }
public void LoadClips(GameObject skeleton, ZMD zmd, GenderType gender, RigType rig, Dictionary<String, String> zmoPaths) { List<AnimationClip> clips = new List<AnimationClip>(); foreach (KeyValuePair<String, String> motion in zmoPaths) { string unityPath = "Assets/Resources/Animation/" + gender.ToString() + "/" + rig.ToString() + "/clips/" + motion.Key + ".anim"; AnimationClip clip = new ZMO("Assets/" + motion.Value).buildAnimationClip(zmd); clip.name = motion.Key; clip.legacy = true; clip = (AnimationClip)Utils.SaveReloadAsset(clip, unityPath, ".anim"); clips.Add(clip); } Animation animation = skeleton.AddComponent<Animation>(); AnimationUtility.SetAnimationClips(animation, clips.ToArray()); }
public void GenerateAnimationAsset(GenderType gender, RigType rig, Dictionary<String,String> zmoPaths) { GameObject skeleton = new GameObject("skeleton"); bool male = (gender == GenderType.MALE); ZMD zmd = new ZMD(male ? "Assets/3DData/Avatar/MALE.ZMD" : "Assets/3DData/Avatar/FEMALE.ZMD"); zmd.buildSkeleton(skeleton); BindPoses poses = ScriptableObject.CreateInstance<BindPoses>(); poses.bindPoses = zmd.bindposes; poses.boneNames = getBoneNames(zmd.boneTransforms); poses.boneTransforms = zmd.boneTransforms; LoadClips(skeleton, zmd, gender, rig, zmoPaths); string path = "Assets/Resources/Animation/" + gender.ToString() + "/" + rig.ToString() + "/skeleton.prefab"; AssetDatabase.CreateAsset(poses, path.Replace("skeleton.prefab", "bindPoses.asset")); AssetDatabase.SaveAssets(); PrefabUtility.CreatePrefab(path, skeleton); }
public GameObject loadSkeleton(GenderType gender, RigType rig) { var prefab = Resources.Load("Animation/" + gender.ToString() + "/" + rig.ToString() + "/skeleton"); var clone = GameObject.Instantiate(prefab); return clone as GameObject; }