public static void SetCVVTuberSettings()
        {
            GameObject cVVTuberModel = GameObject.Find("CVVTuberModel");

            if (cVVTuberModel != null)
            {
                //Undo.RecordObject(cVVTuberModel.transform.localEulerAngles, "Change cVVTuberModel.transform.localEulerAngles");
                //cVVTuberModel.transform.localEulerAngles = new Vector3 (0, 180, 0);

                Animator animator = cVVTuberModel.GetComponent <Animator> ();

                AnimatorController animCon = animator.runtimeAnimatorController as AnimatorController;
                Undo.RecordObject(animCon, "Set true to layer.ikPass");
                var layers = animCon.layers;
                foreach (var layer in layers)
                {
                    if (layer.stateMachine.name == "Base Layer")
                    {
                        layer.iKPass = true;
                    }
                }

                HeadLookAtIKController headLookAtIKController = FindObjectOfType <HeadLookAtIKController> ();
                if (headLookAtIKController != null)
                {
                    Undo.RecordObject(headLookAtIKController, "Set animator to headLookAtIKController.target");
                    headLookAtIKController.target = animator;

                    var lookAtLoot = GameObject.Find("LookAtRoot").transform;
                    if (lookAtLoot != null)
                    {
                        headLookAtIKController.lookAtRoot = lookAtLoot;
                        var lookAtTarget = lookAtLoot.transform.Find("LookAtTarget").transform;
                        if (lookAtTarget != null)
                        {
                            headLookAtIKController.lookAtTarget = lookAtTarget;
                        }
                    }
                }

                HeadRotationController headRotationController = FindObjectOfType <HeadRotationController> ();
                Undo.RecordObject(headRotationController, "Set head.transform to headRotationController.target");
                if (headRotationController != null)
                {
                    headRotationController.target = cVVTuberModel.transform.Find("Character001/hips/spine/chest/upper_chest/neck/head").transform;
                }

                FaceBlendShapeController faceBlendShapeController = FindObjectOfType <FaceBlendShapeController> ();
                if (faceBlendShapeController != null)
                {
                    Undo.RecordObject(faceBlendShapeController, "Set SkinnedMeshRenderer to faceBlendShapeController.FACE_DEF");
                    faceBlendShapeController.FACE_DEF = cVVTuberModel.transform.Find("FACE_DEF").GetComponent <SkinnedMeshRenderer> ();
                }
            }
            else
            {
                Debug.LogError("There is no \"CVVTuberModel\" prefab in the scene. Please add \"CVVTuberModel\" prefab to the scene.");
            }
        }
Ejemplo n.º 2
0
        static void SetPluginImportSettings()
        {
            GameObject unitychan = GameObject.Find("unitychan");

            if (unitychan != null)
            {
                unitychan.transform.localEulerAngles = new Vector3(0, 180, 0);

                Animator animator = unitychan.GetComponent <Animator> ();

                AnimatorController animCon = animator.runtimeAnimatorController as AnimatorController;
                var layers = animCon.layers;
                foreach (var layer in layers)
                {
                    if (layer.stateMachine.name == "Base Layer")
                    {
                        layer.iKPass = true;
                    }
                }
                EditorUtility.SetDirty(animator);

                IdleChanger idleChanger = unitychan.GetComponent <IdleChanger> ();
                idleChanger.enabled = false;

                FaceUpdate faceUpdate = unitychan.GetComponent <FaceUpdate> ();
                faceUpdate.enabled = false;

                HeadLookAtIKController headLookAtIKController = FindObjectOfType <HeadLookAtIKController> ();
                if (headLookAtIKController != null)
                {
                    headLookAtIKController.animator = animator;

                    EditorUtility.SetDirty(headLookAtIKController);
                }

                HeadRotationController headRotationController = FindObjectOfType <HeadRotationController> ();
                if (headRotationController != null)
                {
                    headRotationController.target = GameObject.Find("Character1_Head").transform;

                    EditorUtility.SetDirty(headRotationController);
                }

                UnityChanDlibFaceBlendShapeController unityChanDlibFaceBlendShapeController = FindObjectOfType <UnityChanDlibFaceBlendShapeController> ();
                if (unityChanDlibFaceBlendShapeController != null)
                {
                    unityChanDlibFaceBlendShapeController.EYE_DEF = GameObject.Find("EYE_DEF").GetComponent <SkinnedMeshRenderer> ();
                    unityChanDlibFaceBlendShapeController.EL_DEF  = GameObject.Find("EL_DEF").GetComponent <SkinnedMeshRenderer> ();
                    unityChanDlibFaceBlendShapeController.BLW_DEF = GameObject.Find("BLW_DEF").GetComponent <SkinnedMeshRenderer> ();
                    unityChanDlibFaceBlendShapeController.MTH_DEF = GameObject.Find("MTH_DEF").GetComponent <SkinnedMeshRenderer> ();


                    EditorUtility.SetDirty(unityChanDlibFaceBlendShapeController);
                }

                UnityChanFaceAnimationClipController unityChanFaceAnimationClipController = FindObjectOfType <UnityChanFaceAnimationClipController> ();
                if (unityChanFaceAnimationClipController != null)
                {
                    unityChanFaceAnimationClipController.animator = animator;

                    EditorUtility.SetDirty(unityChanFaceAnimationClipController);
                }

                EditorUtility.SetDirty(unitychan);
            }
            else
            {
                Debug.LogError("There is no \"unitychan\" prefab in the scene. Please add \"unitychan\" prefab to the scene.");
            }
        }