Example #1
0
    public IEnumerator UploadAnimationSet(AnimationSet set)
    {
        // Prepare the die
        var prepareDie = new DieMessageTransferAnimSet();

        prepareDie.count = (byte)set.animations.Length;
        prepareDie.totalAnimationByteSize = (short)set.GetTotalByteSize();
        Debug.Log("sending animation set setup");
        yield return(StartCoroutine(SendMessageWithAck(prepareDie, DieMessageType.TransferAnimSetAck)));

        Debug.Log("die is ready, sending animations");
        // Die is ready, perform bulk transfer for each of the animations
        foreach (var anim in set.animations)
        {
            Debug.Log("sending bulk data");
            byte[] animBytes = RGBAnimation.ToByteArray(anim);
            yield return(StartCoroutine(UploadBulkData(animBytes)));

            Debug.Log("finished sending build data, waiting");
            // Then wait until the die is ready for the next anim bulk transfer
            yield return(StartCoroutine(WaitForMessage(DieMessageType.TransferAnimReadyForNextAnim, null)));

            Debug.Log("die is ready for next anim");
        }

        // We're done!
    }