コード例 #1
0
        void OnTest2(OscMessage message)
        {
            // Get arguments from index 0, 1 and 2 safely.
            int   frameCount;
            float time;
            float random;

            if (
                message.TryGet(0, out frameCount) &&
                message.TryGet(1, out time) &&
                message.TryGet(2, out random)
                )
            {
                Debug.Log("Received test2\n" + frameCount + " " + time + " " + random + "\n");
            }

            // If you don't know what type of arguments to expect, then you
            // can check the type of each argument and get the ones you need.
            for (int i = 0; i < message.Count(); i++)
            {
                OscArgType argType;
                if (!message.TryGetArgType(i, out argType))
                {
                    continue;
                }

                switch (argType)
                {
                case OscArgType.Float:
                    float floatValue;
                    message.TryGet(i, out floatValue);
                    // Do something with floatValue here...
                    break;

                case OscArgType.Int:
                    int intValue;
                    message.TryGet(i, out intValue);
                    // Do something with intValue here...
                    break;
                }
            }

            // Always recycle incoming messages when used.
            OscPool.Recycle(message);
        }