using UnityEngine; namespace Normal.Realtime.Examples { public class VoiceMouthMove : MonoBehaviour { public SkinnedMeshRenderer[] skinned; private RealtimeAvatarVoice _voice; private float _mouthSize; void Awake() { _voice = GetComponent(); } void Update() { if (skinned != null) //not sure whether work or not { float targetMouthSize = Mathf.Lerp(0.1f, 1.0f, _voice.voiceVolume); _mouthSize = Mathf.Lerp(_mouthSize, targetMouthSize, 30.0f * Time.deltaTime); foreach (SkinnedMeshRenderer s in skinned)//not sure whether work or not { s.SetBlendShapeWeight(41, _mouthSize * 100); s.SetBlendShapeWeight(17, _mouthSize * 50); s.SetBlendShapeWeight(6, _mouthSize * 20); } } } } }
top of page

VR Development Test by using Keyboard Script

  • 作家相片: Ju Zhang
    Ju Zhang
  • 2022年3月16日
  • 讀畢需時 1 分鐘

#if !(!UNITY_EDITOR_WIN ||!UNITY_STANDALONE_WIN ||(UNITY_ANDROID && !UNITY_EDITOR))
#define VRHEADSET_UNSUPPORTED_PLATFORM
#endifusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Normal.Realtime;
 
public class ControllerSwitcher : MonoBehaviour
{
    public GameObject keyboardController;
    public Transform keyboardHead;
    public GameObject XROrigin;
    public Transform XRHead;
    public Transform XRLeftHand;
    public Transform XRRightHand;
    public Transform realtime;
 
    private RealtimeAvatarManager realtimeAvatarManager;
 
    void Start()
    {
        
        realtimeAvatarManager = realtime.GetComponent<RealtimeAvatarManager>();
        realtimeAvatarManager.avatarCreated += OnAvatarCreated;
 
#if VRHEADSET_UNSUPPORTED_PLATFORM
        XROrigin.SetActive(false);
        keyboardController.SetActive(true);
#else    XROrigin.SetActive(true);
#endif
    }
 
    void Update()
    {
    }
 
    public void OnAvatarCreated(RealtimeAvatarManager avatarManager, RealtimeAvatar avatar, bool isLocalAvatar)
    {
        if (!isLocalAvatar) return;
 
#if VRHEADSET_UNSUPPORTED_PLATFORM
        avatar.localPlayer.head = keyboardHead;
#else    avatar.localPlayer.root = XROrigin.transform;
    avatar.localPlayer.head = XRHead;
    avatar.localPlayer.leftHand = XRLeftHand;
    avatar.localPlayer.rightHand = XRRightHand;
#endif
    }
}




相關文章

查看全部
Inspector GUI

https://answers.unity.com/questions/814870/why-arent-public-variables-shown-in-the-inspector.html public variables shown in the Inspector...

 
 
 

Comments


  • Facebook
  • Twitter
  • LinkedIn

©2021 by Mianzi Ltd

bottom of page