static void BuildHandsAssets(Object o, ref List <Object> toInclued, ref List <string> tempPaths) { if (o.name.Contains("animation") && !o.name.Contains("@")) { Debug.Log(o.name); AnimationClip clip = o as AnimationClip; AnimationClipEx clipEx = ScriptableObject.CreateInstance <AnimationClipEx>(); clipEx.SetAnimationClip(clip); string path = "Assets/anime.asset"; AssetDatabase.CreateAsset(clipEx, path); toInclued.Add(AssetDatabase.LoadAssetAtPath(path, typeof(AnimationClipEx))); tempPaths.Add(path); } if (o.name.Contains("left_hand") && !o.name.Contains("tex") && !o.name.Contains("mat")) { AddPrefabClone(o, "left_hand", ref toInclued, ref tempPaths); } if (o.name.Contains("right_hand") && !o.name.Contains("tex") && !o.name.Contains("mat")) { AddPrefabClone(o, "right_hand", ref toInclued, ref tempPaths); } if (o.name.Contains("pose") && !o.name.Contains("_")) { TextAsset poseObj = o as TextAsset; // Debug.Log(poseObj.text); toInclued.Add(poseObj); } }
AnimationClipEx GetPostureData(_SourceItemData item) { AnimationClipEx postureClip = null; if (!poseTable.ContainsKey(item)) { AssetBundle ab = AssetBundle.CreateFromFile(item.isTempLoaded ? item.TempLocalPath : item.DecorationLocalPath); postureClip = ab.Load("anime") as AnimationClipEx; if (postureClip != null) { poseTable.Add(item, postureClip); Debug.Log("Clip is " + (postureClip.animationClip == null) + "?\n" + postureClip.ToString()); } else { Debug.Log("AssetBundle Load \"anime\" is back NULL!!!"); } ab.Unload(false); } else { postureClip = poseTable[item]; } return(postureClip); }
static void ExportAnimationClip(BuildTarget target) { string resultPath = ActiveBundleDirectionForTarget(target) + "hands.unity3d"; DeleteBundleFileByName(target, "hands"); List <Object> handsToInclude = new List <Object>(); List <string> tempPaths = new List <string>(); foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets)) { if (o.name.Contains("animation") && !o.name.Contains("@")) { Debug.Log(o.name); AnimationClip clip = o as AnimationClip; AnimationClipEx clipEx = ScriptableObject.CreateInstance <AnimationClipEx>(); clipEx.SetAnimationClip(clip); string path = "Assets/anime.asset"; AssetDatabase.CreateAsset(clipEx, path); handsToInclude.Add(AssetDatabase.LoadAssetAtPath(path, typeof(AnimationClipEx))); tempPaths.Add(path); } if (o.name.Contains("left_hand") && !o.name.Contains("tex") && !o.name.Contains("mat")) { AddPrefabClone(o, "left_hand", ref handsToInclude, ref tempPaths); } if (o.name.Contains("right_hand") && !o.name.Contains("tex") && !o.name.Contains("mat")) { AddPrefabClone(o, "right_hand", ref handsToInclude, ref tempPaths); } if (o.name.Contains("pose") && !o.name.Contains("_")) { TextAsset poseObj = o as TextAsset; // Debug.Log(poseObj.text); handsToInclude.Add(poseObj); } } BuildPipeline.BuildAssetBundle(null, handsToInclude.ToArray(), resultPath, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.UncompressedAssetBundle, target //BuildTarget.Android// | BuildTarget.iPhone ); Debug.Log("Saved " + resultPath + " with " + (handsToInclude.Count) + " items"); int i = 0; while (i < tempPaths.Count) { AssetDatabase.DeleteAsset(tempPaths[i]); i++; } }
public void UpdatePosture(_SourceItemData item, bool toSelect, bool isInitial) { AnimationClipEx postureData = GetPostureData(item); if (postureData == null) { Debug.Log("The AnimationClipEx is NULL!!!"); return; } Debug.Log("Clip is " + (postureData.animationClip == null) + "?\n" + postureData.ToString()); ///Show if (toSelect) { // Debug.Log ("Accessory Selected !"); if (postureData == currentPoseClip) { // Debug.Log ("There must be something wrong!"); return; } else { if (isInitial) { initialPoseClip = postureData; // Debug.Log (item.title + "Set Posture to default"); } currentPoseClip = postureData; } ///Hide } else { // Debug.Log ("Accessory Reselesed !"); if (postureData == currentPoseClip) { currentPoseClip = initialPoseClip; } else { // Debug.Log ("There must be something else wrong!"); } } // UpdateAnimationClip(currentPoseClip); }
void UpdateAnimationClip(AnimationClipEx clipEx) { if (GetComponent <Animator>() == null) { return; } if (clipEx == null || clipEx.animationClip == null) { clipEx = defaultPoseClip; } overrideConttroller["postureAnim"] = clipEx; Debug.Log("------------------ After ------------------"); LogOverrideController(); }
void initialControllor() { poseTable = new Dictionary <_SourceItemData, AnimationClipEx>(); AnimationClip clip = Resources.Load("PostureAnimation/postureAnim") as AnimationClip; AnimationClipEx clipEx = ScriptableObject.CreateInstance <AnimationClipEx>(); clipEx.SetAnimationClip(clip); initialPoseClip = defaultPoseClip = clipEx; // avatorAnimator = GetComponent<Animator>(); RuntimeAnimatorController runtimeController = GetComponent <Animator>().runtimeAnimatorController; overrideConttroller = new AnimatorOverrideController(); overrideConttroller.name = "Zero Override Animator"; overrideConttroller.runtimeAnimatorController = runtimeController; // avatorAnimator.runtimeAnimatorController = overrideConttroller; // UpdateAnimationClip(defaultPoseClip); }