コード例 #1
0
        void Update()
        {
            // Add the components when checked and not already loaded
            if (loadSalsaAndRandomEyes && !salsa3D && !re3D)
            {
                // Salsa3D
                gameObject.AddComponent <Salsa3D>();                                // Add a Salsa3D component
                salsa3D = GetComponent <Salsa3D>();                                 // Get reference to the Salsa3D component
                salsa3D.skinnedMeshRenderer = GetComponent <SkinnedMeshRenderer>(); // Link the SkinnedMeshRenderer
                salsa3D.saySmallIndex       = 0;                                    // Set saySmall BlendShape index
                salsa3D.sayMediumIndex      = 1;                                    // Set sayMedium BlendShape index
                salsa3D.sayLargeIndex       = 2;                                    // Set sayLarge BlendShape index
                salsa3D.SetAudioClip(audioClip);                                    // Set AudioClip
                // Or set the AudioClip from a clip in any Resources folder
                //salsa3D.SetAudioClip((Resources.Load("EthanEcho0", typeof(AudioClip)) as AudioClip));
                salsa3D.saySmallTrigger  = 0.002f;                 // Set the saySmall amplitude trigger
                salsa3D.sayMediumTrigger = 0.004f;                 // Set the sayMedium amplitude trigger
                salsa3D.sayLargeTrigger  = 0.006f;                 // Set the sayLarge amplitude trigger
                salsa3D.audioUpdateDelay = 0.08f;                  // Set the amplitutde sample update delay
                salsa3D.blendSpeed       = 10f;                    // Set the blend speed
                salsa3D.rangeOfMotion    = 100f;                   // Set the range of motion

                salsa3D.broadcast             = true;              // Enable talk event broadcasts
                salsa3D.broadcastReceivers    = new GameObject[1]; // Creat a new array of broadcast receivers
                salsa3D.broadcastReceivers[0] = broadcastReciever; // Link to a GameObject setup to listen for SALSA talk events
                salsa3D.expandBroadcast       = true;              // Expand the broadcast recievers array in the inspector

                salsa3D.Play();                                    // Begin lip sync


                // RandomEyes3D
                gameObject.AddComponent <RandomEyes3D>();                        // Add a RandomEyes3D component
                re3D = GetComponent <RandomEyes3D>();                            // Get reference to the RandomEyes3D component
                re3D.skinnedMeshRenderer = GetComponent <SkinnedMeshRenderer>(); // Link the SkinnedMeshRenderer
                re3D.lookUpIndex         = 3;                                    // Set the lookUp BlendShape index
                re3D.lookDownIndex       = 4;                                    // Set the lookDown BlendShape index
                re3D.lookLeftIndex       = 5;                                    // Set the lookLeft BlendShape index
                re3D.lookRightIndex      = 6;                                    // Set the lookRight BlendShape index
                re3D.blinkIndex          = 7;                                    // Set the blink BlendShape index
                re3D.rangeOfMotion       = 100f;                                 // Set the eyes range of motion
                re3D.blendSpeed          = 10f;                                  // Set the eyes blend speed
                re3D.blinkDuration       = 0.05f;                                // Set the blink duration
                re3D.blinkSpeed          = 20f;                                  // Set the blink speed
                re3D.SetOpenMax(0f);                                             // Set the max eye open position, 0=max
                re3D.SetCloseMax(100f);                                          // Set the max eye close position, 100=max
                re3D.SetRandomEyes(true);                                        // Enable random eye movement
                re3D.SetBlink(true);                                             // Enable random blink

                re3D.AutoLinkCustomShapes(true, salsa3D);                        // Automatically link all available BlendShapes while excluding eye and mouth shapes
                re3D.expandCustomShapes = true;                                  // Expand the custom shapes array in the inspector

                re3D.broadcastCS             = true;                             // Enable cust shape event broadcasts
                re3D.broadcastCSReceivers    = new GameObject[1];                // Creat a new array of broadcast receivers
                re3D.broadcastCSReceivers[0] = GameObject.Find("Broadcasts");    // Link to a GameObject setup to listen for RandomEyes custom shape events
                re3D.expandBroadcastCS       = true;                             // Expand the broadcast recievers array in the inspector
            }
        }
コード例 #2
0
        /// <summary>
        /// Verify all mapped BlendShape indexes by name and names by verified index
        /// </summary>
        public void VerifyIndexes()
        {
            int index = -1;

            GetShapeNames();

            if (saySmall.Count > 0)
            {
                for (int i = saySmall.Count - 1; i >= 0; i--)
                {
                    index = -1;
                    index = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(saySmall[i].shapeName);
                    if (index != -1)
                    {
                        if (index != saySmall[i].shapeIndex)
                        {
                            saySmall[i].shapeIndex = index;
                        }
                    }
                    else
                    {
                        saySmall.RemoveAt(i);
                    }
                }
            }

            if (sayMedium.Count > 0)
            {
                for (int i = sayMedium.Count - 1; i >= 0; i--)
                {
                    index = -1;
                    index = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(sayMedium[i].shapeName);
                    if (index != -1)
                    {
                        if (index != sayMedium[i].shapeIndex)
                        {
                            sayMedium[i].shapeIndex = index;
                        }
                    }
                    else
                    {
                        sayMedium.RemoveAt(i);
                    }
                }
            }

            if (sayLarge.Count > 0)
            {
                for (int i = sayLarge.Count - 1; i >= 0; i--)
                {
                    index = -1;
                    index = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(sayLarge[i].shapeName);
                    if (index != -1)
                    {
                        if (index != sayLarge[i].shapeIndex)
                        {
                            sayLarge[i].shapeIndex = index;
                        }
                    }
                    else
                    {
                        sayLarge.RemoveAt(i);
                    }
                }
            }

            if (reExpression & salsa3D)
            {
                reExpression.GetBlendShapes();
                reExpression.AutoLinkCustomShapes(true, salsa3D);
            }
        }
