コード例 #1
0
    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);
        }
    }
コード例 #2
0
    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++;
        }
    }
コード例 #3
0
    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);
    }