예제 #1
0
    void FindBoneTransforms()
    {
        string[] optionalBones =
        {
            "Mid_Head_Jnt_03",
            "L_LowEyelid_Jnt_00",
            "R_LowEyelid_Jnt_00",
            "L_UpEyelid_Jnt_00",
            "R_UpEyelid_Jnt_00",
            "L_Eyeball_Jnt_00",
            "R_Eyeball_Jnt_00"
        };

        Dictionary <string, Transform> mappedTransforms = new Dictionary <string, Transform>();

        TransformHelp.FindChildrenRecursive(this.transform, optionalBones, mappedTransforms);

        //Avoid using enumerators when iterating
        foreach (KeyValuePair <string, Transform> pair in mappedTransforms)
        {
            BoneTransform boneTransform = new BoneTransform(pair.Key, pair.Value, pair.Value.localRotation);

            if (!this.animationTransforms.ContainsKey(pair.Key))
            {
                this.animationTransforms.Add(pair.Key, boneTransform);
            }
        }
    }
예제 #2
0
    void Start()
    {
        Application.targetFrameRate = 30;

        this.device = new StreamedMicrophone();

        //Set microphone to native device implementation.
        RecordingMachineBase.SetRecordingDevice(device);

                #if UNITY_IOS && !UNITY_EDITOR
        this.animationsDatabase = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/FacialAnimations/iOS/FacialAnimationsDatabase.facialanimation");
                #else
        this.animationsDatabase = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/FacialAnimations/Standalone/FacialAnimationsDatabase.facialanimation");
                #endif

        if (this.animationsDatabase != null)
        {
            GameObject mainGO = this.animationsDatabase.mainAsset as GameObject;
            GameObject.Instantiate(mainGO);
        }

        this.Actor = GameObject.Find("deadtrigger2.buck");

        this.animationTarget = this.Actor.GetComponent <FacialAnimation>();

        if (this.animationTarget != null)
        {
            Transform headTransform = TransformHelp.FindChildRecursive(this.Actor.transform, "BaseHead");

            this.animationTarget.SetTargetMesh(headTransform.GetComponent <SkinnedMeshRenderer>());
        }

                #if UNITY_IOS && !UNITY_EDITOR
        MicrophoneWrappers.RequestMicrophoneAccess((bool access) => {
            Debug.Log("Mic access: " + access);
        });
                #endif

        AudioConfiguration config = AudioSettings.GetConfiguration();

        config.sampleRate    = 44100;
        config.dspBufferSize = 512;
        config.speakerMode   = AudioSpeakerMode.Mono;

        AudioSettings.Reset(config);
    }