コード例 #3
0
        void Update()
        {
            // Add the components when checked and not already loaded
            if (loadSalsaAndRandomEyes && !salsa3D && !re3D)
            {
                // Salsa3D
                gameObject.AddComponent<Salsa3D>(); // Add a Salsa3D component
                salsa3D = GetComponent<Salsa3D>(); // Get reference to the Salsa3D component
                salsa3D.skinnedMeshRenderer = GetComponent<SkinnedMeshRenderer>(); // Link the SkinnedMeshRenderer
                salsa3D.saySmallIndex = 0; // Set saySmall BlendShape index
                salsa3D.sayMediumIndex = 1; // Set sayMedium BlendShape index
                salsa3D.sayLargeIndex = 2; // Set sayLarge BlendShape index
                salsa3D.SetAudioClip(audioClip); // Set AudioClip
                // Or set the AudioClip from a clip in any Resources folder
                //salsa3D.SetAudioClip((Resources.Load("EthanEcho0", typeof(AudioClip)) as AudioClip));
                salsa3D.saySmallTrigger = 0.002f; // Set the saySmall amplitude trigger
                salsa3D.sayMediumTrigger = 0.004f; // Set the sayMedium amplitude trigger
                salsa3D.sayLargeTrigger = 0.006f; // Set the sayLarge amplitude trigger
                salsa3D.audioUpdateDelay = 0.08f; // Set the amplitutde sample update delay
                salsa3D.blendSpeed = 10f; // Set the blend speed
                salsa3D.rangeOfMotion = 100f; // Set the range of motion

                salsa3D.broadcast = true; // Enable talk event broadcasts
                salsa3D.broadcastReceivers = new GameObject[1]; // Creat a new array of broadcast receivers
                salsa3D.broadcastReceivers[0] = broadcastReciever; // Link to a GameObject setup to listen for SALSA talk events
                salsa3D.expandBroadcast = true; // Expand the broadcast recievers array in the inspector

                salsa3D.Play(); // Begin lip sync

                // RandomEyes3D
                gameObject.AddComponent<RandomEyes3D>(); // Add a RandomEyes3D component
                re3D = GetComponent<RandomEyes3D>(); // Get reference to the RandomEyes3D component
                re3D.skinnedMeshRenderer = GetComponent<SkinnedMeshRenderer>(); // Link the SkinnedMeshRenderer
                re3D.lookUpIndex = 3; // Set the lookUp BlendShape index
                re3D.lookDownIndex = 4; // Set the lookDown BlendShape index
                re3D.lookLeftIndex = 5; // Set the lookLeft BlendShape index
                re3D.lookRightIndex = 6; // Set the lookRight BlendShape index
                re3D.blinkIndex = 7; // Set the blink BlendShape index
                re3D.rangeOfMotion = 100f; // Set the eyes range of motion
                re3D.blendSpeed = 10f; // Set the eyes blend speed
                re3D.blinkDuration = 0.05f; // Set the blink duration
                re3D.blinkSpeed = 20f; // Set the blink speed
                re3D.SetOpenMax(0f); // Set the max eye open position, 0=max
                re3D.SetCloseMax(100f); // Set the max eye close position, 100=max
                re3D.SetRandomEyes(true); // Enable random eye movement
                re3D.SetBlink(true); // Enable random blink

                re3D.broadcast = true; // Enable eye movement event broadcasts
                re3D.broadcastReceivers = new GameObject[1]; // Creat a new array of broadcast receivers
                re3D.broadcastReceivers[0] = GameObject.Find("Broadcasts"); // Link to a GameObject setup to listen for RandomEyes look events
                re3D.expandBroadcast = true; // Expand the broadcast recievers array in the inspector

                re3D.AutoLinkCustomShapes(true, salsa3D); // Automatically link all available BlendShapes while excluding eye and mouth shapes
                re3D.expandCustomShapes = true; // Expand the custom shapes array in the inspector

                re3D.broadcastCS = true; // Enable cust shape event broadcasts
                re3D.broadcastCSReceivers = new GameObject[1]; // Creat a new array of broadcast receivers
                re3D.broadcastCSReceivers[0] = GameObject.Find("Broadcasts"); // Link to a GameObject setup to listen for RandomEyes custom shape events
                re3D.expandBroadcastCS = true; // Expand the broadcast recievers array in the inspector
            }
        }